Skip to content

Commit

Permalink
Add tests for previous commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Feb 27, 2016
1 parent 2d44ca9 commit fde081f
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/TestCase/ORM/AssociationTest.php
Expand Up @@ -329,6 +329,48 @@ public function testProperty()
$this->assertEquals('thing', $this->association->property());
}

/**
* Test that warning is shown if property name clashes with table field.
*
* @return void
* @expectedException PHPUnit_Framework_Error_Warning
*/
public function testPropertyNameClash()
{
$this->source->schema(['foo' => ['type' => 'string']]);
$this->assertEquals('foo', $this->association->property());
}

/**
* Test that warning is not shown if "propertyName" option is explicitly specified.
*
* @return void
*/
public function testPropertyNameExplicitySet()
{
$this->source->schema(['foo' => ['type' => 'string']]);

$config = [
'className' => '\Cake\Test\TestCase\ORM\TestTable',
'foreignKey' => 'a_key',
'conditions' => ['field' => 'value'],
'dependent' => true,
'sourceTable' => $this->source,
'joinType' => 'INNER',
'propertyName' => 'foo'
];
$association = $this->getMock(
'\Cake\ORM\Association',
[
'_options', 'attachTo', '_joinCondition', 'cascadeDelete', 'isOwningSide',
'saveAssociated', 'eagerLoader', 'type'
],
['Foo', $config]
);

$this->assertEquals('foo', $association->property());
}

/**
* Tests strategy method
*
Expand Down

0 comments on commit fde081f

Please sign in to comment.