Skip to content

Commit 1531a72

Browse files
committed
Removing duplicated tests, and tests for methods that are not implemented in the subclasses.
1 parent 7b4ffa2 commit 1531a72

File tree

4 files changed

+2
-250
lines changed

4 files changed

+2
-250
lines changed

cake/tests/cases/console/libs/task_collection.test.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -118,25 +118,4 @@ function testUnload() {
118118
$this->assertEquals(array('Extract'), $result, 'loaded tasks is wrong');
119119
}
120120

121-
/**
122-
* test normalizeObjectArray
123-
*
124-
* @return void
125-
*/
126-
function testnormalizeObjectArray() {
127-
$tasks = array(
128-
'Html',
129-
'Foo.Bar' => array('one', 'two'),
130-
'Something',
131-
'Banana.Apple' => array('foo' => 'bar')
132-
);
133-
$result = TaskCollection::normalizeObjectArray($tasks);
134-
$expected = array(
135-
'Html' => array('class' => 'Html', 'settings' => array()),
136-
'Bar' => array('class' => 'Foo.Bar', 'settings' => array('one', 'two')),
137-
'Something' => array('class' => 'Something', 'settings' => array()),
138-
'Apple' => array('class' => 'Banana.Apple', 'settings' => array('foo' => 'bar')),
139-
);
140-
$this->assertEquals($expected, $result);
141-
}
142121
}

cake/tests/cases/libs/controller/component_collection.test.php

Lines changed: 0 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -119,162 +119,6 @@ function testUnload() {
119119
$this->assertEquals(array('Security'), $result, 'enabled components is wrong');
120120
}
121121

