Skip to content

Commit

Permalink
Added test for ArrayContext::isPrimaryKey()
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Feb 28, 2014
1 parent 487c4aa commit 624f038
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/TestCase/View/Form/ArrayContextTest.php
Expand Up @@ -62,6 +62,45 @@ public function testPrimaryKey() {
$this->assertEquals($expected, $context->primaryKey());
}

/**
* Test isPrimaryKey.
*
* @return void
*/
public function testIsPrimaryKey() {
$context = new ArrayContext($this->request, []);
$this->assertFalse($context->isPrimaryKey('id'));

$context = new ArrayContext($this->request, [
'schema' => [
'_constraints' => 'mistake',
]
]);
$this->assertFalse($context->isPrimaryKey('mistake'));

$data = [
'schema' => [
'_constraints' => [
'primary' => ['type' => 'primary', 'columns' => ['id']]
]
],
];
$context = new ArrayContext($this->request, $data);
$this->assertTrue($context->isPrimaryKey('id'));
$this->assertFalse($context->isPrimaryKey('name'));

$data = [
'schema' => [
'_constraints' => [
'primary' => ['type' => 'primary', 'columns' => ['id', 'name']]
]
],
];
$context = new ArrayContext($this->request, $data);
$this->assertTrue($context->isPrimaryKey('id'));
$this->assertTrue($context->isPrimaryKey('name'));
}

/**
* Test the isCreate method.
*
Expand Down

0 comments on commit 624f038

Please sign in to comment.