Skip to content
Permalink
Browse files

Added tests for the bindingKey() method

  • Loading branch information...
lorenzo committed Jul 1, 2015
1 parent b0bbe8b commit 94cf64e0cff3dc1a5d3e0140901fc0c973b4cefd
Showing with 47 additions and 0 deletions.
  1. +47 −0 tests/TestCase/ORM/AssociationTest.php
@@ -120,6 +120,53 @@ public function testCascadeCallbacks()
$this->assertSame(true, $this->association->cascadeCallbacks());
}
/**
* Tests the bindingKey method as a setter/getter
*
* @return void
*/
public function testBindingKey()
{
$this->association->bindingKey('foo_id');
$this->assertEquals('foo_id', $this->association->bindingKey());
}
/**
* Tests the bindingKey() method when called with its defaults
*
* @return void
*/
public function testBindingKeyDefault()
{
$this->source->primaryKey(['id', 'site_id']);
$this->association
->expects($this->once())
->method('isOwningSide')
->will($this->returnValue(true));
$result = $this->association->bindingKey();
$this->assertEquals(['id', 'site_id'], $result);
}
/**
* Tests the bindingKey() method when the association source is not the
* owning side
*
* @return void
*/
public function testBindingDefaultNoOwningSide()
{
$target = new Table;
$target->primaryKey(['foo', 'site_id']);
$this->association->target($target);
$this->association
->expects($this->once())
->method('isOwningSide')
->will($this->returnValue(false));
$result = $this->association->bindingKey();
$this->assertEquals(['foo', 'site_id'], $result);
}
/**
* Tests that name() returns the correct configured value
*

0 comments on commit 94cf64e

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