/**
  * @return void
  */
 public function testPatchOptionalNotNull()
 {
     $this->skipIf(version_compare(Configure::version(), '3.3.7') <= 0);
     $data = ['string_optional_notnull' => '', 'active_optional_notnull' => ''];
     $entity = $this->Table->newEntity($data);
     $expected = ['string_optional_notnull' => '', 'active_optional_notnull' => false];
     $this->assertSame($expected, $entity->toArray());
 }
示例#2
0
 /**
  * @return void
  */
 public function testFormInput()
 {
     $Form = new FormHelper(new View());
     $entity = $this->Table->newEntity();
     $Form->create($entity);
     $x = $Form->input('year_of_birth', ['type' => 'year']);
     $this->assertContains('<select name="year_of_birth[year]" type="year"', $x);
     // <div class="input number"><label for="year-of-birth">Year Of Birth</label><input type="number" name="year_of_birth" id="year-of-birth"/></div>
 }
示例#3
0
 /**
  * Validator method used to check the uniqueness of a value for a column.
  * This is meant to be used with the validation API and not to be called
  * directly.
  *
  * ### Example:
  *
  * {{{
  * $validator->add('email', [
  *    'unique' => ['rule' => 'validateUnique', 'provider' => 'table']
  * ])
  * }}}
  *
  * Unique validation can be scoped to the value of another column:
  *
  * {{{
  * $validator->add('email', [
  *    'unique' => [
  *        'rule' => ['validateUnique', ['scope' => 'site_id']],
  *        'provider' => 'table'
  *    ]
  * ]);
  * }}}
  *
  * In the above example, the email uniqueness will be scoped to only rows having
  * the same site_id. Scoping will only be used if the scoping field is present in
  * the data to be validated.
  *
  * @override To allow multiple scoped values
  *
  * @param mixed $value The value of column to be checked for uniqueness
  * @param array $options The options array, optionally containing the 'scope' key
  * @param array $context The validation context as provided by the validation routine
  * @return bool true if the value is unique
  */
 public function validateUniqueExt($value, array $options, array $context = [])
 {
     $context += $options;
     return parent::validateUnique($value, $context);
 }
示例#4
0
 /**
  * Shim support for exists and primary key directly.
  *
  * @return void
  */
 public function testExistsById()
 {
     $result = $this->Posts->existsById(1);
     $this->assertTrue($result);
 }