Skip to content

Commit

Permalink
Adding another test for the IsUnique rule
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Nov 30, 2014
1 parent 6c665c7 commit e4a5af8
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/TestCase/ORM/DomainRulesIntegrationTest.php
Expand Up @@ -297,6 +297,32 @@ public function testIsUniqueDomainRule() {

$entity->name = 'jose';
$this->assertSame($entity, $table->save($entity));

$entity = $table->get(1);
$entity->dirty('name', true);
$this->assertSame($entity, $table->save($entity));
}

/**
* Tests isUnique with multiple fields
*
* @group save
* @return void
*/
public function testIsUniqueMultipleFields() {
$entity = new Entity([
'author_id' => 1,
'title' => 'First Article'
]);

$table = TableRegistry::get('Articles');
$rules = $table->domainRules();
$rules->add($rules->isUnique(['author_id', 'title']));

$this->assertFalse($table->save($entity));

$entity->author_id = 2;
$this->assertSame($entity, $table->save($entity));
}

}

0 comments on commit e4a5af8

Please sign in to comment.