Skip to content

Commit

Permalink
Demonstrate that there isn't alias-confusion
Browse files Browse the repository at this point in the history
When dealing with overlapping table aliases
  • Loading branch information
AD7six committed Feb 10, 2015
1 parent 6b02321 commit 9d1e8a3
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/TestCase/ORM/TableTest.php
Expand Up @@ -16,6 +16,7 @@

use ArrayObject;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\Database\Expression\OrderByExpression;
use Cake\Database\Expression\QueryExpression;
use Cake\Database\TypeMap;
Expand Down Expand Up @@ -519,6 +520,28 @@ public function testHasMany()
$this->assertSame($table, $hasMany->source());
}

/**
* Should a dupicate short-named association be defined, the earlier
* association will be inaccessible via the __get method
*
* @return void
*/
public function testHasManyPluginOverlap()
{
TableRegistry::get('Comments');
Plugin::load('TestPlugin');

$table = new Table(['table' => 'authors']);

$table->hasOne('Comments');
$comments = $table->Comments->target();
$this->assertInstanceOf('Cake\ORM\Table', $comments);

$table->hasMany('TestPlugin.Comments');
$comments = $table->Comments->target();
$this->assertInstanceOf('TestPlugin\Model\Table\CommentsTable', $comments);
}

/**
* Tests that BelongsToMany() creates and configures correctly the association
*
Expand Down

0 comments on commit 9d1e8a3

Please sign in to comment.