Skip to content

Commit 5729146

Browse files
committed
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
1 parent 6c0c82f commit 5729146

File tree

2 files changed

+50
-18
lines changed

2 files changed

+50
-18
lines changed

Cake/ORM/Behavior.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ class Behavior implements EventListener {
131131
*/
132132
public function __construct(Table $table, array $settings = []) {
133133
$this->_settings = $settings + $this->_defaultSettings;
134-
$this->verifySettings();
135134
}
136135

137136
/**

Cake/Test/TestCase/ORM/BehaviorTest.php

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -229,23 +229,6 @@ public function testImplementedMethodsDisabled() {
229229
$this->assertEquals($expected, $behavior->implementedMethods());
230230
}
231231

232-
/**
233-
* testImplementedMethodsInvalid
234-
*
235-
* @expectedException Cake\Error\Exception
236-
* @expectedExceptionMessage The method iDoNotExist is not callable on class Cake\Test\TestCase\ORM\Test2Behavior
237-
*
238-
* @return void
239-
*/
240-
public function testImplementedMethodsInvalid() {
241-
$table = $this->getMock('Cake\ORM\Table');
242-
$behavior = new Test2Behavior($table, [
243-
'implementedMethods' => [
244-
'aliased' => 'iDoNotExist'
245-
]
246-
]);
247-
}
248-
249232
/**
250233
* testImplementedFinders
251234
*
@@ -308,4 +291,54 @@ public function testImplementedFinderInvalid() {
308291
]
309292
]);
310293
}
294+
295+
/**
296+
* testImplementedMethods
297+
*
298+
* Simply don't expect an exception to be thrown
299+
*
300+
* @return void
301+
*/
302+
public function testVerifySettings() {
303+
$table = $this->getMock('Cake\ORM\Table');
304+
$behavior = new Test2Behavior($table);
305+
$behavior->verifySettings();
306+
}
307+
308+
/**
309+
* testImplementedMethodsOverriden
310+
*
311+
* Simply don't expect an exception to be thrown
312+
*
313+
* @return void
314+
*/
315+
public function testVerifySettingsOverriden() {
316+
$table = $this->getMock('Cake\ORM\Table');
317+
$behavior = new Test2Behavior($table);
318+
$behavior = new Test2Behavior($table, [
319+
'implementedMethods' => [
320+
'aliased' => 'doSomething'
321+
]
322+
]);
323+
$behavior->verifySettings();
324+
}
325+
326+
/**
327+
* testImplementedMethodsInvalid
328+
*
329+
* @expectedException Cake\Error\Exception
330+
* @expectedExceptionMessage The method iDoNotExist is not callable on class Cake\Test\TestCase\ORM\Test2Behavior
331+
*
332+
* @return void
333+
*/
334+
public function testVerifySettingsInvalid() {
335+
$table = $this->getMock('Cake\ORM\Table');
336+
$behavior = new Test2Behavior($table, [
337+
'implementedMethods' => [
338+
'aliased' => 'iDoNotExist'
339+
]
340+
]);
341+
$behavior->verifySettings();
342+
}
343+
311344
}

0 commit comments

Comments
 (0)