Skip to content

Commit

Permalink
Add test for the getBehavior() method.
Browse files Browse the repository at this point in the history
  • Loading branch information
sdustinh committed Jan 16, 2018
1 parent c3005dc commit a78591a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/TestCase/ORM/TableTest.php
Expand Up @@ -1786,6 +1786,21 @@ public function testBehaviors()
$this->assertInstanceOf('Cake\ORM\BehaviorRegistry', $result);
}

/**
* Test that the getBehavior() method retrieves a behavior from the table registry.
*
* @return void
*/
public function testGetBehavior()
{
$table = new Table(['table' => 'comments']);
$table->addBehavior('Sluggable');

$this->assertSame($table->behaviors()->get('Sluggable'), $table->getBehavior('Sluggable'));
$this->assertFalse($table->hasBehavior('FakeBehavior'));
$this->assertNull($table->getBehavior('FakeBehavior'));
}

/**
* Ensure exceptions are raised on missing behaviors.
*
Expand Down

0 comments on commit a78591a

Please sign in to comment.