From 1531a7226e8cb1317e8a17d7a7c2b06f261e4e5d Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 14 Dec 2010 23:26:24 -0500 Subject: [PATCH] Removing duplicated tests, and tests for methods that are not implemented in the subclasses. --- .../console/libs/task_collection.test.php | 21 --- .../controller/component_collection.test.php | 156 ------------------ .../cases/libs/object_collection.test.php | 4 +- .../libs/view/helper_collection.test.php | 71 -------- 4 files changed, 2 insertions(+), 250 deletions(-) diff --git a/cake/tests/cases/console/libs/task_collection.test.php b/cake/tests/cases/console/libs/task_collection.test.php index da7d6eaefbd..b89de158cf7 100644 --- a/cake/tests/cases/console/libs/task_collection.test.php +++ b/cake/tests/cases/console/libs/task_collection.test.php @@ -118,25 +118,4 @@ function testUnload() { $this->assertEquals(array('Extract'), $result, 'loaded tasks is wrong'); } -/** - * test normalizeObjectArray - * - * @return void - */ - function testnormalizeObjectArray() { - $tasks = array( - 'Html', - 'Foo.Bar' => array('one', 'two'), - 'Something', - 'Banana.Apple' => array('foo' => 'bar') - ); - $result = TaskCollection::normalizeObjectArray($tasks); - $expected = array( - 'Html' => array('class' => 'Html', 'settings' => array()), - 'Bar' => array('class' => 'Foo.Bar', 'settings' => array('one', 'two')), - 'Something' => array('class' => 'Something', 'settings' => array()), - 'Apple' => array('class' => 'Banana.Apple', 'settings' => array('foo' => 'bar')), - ); - $this->assertEquals($expected, $result); - } } \ No newline at end of file diff --git a/cake/tests/cases/libs/controller/component_collection.test.php b/cake/tests/cases/libs/controller/component_collection.test.php index ff96199b198..ecdac7775cd 100644 --- a/cake/tests/cases/libs/controller/component_collection.test.php +++ b/cake/tests/cases/libs/controller/component_collection.test.php @@ -119,162 +119,6 @@ function testUnload() { $this->assertEquals(array('Security'), $result, 'enabled components is wrong'); } -/** - * creates mock classes for testing - * - * @return void - */ - protected function _makeMockClasses() { - if (!class_exists('TriggerMockCookieComponent')) { - $this->getMock('CookieComponent', array(), array(), 'TriggerMockCookieComponent', false); - $this->getMock('SecurityComponent', array(), array(), 'TriggerMockSecurityComponent', false); - } - } - -/** - * test triggering callbacks. - * - * @return void - */ - function testTrigger() { - $controller = null; - $this->_makeMockClasses(); - $this->Components->load('TriggerMockCookie'); - $this->Components->load('TriggerMockSecurity'); - - $this->Components->TriggerMockCookie->expects($this->once())->method('startup') - ->with(null); - $this->Components->TriggerMockSecurity->expects($this->once())->method('startup') - ->with(null); - - $this->mockObjects[] = $this->Components->TriggerMockCookie; - $this->mockObjects[] = $this->Components->TriggerMockSecurity; - - $this->assertNull($this->Components->trigger('startup', array(&$controller))); - } - -/** - * test that the initalize callback is triggered on all components even those that are disabled. - * - * @return void - */ - function testTriggerWithTriggerDisabledObjects() { - $controller = 'Not a controller'; - - $this->_makeMockClasses(); - $this->Components->load('TriggerMockCookie', array(), false); - $this->Components->load('TriggerMockSecurity'); - - $this->Components->TriggerMockCookie->expects($this->once())->method('initialize') - ->with($controller); - $this->Components->TriggerMockSecurity->expects($this->once())->method('initialize') - ->with($controller); - - $this->mockObjects[] = $this->Components->TriggerMockCookie; - $this->mockObjects[] = $this->Components->TriggerMockSecurity; - - $result = $this->Components->trigger('initialize', array(&$controller), array('triggerDisabled' => true)); - $this->assertNull($result); - } - -/** - * test trigger and disabled helpers. - * - * @return void - */ - function testTriggerWithDisabledComponents() { - $controller = null; - $this->_makeMockClasses(); - $this->Components->load('TriggerMockCookie'); - $this->Components->load('TriggerMockSecurity'); - - $this->Components->TriggerMockCookie->expects($this->once())->method('startup') - ->with($controller); - $this->Components->TriggerMockSecurity->expects($this->never())->method('startup'); - - $this->mockObjects[] = $this->Components->TriggerMockCookie; - $this->mockObjects[] = $this->Components->TriggerMockSecurity; - - $this->Components->disable('TriggerMockSecurity'); - - $this->assertNull($this->Components->trigger('startup', array(&$controller))); - } - -/** - * test that the collectReturn option works. - * - * @return void - */ - function testTriggerWithCollectReturn() { - $controller = null; - $this->_makeMockClasses(); - $this->Components->load('TriggerMockCookie'); - $this->Components->load('TriggerMockSecurity'); - - $this->Components->TriggerMockCookie->expects($this->once())->method('startup') - ->will($this->returnValue(array('one', 'two'))); - $this->Components->TriggerMockSecurity->expects($this->once())->method('startup') - ->will($this->returnValue(array('three', 'four'))); - - $this->mockObjects[] = $this->Components->TriggerMockCookie; - $this->mockObjects[] = $this->Components->TriggerMockSecurity; - - $result = $this->Components->trigger('startup', array(&$controller), array('collectReturn' => true)); - $expected = array( - array('one', 'two'), - array('three', 'four') - ); - $this->assertEquals($expected, $result); - } - -/** - * test that trigger with break & breakOn works. - * - * @return void - */ - function testTriggerWithBreak() { - $controller = null; - $this->_makeMockClasses(); - $this->Components->load('TriggerMockCookie'); - $this->Components->load('TriggerMockSecurity'); - - $this->Components->TriggerMockCookie->expects($this->once())->method('startup') - ->will($this->returnValue(false)); - $this->Components->TriggerMockSecurity->expects($this->never())->method('startup'); - - $this->mockObjects[] = $this->Components->TriggerMockCookie; - $this->mockObjects[] = $this->Components->TriggerMockSecurity; - - $result = $this->Components->trigger( - 'startup', - array(&$controller), - array('break' => true, 'breakOn' => false) - ); - $this->assertFalse($result); - } - -/** - * test normalizeObjectArray - * - * @return void - */ - function testnormalizeObjectArray() { - $components = array( - 'Html', - 'Foo.Bar' => array('one', 'two'), - 'Something', - 'Banana.Apple' => array('foo' => 'bar') - ); - $result = ComponentCollection::normalizeObjectArray($components); - $expected = array( - 'Html' => array('class' => 'Html', 'settings' => array()), - 'Bar' => array('class' => 'Foo.Bar', 'settings' => array('one', 'two')), - 'Something' => array('class' => 'Something', 'settings' => array()), - 'Apple' => array('class' => 'Banana.Apple', 'settings' => array('foo' => 'bar')), - ); - $this->assertEquals($expected, $result); - } - /** * test getting the controller out of the collection * diff --git a/cake/tests/cases/libs/object_collection.test.php b/cake/tests/cases/libs/object_collection.test.php index fd51cbecdf3..73e0fec4fe1 100644 --- a/cake/tests/cases/libs/object_collection.test.php +++ b/cake/tests/cases/libs/object_collection.test.php @@ -189,11 +189,11 @@ function testTriggerWithTriggerDisabledObjects() { } /** - * test trigger and disabled helpers. + * test trigger and disabled objects * * @return void */ - function testTriggerWithDisabledComponents() { + function testTriggerWithDisabledObjects() { $this->_makeMockClasses(); $this->Objects->load('TriggerMockFirst'); $this->Objects->load('TriggerMockSecond'); diff --git a/cake/tests/cases/libs/view/helper_collection.test.php b/cake/tests/cases/libs/view/helper_collection.test.php index 403bbc8e7c2..d5f1480dd2a 100644 --- a/cake/tests/cases/libs/view/helper_collection.test.php +++ b/cake/tests/cases/libs/view/helper_collection.test.php @@ -116,75 +116,4 @@ function testUnload() { $this->assertEquals(array('Form'), $result, 'loaded helpers is wrong'); } -/** - * test triggering callbacks. - * - * @return void - */ - function testTrigger() { - if (!class_exists('TriggerMockHtmlHelper')) { - $this->getMock('HtmlHelper', array(), array($this->View), 'TriggerMockHtmlHelper'); - $this->getMock('FormHelper', array(), array($this->View), 'TriggerMockFormHelper'); - } - - $this->Helpers->load('TriggerMockHtml'); - $this->Helpers->load('TriggerMockForm'); - - $this->Helpers->TriggerMockHtml->expects($this->once())->method('beforeRender') - ->with('one', 'two'); - $this->Helpers->TriggerMockForm->expects($this->once())->method('beforeRender') - ->with('one', 'two'); - - $this->mockObjects[] = $this->Helpers->TriggerMockForm; - - $this->assertNull($this->Helpers->trigger('beforeRender', array('one', 'two'))); - } - -/** - * test trigger and disabled helpers. - * - * @return void - */ - function testTriggerWithDisabledHelpers() { - if (!class_exists('TriggerMockHtmlHelper')) { - $this->getMock('HtmlHelper', array(), array(), 'TriggerMockHtmlHelper', false); - $this->getMock('FormHelper', array(), array(), 'TriggerMockFormHelper', false); - } - - $this->Helpers->load('TriggerMockHtml'); - $this->Helpers->load('TriggerMockForm'); - - $this->Helpers->TriggerMockHtml->expects($this->once())->method('beforeRender') - ->with('one', 'two'); - $this->Helpers->TriggerMockForm->expects($this->never())->method('beforeRender'); - - $this->mockObjects[] = $this->Helpers->TriggerMockForm; - $this->mockObjects[] = $this->Helpers->TriggerMockHtml; - - $this->Helpers->disable('TriggerMockForm'); - - $this->assertNull($this->Helpers->trigger('beforeRender', array('one', 'two'))); - } - -/** - * test normalizeObjectArray - * - * @return void - */ - function testnormalizeObjectArray() { - $helpers = array( - 'Html', - 'Foo.Bar' => array('one', 'two'), - 'Something', - 'Banana.Apple' => array('foo' => 'bar') - ); - $result = ObjectCollection::normalizeObjectArray($helpers); - $expected = array( - 'Html' => array('class' => 'Html', 'settings' => array()), - 'Bar' => array('class' => 'Foo.Bar', 'settings' => array('one', 'two')), - 'Something' => array('class' => 'Something', 'settings' => array()), - 'Apple' => array('class' => 'Banana.Apple', 'settings' => array('foo' => 'bar')), - ); - $this->assertEquals($expected, $result); - } } \ No newline at end of file