Skip to content

Commit

Permalink
Add stub methods and implement remaining empty tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Oct 22, 2013
1 parent 2559b84 commit 8b9f916
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 12 deletions.
23 changes: 23 additions & 0 deletions Cake/ORM/BehaviorRegistry.php
Expand Up @@ -100,4 +100,27 @@ protected function _create($class, $settings) {
return $instance;
}

/**
* Check if any of the loaded behaviors implement a method.
*
* Will return true if any behavior provides a public method with
* the chosen name.
*
* @param string $method The method to check for.
* @return boolean
*/
public function hasMethod($method) {
}

/**
* Invoke a method on a behavior.
*
* @param string $method The method to invoke.
* @param mixed $args The arguments you want to invoke the method with should
* be provided as the remaining arguments to call()
* @return mixed The return value depends on the underlying behavior method.
*/
public function call($method) {
}

}
@@ -1,11 +1,5 @@
<?php
/**
* Behavior for binding management.
*
* Behavior to simplify manipulating a model's bindings when doing a find operation
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
Expand All @@ -18,11 +12,16 @@
* @since CakePHP(tm) v 1.2.0.5669
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace TestApp\Model\Behavior;

use Cake\ORM\Behavior;

/**
* Behavior to allow for dynamic and atomic manipulation of a Model's associations used for a find call. Most useful for limiting
* the amount of associations and data returned.
*
* Test class for trigging duplicate method errors.
*/
class PersisterTwoBehaviorBehavior extends ModelBehavior {
class DuplicateBehavior extends Behavior {

public function slugify() {
}

}
18 changes: 16 additions & 2 deletions Cake/Test/TestCase/ORM/BehaviorRegistryTest.php
Expand Up @@ -118,7 +118,8 @@ public function testLoadMissingClass() {
* @return void
*/
public function testLoadDuplicateMethodError() {
$this->markTestIncomplete('not done');
$this->Behaviors->load('Sluggable');
$this->Behaviors->load('Duplicate');
}

/**
Expand All @@ -127,7 +128,20 @@ public function testLoadDuplicateMethodError() {
* @return void
*/
public function testHasMethod() {
$this->markTestIncomplete('not done');
$this->Behaviors->load('Sluggable');
$this->assertTrue($this->Behaviors->hasMethod('slugify'));
$this->assertFalse($this->Behaviors->hasMethod('nope'));
}

/**
* test call
*
* @return void
*/
public function testCall() {
$this->Behaviors->load('Sluggable');
$result = $this->Behaviors->call('slugify', 'some value');
$this->assertEquals('some_value', $result);
}

}

0 comments on commit 8b9f916

Please sign in to comment.