Skip to content

Commit

Permalink
Adding test for
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Feb 28, 2014
1 parent 624f038 commit 80fc349
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/TestCase/View/Form/EntityContextTest.php
Expand Up @@ -66,6 +66,26 @@ public function testPrimaryKey() {
$this->assertEquals(['id'], $context->primaryKey());
}

/**
* Test isPrimaryKey
*
* @return void
*/
public function testIsPrimaryKey() {
$row = new Article();
$context = new EntityContext($this->request, [
'entity' => $row,
]);
$this->assertTrue($context->isPrimaryKey('id'));
$this->assertFalse($context->isPrimaryKey('title'));
$this->assertTrue($context->isPrimaryKey('1.id'));
$this->assertTrue($context->isPrimaryKey('Articles.1.id'));
$this->assertTrue($context->isPrimaryKey('comments.0.id'));
$this->assertTrue($context->isPrimaryKey('1.comments.0.id'));
$this->assertFalse($context->isPrimaryKey('1.comments.0.comment'));
$this->assertFalse($context->isPrimaryKey('1.comments.0.comment'));
}

/**
* Test isCreate on a single entity.
*
Expand Down

0 comments on commit 80fc349

Please sign in to comment.