Skip to content

Commit

Permalink
Fixnishing stub test case
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Jul 2, 2015
1 parent 71dd2d6 commit 7ca6baf
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions tests/TestCase/ORM/BindingKeyTest.php
Expand Up @@ -33,6 +33,11 @@ class BindingKeyTest extends TestCase
'core.auth_users' 'core.auth_users'
]; ];


/**
* Tests that bindingKey can be used in belongsTo associations
*
* @return void
*/
public function testBelongsto() public function testBelongsto()
{ {
$users = TableRegistry::get('Users'); $users = TableRegistry::get('Users');
Expand All @@ -43,8 +48,18 @@ public function testBelongsto()


$result = $users->find() $result = $users->find()
->contain(['AuthUsers']); ->contain(['AuthUsers']);
debug($result);
debug($result->toArray());
}


$expected = ['mariano', 'nate', 'larry', 'garrett'];
$expected = array_combine($expected, $expected);
$this->assertEquals(
$expected,
$result->combine('username', 'auth_user.username')->toArray()
);

$expected = [1 => 1, 2 => 5, 3 => 2, 4 => 4];
$this->assertEquals(
$expected,
$result->combine('id', 'auth_user.id')->toArray()
);
}
} }

0 comments on commit 7ca6baf

Please sign in to comment.