本文整理汇总了PHP中MailForm::setFormConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP MailForm::setFormConfig方法的具体用法?PHP MailForm::setFormConfig怎么用?PHP MailForm::setFormConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MailForm
的用法示例。
在下文中一共展示了MailForm::setFormConfig方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetFormConfig
public function testSetFormConfig()
{
$getArrowTempFilesByIndex = getMethod('MailForm', 'getArrowTempFilesByIndex');
$getToArrayByIndex = getMethod('MailForm', 'getToArrayByIndex');
$getFromArrayByIndex = getMethod('MailForm', 'getFromArrayByIndex');
$getMailSubjectTemplateByIndex = getMethod('MailForm', 'getMailSubjectTemplateByIndex');
$getMailBodyTemplateByIndex = getMethod('MailForm', 'getMailBodyTemplateByIndex');
$ErrorCode = getProperty('MailForm', 'ErrorCode');
$mailform = new MailForm();
$this->assertFalse($mailform->setFormConfig("", "", 100000));
$this->assertEquals(MailForm::ERROR_CODE_INVALID_FORM_CONFIG, $ErrorCode->getValue($mailform));
// フォーマットに合わなくても、大丈夫
$text = <<<EOT
{"from":"from@example.com"}
EOT;
$this->assertTrue($mailform->setFormConfig($text, "", MailForm::MAILEFORM_FILE_TYPE_JSON));
$text = <<<EOT
from: from@example.com
mailconf:
to-admin:
test: test
EOT;
$this->assertTrue($mailform->setFormConfig($text, "", MailForm::MAILEFORM_FILE_TYPE_YAML));
// フォーマットのパターンテスト
$text = <<<EOT
mailconf:
to-admin:
from: to-admin-from@example.com
to:
- to-admin-test1 <to-admin-test1@example.com>
- to-admin-test2@example.com
subject: "to-admin-subject"
arrow-temp-files: true
to-user:
from: to-user-from@example.com
to: to-user-test1@example.com
body-template-path: "to-user-mail-body-template.txt"
arrow-temp-files: false
EOT;
$this->assertTrue($mailform->setFormConfig($text, dirname(__FILE__) . '/conf'));
$froms = $getFromArrayByIndex->invokeArgs($mailform, array('to-admin'));
$this->assertCount(1, $froms);
$this->assertArrayHasKey('to-admin-from@example.com', $froms);
$this->assertEquals('', $froms['to-admin-from@example.com']);
$subject = $getMailSubjectTemplateByIndex->invokeArgs($mailform, array('to-admin'));
$this->assertEquals('to-admin-subject', $subject);
$tos = $getToArrayByIndex->invokeArgs($mailform, array('to-admin'));
$this->assertCount(2, $tos);
$this->assertArrayHasKey('to-admin-test1@example.com', $tos);
$this->assertEquals('to-admin-test1', $tos['to-admin-test1@example.com']);
$this->assertArrayHasKey('to-admin-test2@example.com', $tos);
$this->assertEquals('', $tos['to-admin-test2@example.com']);
$this->assertTrue($getArrowTempFilesByIndex->invokeArgs($mailform, array('to-admin')));
$froms = $getFromArrayByIndex->invokeArgs($mailform, array('to-user'));
$this->assertCount(1, $froms);
$this->assertArrayHasKey('to-user-from@example.com', $froms);
$this->assertEquals('', $froms['to-user-from@example.com']);
$tos = $getToArrayByIndex->invokeArgs($mailform, array('to-user'));
$this->assertCount(1, $tos);
$this->assertArrayHasKey('to-user-test1@example.com', $tos);
$this->assertEquals('', $tos['to-user-test1@example.com']);
$body = $getMailBodyTemplateByIndex->invokeArgs($mailform, array('to-user'));
$this->assertEquals('to-user-mail-body-template', $body);
$this->assertFalse($getArrowTempFilesByIndex->invokeArgs($mailform, array('to-user')));
}