122-
/**
123-
* creates mock classes for testing
124-
*
125-
* @return void
126-
*/
127-
protected function _makeMockClasses() {
128-
if (!class_exists('TriggerMockCookieComponent')) {
129-
$this->getMock('CookieComponent', array(), array(), 'TriggerMockCookieComponent', false);
130-
$this->getMock('SecurityComponent', array(), array(), 'TriggerMockSecurityComponent', false);
131-
}
132-
}
133-
134-
/**
135-
* test triggering callbacks.
136-
*
137-
* @return void
138-
*/
139-
function testTrigger() {
140-
$controller = null;
141-
$this->_makeMockClasses();
142-
$this->Components->load('TriggerMockCookie');
143-
$this->Components->load('TriggerMockSecurity');
144-
145-
$this->Components->TriggerMockCookie->expects($this->once())->method('startup')
146-
->with(null);
147-
$this->Components->TriggerMockSecurity->expects($this->once())->method('startup')
148-
->with(null);
149-
150-
$this->mockObjects[] = $this->Components->TriggerMockCookie;
151-
$this->mockObjects[] = $this->Components->TriggerMockSecurity;
152-
153-
$this->assertNull($this->Components->trigger('startup', array(&$controller)));
154-
}
155-
156-
/**
157-
* test that the initalize callback is triggered on all components even those that are disabled.
158-
*
159-
* @return void
160-
*/
161-
function testTriggerWithTriggerDisabledObjects() {
162-
$controller = 'Not a controller';
163-
164-
$this->_makeMockClasses();
165-
$this->Components->load('TriggerMockCookie', array(), false);
166-
$this->Components->load('TriggerMockSecurity');
167-
168-
$this->Components->TriggerMockCookie->expects($this->once())->method('initialize')
169-
->with($controller);
170-
$this->Components->TriggerMockSecurity->expects($this->once())->method('initialize')
171-
->with($controller);
172-
173-
$this->mockObjects[] = $this->Components->TriggerMockCookie;
174-
$this->mockObjects[] = $this->Components->TriggerMockSecurity;
175-
176-
$result = $this->Components->trigger('initialize', array(&$controller), array('triggerDisabled' => true));
177-
$this->assertNull($result);
178-
}
179-
180-
/**
181-
* test trigger and disabled helpers.
182-
*
183-
* @return void
184-
*/
185-
function testTriggerWithDisabledComponents() {
186-
$controller = null;
187-
$this->_makeMockClasses();
188-
$this->Components->load('TriggerMockCookie');
189-
$this->Components->load('TriggerMockSecurity');
190-
191-
$this->Components->TriggerMockCookie->expects($this->once())->method('startup')
192-
->with($controller);
193-
$this->Components->TriggerMockSecurity->expects($this->never())->method('startup');
194-
195-
$this->mockObjects[] = $this->Components->TriggerMockCookie;
196-
$this->mockObjects[] = $this->Components->TriggerMockSecurity;
197-
198-
$this->Components->disable('TriggerMockSecurity');
199-
200-
$this->assertNull($this->Components->trigger('startup', array(&$controller)));
201-
}
202-
203-
/**
204-
* test that the collectReturn option works.
205-
*
206-
* @return void
207-
*/
208-
function testTriggerWithCollectReturn() {
209-
$controller = null;
210-
$this->_makeMockClasses();
211-
$this->Components->load('TriggerMockCookie');
212-
$this->Components->load('TriggerMockSecurity');
213-
214-
$this->Components->TriggerMockCookie->expects($this->once())->method('startup')
215-
->will($this->returnValue(array('one', 'two')));
216-
$this->Components->TriggerMockSecurity->expects($this->once())->method('startup')
217-
->will($this->returnValue(array('three', 'four')));
218-
219-
$this->mockObjects[] = $this->Components->TriggerMockCookie;
220-
$this->mockObjects[] = $this->Components->TriggerMockSecurity;
221-
222-
$result = $this->Components->trigger('startup', array(&$controller), array('collectReturn' => true));
223-
$expected = array(
224-
array('one', 'two'),
225-
array('three', 'four')
226-
);
227-
$this->assertEquals($expected, $result);
228-
}
229-
230-
/**
231-
* test that trigger with break & breakOn works.
232-
*
233-
* @return void
234-
*/
235-
function testTriggerWithBreak() {
236-
$controller = null;
237-
$this->_makeMockClasses();
238-
$this->Components->load('TriggerMockCookie');
239-
$this->Components->load('TriggerMockSecurity');
240-
241-
$this->Components->TriggerMockCookie->expects($this->once())->method('startup')
242-
->will($this->returnValue(false));
243-
$this->Components->TriggerMockSecurity->expects($this->never())->method('startup');
244-
245-
$this->mockObjects[] = $this->Components->TriggerMockCookie;
246-
$this->mockObjects[] = $this->Components->TriggerMockSecurity;
247-
248-
$result = $this->Components->trigger(
249-
'startup',
250-
array(&$controller),
251-
array('break' => true, 'breakOn' => false)
252-
);
253-
$this->assertFalse($result);
254-
}
255-
256-
/**
257-
* test normalizeObjectArray
258-
*
259-
* @return void
260-
*/
261-
function testnormalizeObjectArray() {
262-
$components = array(
263-
'Html',
264-
'Foo.Bar' => array('one', 'two'),
265-
'Something',
266-
'Banana.Apple' => array('foo' => 'bar')
267-
);
268-
$result = ComponentCollection::normalizeObjectArray($components);
269-
$expected = array(
270-
'Html' => array('class' => 'Html', 'settings' => array()),
271-
'Bar' => array('class' => 'Foo.Bar', 'settings' => array('one', 'two')),
272-
'Something' => array('class' => 'Something', 'settings' => array()),
273-
'Apple' => array('class' => 'Banana.Apple', 'settings' => array('foo' => 'bar')),
274-
);
275-
$this->assertEquals($expected, $result);
276-
}
277-
278122
/**
279123
* test getting the controller out of the collection
280124
*

cake/tests/cases/libs/object_collection.test.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,11 @@ function testTriggerWithTriggerDisabledObjects() {
189189
}
190190

191191
/**
192-
* test trigger and disabled helpers.
192+
* test trigger and disabled objects
193193
*
194194
* @return void
195195
*/
196-
function testTriggerWithDisabledComponents() {
196+
function testTriggerWithDisabledObjects() {
197197
$this->_makeMockClasses();
198198
$this->Objects->load('TriggerMockFirst');
199199
$this->Objects->load('TriggerMockSecond');

cake/tests/cases/libs/view/helper_collection.test.php

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -116,75 +116,4 @@ function testUnload() {
116116
$this->assertEquals(array('Form'), $result, 'loaded helpers is wrong');
117117
}
118118

119-
/**
120-
* test triggering callbacks.
121-
*
122-
* @return void
123-
*/
124-
function testTrigger() {
125-
if (!class_exists('TriggerMockHtmlHelper')) {
126-
$this->getMock('HtmlHelper', array(), array($this->View), 'TriggerMockHtmlHelper');
127-
$this->getMock('FormHelper', array(), array($this->View), 'TriggerMockFormHelper');
128-
}
129-
130-
$this->Helpers->load('TriggerMockHtml');
131-
$this->Helpers->load('TriggerMockForm');
132-
133-
$this->Helpers->TriggerMockHtml->expects($this->once())->method('beforeRender')
134-
->with('one', 'two');
135-
$this->Helpers->TriggerMockForm->expects($this->once())->method('beforeRender')
136-
->with('one', 'two');
137-
138-
$this->mockObjects[] = $this->Helpers->TriggerMockForm;
139-
140-
$this->assertNull($this->Helpers->trigger('beforeRender', array('one', 'two')));
141-
}
142-
143-
/**
144-
* test trigger and disabled helpers.
145-
*
146-
* @return void
147-
*/
148-
function testTriggerWithDisabledHelpers() {
149-
if (!class_exists('TriggerMockHtmlHelper')) {
150-
$this->getMock('HtmlHelper', array(), array(), 'TriggerMockHtmlHelper', false);
151-
$this->getMock('FormHelper', array(), array(), 'TriggerMockFormHelper', false);
152-
}
153-
154-
$this->Helpers->load('TriggerMockHtml');
155-
$this->Helpers->load('TriggerMockForm');
156-
157-
$this->Helpers->TriggerMockHtml->expects($this->once())->method('beforeRender')
158-
->with('one', 'two');
159-
$this->Helpers->TriggerMockForm->expects($this->never())->method('beforeRender');
160-
161-
$this->mockObjects[] = $this->Helpers->TriggerMockForm;
162-
$this->mockObjects[] = $this->Helpers->TriggerMockHtml;
163-
164-
$this->Helpers->disable('TriggerMockForm');
165-
166-
$this->assertNull($this->Helpers->trigger('beforeRender', array('one', 'two')));
167-
}
168-
169-
/**
170-
* test normalizeObjectArray
171-
*
172-
* @return void
173-
*/
174-
function testnormalizeObjectArray() {
175-
$helpers = array(
176-
'Html',
177-
'Foo.Bar' => array('one', 'two'),
178-
'Something',
179-
'Banana.Apple' => array('foo' => 'bar')
180-
);
181-
$result = ObjectCollection::normalizeObjectArray($helpers);
182-
$expected = array(
183-
'Html' => array('class' => 'Html', 'settings' => array()),
184-
'Bar' => array('class' => 'Foo.Bar', 'settings' => array('one', 'two')),
185-
'Something' => array('class' => 'Something', 'settings' => array()),
186-
'Apple' => array('class' => 'Banana.Apple', 'settings' => array('foo' => 'bar')),
187-
);
188-
$this->assertEquals($expected, $result);
189-
}
190119
}

0 commit comments

Comments
 (0)