Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Don't verify settings on construction
Keep the method available for the option to use this in user-land code
OR potentially in semi-static analysis e.g.

    Console/cake sanitycheck /These/Files
  • Loading branch information
AD7six committed Nov 10, 2013
1 parent 6c0c82f commit 5729146
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 18 deletions.
1 change: 0 additions & 1 deletion Cake/ORM/Behavior.php
Expand Up @@ -131,7 +131,6 @@ class Behavior implements EventListener {
*/
public function __construct(Table $table, array $settings = []) {
$this->_settings = $settings + $this->_defaultSettings;
$this->verifySettings();
}

/**
Expand Down
67 changes: 50 additions & 17 deletions Cake/Test/TestCase/ORM/BehaviorTest.php
Expand Up @@ -229,23 +229,6 @@ public function testImplementedMethodsDisabled() {
$this->assertEquals($expected, $behavior->implementedMethods());
}

/**
* testImplementedMethodsInvalid
*
* @expectedException Cake\Error\Exception
* @expectedExceptionMessage The method iDoNotExist is not callable on class Cake\Test\TestCase\ORM\Test2Behavior
*
* @return void
*/
public function testImplementedMethodsInvalid() {
$table = $this->getMock('Cake\ORM\Table');
$behavior = new Test2Behavior($table, [
'implementedMethods' => [
'aliased' => 'iDoNotExist'
]
]);
}

/**
* testImplementedFinders
*
Expand Down Expand Up @@ -308,4 +291,54 @@ public function testImplementedFinderInvalid() {
]
]);
}

/**
* testImplementedMethods
*
* Simply don't expect an exception to be thrown
*
* @return void
*/
public function testVerifySettings() {
$table = $this->getMock('Cake\ORM\Table');
$behavior = new Test2Behavior($table);
$behavior->verifySettings();
}

/**
* testImplementedMethodsOverriden
*
* Simply don't expect an exception to be thrown
*
* @return void
*/
public function testVerifySettingsOverriden() {
$table = $this->getMock('Cake\ORM\Table');
$behavior = new Test2Behavior($table);
$behavior = new Test2Behavior($table, [
'implementedMethods' => [
'aliased' => 'doSomething'
]
]);
$behavior->verifySettings();
}

/**
* testImplementedMethodsInvalid
*
* @expectedException Cake\Error\Exception
* @expectedExceptionMessage The method iDoNotExist is not callable on class Cake\Test\TestCase\ORM\Test2Behavior
*
* @return void
*/
public function testVerifySettingsInvalid() {
$table = $this->getMock('Cake\ORM\Table');
$behavior = new Test2Behavior($table, [
'implementedMethods' => [
'aliased' => 'iDoNotExist'
]
]);
$behavior->verifySettings();
}

}

0 comments on commit 5729146

Please sign in to comment.