diff --git a/src/ORM/Table.php b/src/ORM/Table.php index 41f2e7592ff..0490771a855 100644 --- a/src/ORM/Table.php +++ b/src/ORM/Table.php @@ -480,13 +480,11 @@ public function addBehavior($name, array $options = []) { } /** - * Removes a behavior. - * - * Removes a behavior from this table's behavior collection. + * Removes a behavior from this table's behavior registry. * * Example: * - * Unload a behavior, with some settings. + * Remove a behavior from this table. * * {{{ * $this->removeBehavior('Tree'); @@ -502,15 +500,12 @@ public function removeBehavior($name) { } /** - * Get the list of Behaviors loaded. - * - * This method will return the *aliases* of the behaviors attached - * to this instance. + * Returns the behavior registry for this table. * - * @return array + * @return \Cake\ORM\BehaviorRegistry */ public function behaviors() { - return $this->_behaviors->loaded(); + return $this->_behaviors; } /** @@ -523,17 +518,6 @@ public function hasBehavior($name) { return $this->_behaviors->loaded($name); } -/** - * Returns a behavior instance with the given alias. - * - * @param string $name The behavior alias to check. - * - * @return \Cake\ORM\Behavior|null - */ - public function getBehavior($name) { - return $this->_behaviors->{$name}; - } - /** * Returns a association objected configured for the specified alias if any * diff --git a/tests/TestCase/ORM/TableTest.php b/tests/TestCase/ORM/TableTest.php index 0a0e36bbe30..5849b71e18b 100644 --- a/tests/TestCase/ORM/TableTest.php +++ b/tests/TestCase/ORM/TableTest.php @@ -1050,20 +1050,10 @@ public function testRemoveBehavior() { * * @return void */ - public function testGetBehavior() { - $returnValue = 'MockSlugInstance'; - $mock = $this->getMock('Cake\ORM\BehaviorRegistry', [], [], '', false); - $mock->expects($this->once()) - ->method('__get') - ->with('Sluggable') - ->will($this->returnValue($returnValue)); - - $table = new Table([ - 'table' => 'articles', - 'behaviors' => $mock - ]); - $result = $table->getBehavior('Sluggable'); - $this->assertSame($returnValue, $result); + public function testBehaviors() { + $table = TableRegistry::get('article'); + $result = $table->behaviors(); + $this->assertInstanceOf('\Cake\ORM\BehaviorRegistry', $result); } /** @@ -2255,10 +2245,8 @@ public function testMagicFindAllOr() { */ public function testBehaviorIntrospection() { $table = TableRegistry::get('users'); - $this->assertEquals([], $table->behaviors(), 'no loaded behaviors'); $table->addBehavior('Timestamp'); - $this->assertEquals(['Timestamp'], $table->behaviors(), 'Should have loaded behavior'); $this->assertTrue($table->hasBehavior('Timestamp'), 'should be true on loaded behavior'); $this->assertFalse($table->hasBehavior('Tree'), 'should be false on unloaded behavior'); }