mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
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.
This commit is contained in:
parent
805b44f17c
commit
f89fe0e1ef
1 changed files with 16 additions and 6 deletions
|
@ -234,6 +234,10 @@ class CakeEventManagerTest extends CakeTestCase {
|
|||
* @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');
|
||||
|
@ -241,11 +245,12 @@ class CakeEventManagerTest extends CakeTestCase {
|
|||
$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);
|
||||
}
|
||||
|
@ -256,6 +261,11 @@ class CakeEventManagerTest extends CakeTestCase {
|
|||
* @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');
|
||||
|
@ -263,11 +273,11 @@ class CakeEventManagerTest extends CakeTestCase {
|
|||
$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());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue