Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
markstory committed Oct 16, 2012
1 parent 805b44f commit f89fe0e
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions lib/Cake/Test/Case/Event/CakeEventManagerTest.php
Expand Up @@ -234,18 +234,23 @@ public function testDispatchWithKeyName() {
* @return void
*/
public function testDispatchReturnValue() {
$this->skipIf(
version_compare(PHPUnit_Runner_Version::VERSION, '3.7', '<'),
'These tests fail in PHPUnit 3.6'
);
$manager = new CakeEventManager;
$listener = $this->getMock('CakeEventTestListener');
$anotherListener = $this->getMock('CakeEventTestListener');
$manager->attach(array($listener, 'listenerFunction'), 'fake.event');
$manager->attach(array($anotherListener, 'listenerFunction'), 'fake.event');
$event = new CakeEvent('fake.event');

$firstStep = clone $event;
$listener->expects($this->at(0))->method('listenerFunction')
->with($firstStep)
->with($event)
->will($this->returnValue('something special'));
$anotherListener->expects($this->at(0))->method('listenerFunction')->with($event);
$anotherListener->expects($this->at(0))
->method('listenerFunction')
->with($event);
$manager->dispatch($event);
$this->assertEquals('something special', $event->result);
}
Expand All @@ -256,18 +261,23 @@ public function testDispatchReturnValue() {
* @return void
*/
public function testDispatchFalseStopsEvent() {
$this->skipIf(
version_compare(PHPUnit_Runner_Version::VERSION, '3.7', '<'),
'These tests fail in PHPUnit 3.6'
);

$manager = new CakeEventManager;
$listener = $this->getMock('CakeEventTestListener');
$anotherListener = $this->getMock('CakeEventTestListener');
$manager->attach(array($listener, 'listenerFunction'), 'fake.event');
$manager->attach(array($anotherListener, 'listenerFunction'), 'fake.event');
$event = new CakeEvent('fake.event');

$originalEvent = clone $event;
$listener->expects($this->at(0))->method('listenerFunction')
->with($originalEvent)
->with($event)
->will($this->returnValue(false));
$anotherListener->expects($this->never())->method('listenerFunction');
$anotherListener->expects($this->never())
->method('listenerFunction');
$manager->dispatch($event);
$this->assertTrue($event->isStopped());
}
Expand Down

0 comments on commit f89fe0e

Please sign in to comment.