Skip to content

Commit

Permalink
Merge pull request #8329 from ifunk/feature-assoc-classname
Browse files Browse the repository at this point in the history
Add getter for protected $_className value for Association.
  • Loading branch information
markstory committed Feb 25, 2016
2 parents 262ec6e + f804099 commit bca53dc
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/ORM/Association.php
Expand Up @@ -260,6 +260,16 @@ public function cascadeCallbacks($cascadeCallbacks = null)
return $this->_cascadeCallbacks;
}

/**
* The class name of the target table object
*
* @return string
*/
public function className()
{
return $this->_className;
}

/**
* Sets the table instance for the source side of the association. If no arguments
* are passed, the current configured table instance is returned
Expand Down
32 changes: 32 additions & 0 deletions tests/TestCase/ORM/AssociationTest.php
Expand Up @@ -108,6 +108,38 @@ public function testName()
$this->assertEquals('Bar', $this->association->name());
}

/**
* Tests that className() returns the correct association className
*
* @return void
*/
public function testClassName()
{
$this->assertEquals('\Cake\Test\TestCase\ORM\TestTable', $this->association->className());
}

/**
* Tests that className() returns the correct (unnormalized) className
*
* @return void
*/
public function testClassNameUnnormalized()
{
$config = [
'className' => 'Test',
];
$this->association = $this->getMock(
'\Cake\ORM\Association',
[
'_options', 'attachTo', '_joinCondition', 'cascadeDelete', 'isOwningSide',
'saveAssociated', 'eagerLoader', 'type'
],
['Foo', $config]
);

$this->assertEquals('Test', $this->association->className());
}

/**
* Tests that cascadeCallbacks() returns the correct configured value
*
Expand Down

0 comments on commit bca53dc

Please sign in to comment.