Skip to content
Permalink
Browse files

Changed name to allow instead of permit

  • Loading branch information...
james.byrne
james.byrne committed Apr 12, 2016
1 parent 6fb1641 commit 7974693c26b3d0f5a2fd5511d515c10396d0e277
Showing with 10 additions and 10 deletions.
  1. +4 −4 src/ORM/Rule/IsUnique.php
  2. +6 −6 tests/TestCase/ORM/RulesCheckerIntegrationTest.php
@@ -53,9 +53,9 @@ public function __invoke(EntityInterface $entity, array $options)
return true;
}
$permitMultipleNulls = true;
if (isset($options['permitMultipleNulls'])) {
$permitMultipleNulls = $options['permitMultipleNulls'] === true ? true : false;
$allowMultipleNulls = true;
if (isset($options['allowMultipleNulls'])) {
$allowMultipleNulls = $options['allowMultipleNulls'] === true ? true : false;
}
$alias = $options['repository']->alias();
@@ -68,7 +68,7 @@ public function __invoke(EntityInterface $entity, array $options)
}
}
if (!$permitMultipleNulls) {
if (!$allowMultipleNulls) {
foreach ($conditions as $key => $value) {
if ($value === null) {
$conditions[$key . ' IS'] = $value;
@@ -370,12 +370,12 @@ public function testIsUniqueMultipleFields()
}
/**
* Tests isUnique with permitMultipleNulls
* Tests isUnique with allowMultipleNulls
*
* @group save
* @return void
*/
public function testIsUniquePermitMultipleNulls()
public function testIsUniqueAllowMultipleNulls()
{
$entity = new Entity([
'article_id' => 11,
@@ -385,7 +385,7 @@ public function testIsUniquePermitMultipleNulls()
$table = TableRegistry::get('SpecialTags');
$rules = $table->rulesChecker();
$rules->add($rules->isUnique(['author_id']), ['permitMultipleNulls' => false]);
$rules->add($rules->isUnique(['author_id']), ['allowMultipleNulls' => false]);
$this->assertFalse($table->save($entity));
$this->assertEquals(['_isUnique' => 'This value is already in use'], $entity->errors('author_id'));
@@ -399,12 +399,12 @@ public function testIsUniquePermitMultipleNulls()
}
/**
* Tests isUnique with multiple fields and permitMultipleNulls
* Tests isUnique with multiple fields and allowMultipleNulls
*
* @group save
* @return void
*/
public function testIsUniqueMultipleFieldsPermitMultipleNulls()
public function testIsUniqueMultipleFieldsAllowMultipleNulls()
{
$entity = new Entity([
'article_id' => 10,
@@ -414,7 +414,7 @@ public function testIsUniqueMultipleFieldsPermitMultipleNulls()
$table = TableRegistry::get('SpecialTags');
$rules = $table->rulesChecker();
$rules->add($rules->isUnique(['author_id', 'article_id'], 'Nope'), ['permitMultipleNulls' => false]);
$rules->add($rules->isUnique(['author_id', 'article_id'], 'Nope'), ['allowMultipleNulls' => false]);
$this->assertFalse($table->save($entity));
$this->assertEquals(['author_id' => ['_isUnique' => 'Nope']], $entity->errors());

0 comments on commit 7974693

Please sign in to comment.
You can’t perform that action at this time.