public function testSetRequestParameter() { $Status = getProperty('MailForm', 'Status'); $RequestParam = getProperty('MailForm', 'RequestParam'); mb_internal_encoding("UTF-8"); $ErrorCode = getProperty('MailForm', 'ErrorCode'); $mailform = new MailForm(); $mailform->setRequestParameter(array()); $this->assertEquals(MailForm::ERROR_CODE_INVALID_FORM_CONFIG, $ErrorCode->getValue($mailform)); $filepath = dirname(__FILE__) . '/conf/mailform_config_for_RequestParameter.yml'; $mailform->loadFormConfig($filepath, 'templateDirectoryPath'); $param = array('mailform-confirm-submit' => '1', 'username' => '㈱テスト', 'other' => 'other'); $mailform->setRequestParameter($param); $requestParam = $RequestParam->getValue($mailform); $this->assertArrayHasKey('username', $requestParam); $this->assertEquals('(株)テスト', $requestParam['username']); $this->assertArrayNotHasKey('kana', $requestParam); $this->assertArrayNotHasKey('other', $requestParam); $status = $Status->getValue($mailform); $this->assertEquals(MailForm::STATUS_CONFIRMATION, $status); }
<?php mb_language('japanese'); mb_internal_encoding('UTF-8'); require_once dirname(__FILE__) . '/../../lib/class.mailform.php'; $mailform = new MailForm(); // メールフォームのテンプレートファイルのパスを設定 $base_path = dirname(__FILE__) . '/'; $mailform->InputURL = $base_path . 'input.php'; $mailform->ConfirmURL = $base_path . 'confirm.php'; $mailform->CompleteURL = $base_path . 'complete.php'; $mailform->ErrorURL = $base_path . 'input.php'; // フォームの設定を読み込む $mailform->loadFormConfig(dirname(__FILE__) . "/conf/mailform_config.yml", dirname(__FILE__) . "/conf"); // データを設定 $mailform->setRequestParameter($_POST); // 実行 $mailform->execute();