本文整理汇总了PHP中ValidationTest1::create方法的典型用法代码示例。如果您正苦于以下问题:PHP ValidationTest1::create方法的具体用法?PHP ValidationTest1::create怎么用?PHP ValidationTest1::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ValidationTest1
的用法示例。
在下文中一共展示了ValidationTest1::create方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAllowSimulatedFields
/**
* Tests validation parameter order in custom validation methods
*
* @return void
*/
public function testAllowSimulatedFields()
{
$TestModel = new ValidationTest1();
$TestModel->create(array('title' => 'foo', 'bar' => 'baz'));
$expected = array('ValidationTest1' => array('title' => 'foo', 'bar' => 'baz'));
$this->assertEquals($expected, $TestModel->data);
}
示例2: testValidationMessageAsArray
/**
* Test placeholder replacement when validation message is an array
*
* @return void
*/
public function testValidationMessageAsArray()
{
$TestModel = new ValidationTest1();
$TestModel->validate = array('title' => array('minLength' => array('rule' => array('minLength', 6), 'required' => true, 'message' => 'Minimum length allowed is %d chars', 'last' => false), 'between' => array('rule' => array('between', 5, 15), 'message' => array('You may enter up to %s chars (minimum is %s chars)', 14, 6))));
$TestModel->create();
$TestModel->invalidFields();
$expected = array('title' => array('Minimum length allowed is 6 chars'));
$this->assertEquals($TestModel->validationErrors, $expected);
$TestModel->create(array('title' => 'foo'));
$TestModel->invalidFields();
$expected = array('title' => array('Minimum length allowed is 6 chars', 'You may enter up to 14 chars (minimum is 6 chars)'));
$this->assertEquals($TestModel->validationErrors, $expected);
}
示例3: testValidationMessageTranslation
/**
* Test validation message translation
*
* @return void
*/
public function testValidationMessageTranslation()
{
$lang = Configure::read('Config.language');
Configure::write('Config.language', 'en');
App::build(array('Locale' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Locale' . DS)), App::RESET);
$TestModel = new ValidationTest1();
$TestModel->validationDomain = 'validation_messages';
$TestModel->validate = array('title' => array(array('rule' => array('customValidationMethod', 'arg1'), 'required' => true, 'message' => 'Validation failed: %s')));
$TestModel->create();
$expected = array('title' => array('Translated validation failed: Translated arg1'));
$TestModel->invalidFields();
$this->assertEquals($expected, $TestModel->validationErrors);
$TestModel->validationDomain = 'default';
Configure::write('Config.language', $lang);
App::build();
}
示例4: testMissingValidationErrorNoTriggering
/**
* Test that missing validation methods does not trigger errors in production mode.
*
* @return void
*/
public function testMissingValidationErrorNoTriggering()
{
Configure::write('debug', 0);
$TestModel = new ValidationTest1();
$TestModel->create(array('title' => 'foo'));
$TestModel->validate = array('title' => array('rule' => array('thisOneBringsThePain'), 'required' => true));
$TestModel->invalidFields(array('fieldList' => array('title')));
$this->assertEquals($TestModel->validationErrors, array());
}