public function testSetParamToSession()
 {
     $setParamToSession = getMethod('MailForm', 'setParamToSession');
     $ErrorMessages = getProperty('MailForm', 'ErrorMessages');
     $mailform = new MailForm();
     $mailform->loadFormConfig(dirname(__FILE__) . '/conf/mailform_config.yml', dirname(__FILE__) . '/conf/');
     $factory = new InnerSessionFactory();
     $mailform->setSessionFactory($factory);
     $session = $factory->getInstance();
     $requestParameter = array('kind' => 1);
     $errorMessages = array('username', '「username」は必ず入力してください。');
     $ErrorMessages->setValue($mailform, $errorMessages);
     $mailform->setRequestParameter($requestParameter);
     $setParamToSession->invokeArgs($mailform, array());
     $this->assertEquals($errorMessages, $session->getParamValue('error_messages'));
     $this->assertEquals($requestParameter, $session->getParamValue('item_values'));
     $session->setParam('item_values', array('kind' => 2, 'temp' => 'test.pdf'));
     $ErrorMessages->setValue($mailform, $errorMessages);
     $mailform->setRequestParameter($requestParameter);
     $setParamToSession->invokeArgs($mailform, array());
     $this->assertEquals($errorMessages, $session->getParamValue('error_messages'));
     $sessionItemValues = $session->getParamValue('item_values');
     $this->assertEquals('test.pdf', $sessionItemValues['temp']);
 }
Пример #2
0
<?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();