Skip to content
Permalink
Browse files

Remove automatic table alias handling.

As discussed in #2761 we shouldn't support automatic table aliases in
entity paths. They are not required and only really serve to bloat HTML.
Not having them makes reading entity properties, handling request data
and forms consistent.
  • Loading branch information...
markstory committed Feb 4, 2014
1 parent 4af2637 commit cd9a0f76c88fa940027fc8e75b40d31a3b092b60
Showing with 2 additions and 30 deletions.
  1. +0 −5 src/View/Form/EntityContext.php
  2. +2 −25 tests/TestCase/View/Form/EntityContextTest.php
@@ -135,11 +135,6 @@ protected function _getEntity($path) {
return [$entity, $this->_rootName];
}
// Remove the Table name if present.
if (count($path) > 1 && $path[0] === $this->_rootName) {
array_shift($path);
}
$lastProp = $this->_rootName;
foreach ($path as $prop) {
$next = $this->_getProp($entity, $prop);
@@ -58,21 +58,12 @@ public function testValBasic() {
'entity' => $row,
'table' => 'Articles',
]);
$result = $context->val('Articles.title');
$this->assertEquals($row->title, $result);
$result = $context->val('title');
$this->assertEquals($row->title, $result);
$result = $context->val('Articles.body');
$this->assertEquals($row->body, $result);
$result = $context->val('body');
$this->assertEquals($row->body, $result);
$result = $context->val('Articles.nope');
$this->assertNull($result);
$result = $context->val('nope');
$this->assertNull($result);
}
@@ -99,28 +90,19 @@ public function testValAssociated() {
'table' => 'Articles',
]);
$result = $context->val('Articles.user.fname');
$this->assertEquals($row->user->fname, $result);
$result = $context->val('user.fname');
$this->assertEquals($row->user->fname, $result);
$result = $context->val('Articles.comments.0.comment');
$this->assertEquals($row->comments[0]->comment, $result);
$result = $context->val('comments.0.comment');
$this->assertEquals($row->comments[0]->comment, $result);
$result = $context->val('Articles.comments.1.comment');
$this->assertEquals($row->comments[1]->comment, $result);
$result = $context->val('comments.1.comment');
$this->assertEquals($row->comments[1]->comment, $result);
$result = $context->val('Articles.comments.0.nope');
$result = $context->val('comments.0.nope');
$this->assertNull($result);
$result = $context->val('Articles.comments.0.nope.no_way');
$result = $context->val('comments.0.nope.no_way');
$this->assertNull($result);
}
@@ -138,9 +120,7 @@ public function testIsRequiredStringValidator() {
'validator' => 'create',
]);
$this->assertTrue($context->isRequired('Articles.title'));
$this->assertTrue($context->isRequired('title'));
$this->assertFalse($context->isRequired('Articles.body'));
$this->assertFalse($context->isRequired('body'));
$this->assertFalse($context->isRequired('Herp.derp.derp'));
@@ -175,10 +155,7 @@ public function testIsRequiredAssociatedHasMany() {
]);
$this->assertTrue($context->isRequired('comments.0.user_id'));
$this->assertTrue($context->isRequired('Articles.comments.0.user_id'));
$this->assertFalse($context->isRequired('comments.0.other'));
$this->assertFalse($context->isRequired('Articles.comments.0.other'));
}
/**

0 comments on commit cd9a0f7

Please sign in to comment.
You can’t perform that action at this time.