Skip to content
This repository
Browse code

Fix tests that fail in PHPUnit 3.7

Add skips for PHPUnit 3.6. Mock object expects required clones in 3.6,
but fail in 3.7 with clones.
  • Loading branch information...
commit f89fe0e1efcd77877a3fab8f13e41a7e129639f9 1 parent 805b44f
Mark Story authored October 15, 2012
22  lib/Cake/Test/Case/Event/CakeEventManagerTest.php
@@ -234,6 +234,10 @@ public function testDispatchWithKeyName() {
234 234
  * @return void
235 235
  */
236 236
 	public function testDispatchReturnValue() {
  237
+		$this->skipIf(
  238
+			version_compare(PHPUnit_Runner_Version::VERSION, '3.7', '<'),
  239
+			'These tests fail in PHPUnit 3.6'
  240
+		);
237 241
 		$manager = new CakeEventManager;
238 242
 		$listener = $this->getMock('CakeEventTestListener');
239 243
 		$anotherListener = $this->getMock('CakeEventTestListener');
@@ -241,11 +245,12 @@ public function testDispatchReturnValue() {
241 245
 		$manager->attach(array($anotherListener, 'listenerFunction'), 'fake.event');
242 246
 		$event = new CakeEvent('fake.event');
243 247
 
244  
-		$firstStep = clone $event;
245 248
 		$listener->expects($this->at(0))->method('listenerFunction')
246  
-			->with($firstStep)
  249
+			->with($event)
247 250
 			->will($this->returnValue('something special'));
248  
-		$anotherListener->expects($this->at(0))->method('listenerFunction')->with($event);
  251
+		$anotherListener->expects($this->at(0))
  252
+			->method('listenerFunction')
  253
+			->with($event);
249 254
 		$manager->dispatch($event);
250 255
 		$this->assertEquals('something special', $event->result);
251 256
 	}
@@ -256,6 +261,11 @@ public function testDispatchReturnValue() {
256 261
  * @return void
257 262
  */
258 263
 	public function testDispatchFalseStopsEvent() {
  264
+		$this->skipIf(
  265
+			version_compare(PHPUnit_Runner_Version::VERSION, '3.7', '<'),
  266
+			'These tests fail in PHPUnit 3.6'
  267
+		);
  268
+
259 269
 		$manager = new CakeEventManager;
260 270
 		$listener = $this->getMock('CakeEventTestListener');
261 271
 		$anotherListener = $this->getMock('CakeEventTestListener');
@@ -263,11 +273,11 @@ public function testDispatchFalseStopsEvent() {
263 273
 		$manager->attach(array($anotherListener, 'listenerFunction'), 'fake.event');
264 274
 		$event = new CakeEvent('fake.event');
265 275
 
266  
-		$originalEvent = clone $event;
267 276
 		$listener->expects($this->at(0))->method('listenerFunction')
268  
-			->with($originalEvent)
  277
+			->with($event)
269 278
 			->will($this->returnValue(false));
270  
-		$anotherListener->expects($this->never())->method('listenerFunction');
  279
+		$anotherListener->expects($this->never())
  280
+			->method('listenerFunction');
271 281
 		$manager->dispatch($event);
272 282
 		$this->assertTrue($event->isStopped());
273 283
 	}

0 notes on commit f89fe0e

Please sign in to comment.
Something went wrong with that request. Please try again.