Permalink
Browse files

Adding test for

  • Loading branch information...
1 parent 624f038 commit 80fc34915715f38dc87b3e872ce7ff1c942304ad @lorenzo lorenzo committed Feb 28, 2014
Showing with 20 additions and 0 deletions.
  1. +20 −0 tests/TestCase/View/Form/EntityContextTest.php
View
20 tests/TestCase/View/Form/EntityContextTest.php
@@ -67,6 +67,26 @@ public function testPrimaryKey() {
}
/**
+ * 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.
*
* @return void

0 comments on commit 80fc349

Please sign in to comment.