當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ValidationTest1類代碼示例

本文整理匯總了PHP中ValidationTest1的典型用法代碼示例。如果您正苦於以下問題:PHP ValidationTest1類的具體用法?PHP ValidationTest1怎麽用?PHP ValidationTest1使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ValidationTest1類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
 }
開發者ID:manzapanza,項目名稱:cakephp-api-utils,代碼行數:12,代碼來源:ModelWriteTest.php

示例2: testInvalidAssociation

 /**
  * Tests validation parameter order in custom validation methods
  *
  * @return void
  */
 public function testInvalidAssociation()
 {
     $TestModel = new ValidationTest1();
     $this->assertNull($TestModel->getAssociated('Foo'));
 }
開發者ID:agashish,項目名稱:test_new,代碼行數:10,代碼來源:ModelIntegrationTest.php

示例3: 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);
 }
開發者ID:MrGrigorev,項目名稱:reserva-de-salas,代碼行數:18,代碼來源:ModelValidationTest.php

示例4: 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();
 }
開發者ID:kuradakis,項目名稱:cakephp-ex,代碼行數:21,代碼來源:ModelValidationTest.php

示例5: 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());
 }
開發者ID:Nervie,項目名稱:Beta,代碼行數:14,代碼來源:ModelValidationTest.php


注:本文中的ValidationTest1類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。