Skip to content

Commit

Permalink
Adding test for loading belongsTo with loadInto when having
Browse files Browse the repository at this point in the history
composite primary keys
  • Loading branch information
lorenzo committed Jun 28, 2015
1 parent 86700ed commit b7a7106
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/TestCase/ORM/CompositeKeysTest.php
Expand Up @@ -693,6 +693,27 @@ public function testLoadInto()
$this->assertEquals($expected, $result);
}

/**
* Tets that loadInto() is capable of handling composite primary keys
* when loading belongsTo assocaitions
*
* @return void
*/
public function testLoadIntoWithBelongsTo()
{
$table = TableRegistry::get('SiteArticles');
$table->belongsTo('SiteAuthors', [
'foreignKey' => ['author_id', 'site_id'],
]);

$author = $table->get([2, 2]);
$result = $table->loadInto($author, ['SiteAuthors']);
$this->assertSame($author, $result);

$expected = $table->get([2, 2], ['contain' => ['SiteAuthors']]);
$this->assertEquals($expected, $result);
}

/**
* Tets that loadInto() is capable of handling composite primary keys
* when loading into multiple entities
Expand Down

0 comments on commit b7a7106

Please sign in to comment.