Skip to content

Commit

Permalink
Added test for association dot syntax format
Browse files Browse the repository at this point in the history
Reference: #11366
  • Loading branch information
sdustinh committed Oct 25, 2017
1 parent 8b260f6 commit 66bbca2
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/TestCase/ORM/TableTest.php
Expand Up @@ -510,6 +510,30 @@ function (Event $event, $query, $options) use ($expected) {
$this->assertEquals($expected, $query->all()->toArray());
}

/**
* Test that the association() method supports the dot syntax.
*
* @return void
*/
public function testAssociationDotSyntax()
{
$groups = TableRegistry::get('Groups');
$members = TableRegistry::get('Members');
$groupsMembers = TableRegistry::get('GroupsMembers');

$groups->belongsToMany('Members');
$groups->hasMany('GroupsMembers');
$groupsMembers->belongsTo('Members');
$members->belongsToMany('Groups');

$association = $groups->association('GroupsMembers.Members.Groups');
$this->assertInstanceOf('Cake\ORM\Association\BelongsToMany', $association);
$this->assertSame(
$groups->association('GroupsMembers')->association('Members')->association('Groups'),
$association
);
}

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

0 comments on commit 66bbca2

Please sign in to comment.