Skip to content

Commit

Permalink
Renaming option meant to avoid rule checking during the save process
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Dec 2, 2014
1 parent 0f2ee80 commit 8ec2efd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ORM/Table.php
Expand Up @@ -1188,7 +1188,7 @@ public function save(EntityInterface $entity, $options = []) {
$options = new \ArrayObject($options + [
'atomic' => true,
'associated' => true,
'domainCheck' => true
'checkRules' => true
]);

if ($entity->errors()) {
Expand Down Expand Up @@ -1231,7 +1231,7 @@ protected function _processSave($entity, $options) {
$entity->isNew(!$this->exists($conditions));
}

if ($options['domainCheck'] && !$this->checkDomainRules($entity)) {
if ($options['checkRules'] && !$this->checkDomainRules($entity)) {
return false;
}

Expand Down
19 changes: 19 additions & 0 deletions tests/TestCase/ORM/RulesCheckerIntegrationTest.php
Expand Up @@ -359,4 +359,23 @@ public function testExistsInDomainRuleWithObject() {
$this->assertEquals(['Nope'], $entity->errors('author_id'));
}

/**
* Tests the checkRules save option
*
* @group save
* @return void
*/
public function testSkipRulesChecking() {
$entity = new Entity([
'title' => 'An Article',
'author_id' => 500
]);

$table = TableRegistry::get('Articles');
$rules = $table->domainRules();
$rules->add($rules->existsIn('author_id', TableRegistry::get('Authors'), 'Nope'));

$this->assertSame($entity, $table->save($entity, ['checkRules' => false]));
}

}

0 comments on commit 8ec2efd

Please sign in to comment.