Skip to content

Commit

Permalink
Added tests for the bindingKey() method
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Jul 1, 2015
1 parent b0bbe8b commit 94cf64e
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/TestCase/ORM/AssociationTest.php
Expand Up @@ -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
*
Expand Down

0 comments on commit 94cf64e

Please sign in to comment.