Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 7da4a9d

Browse files
committed
added phpunit 6
updated some tests with ::class changed composer.json with phpunit to min 5.7.14 or 6.0.7
1 parent 0f63906 commit 7da4a9d

15 files changed

+79
-44
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"php": "^5.6 || ^7.0"
3333
},
3434
"require-dev": {
35-
"phpunit/PHPUnit": "^5.6",
35+
"phpunit/PHPUnit": "^5.7.14 || ^6.0.7",
3636
"athletic/athletic": "^0.1",
3737
"zendframework/zend-stdlib": "^2.7.3 || ^3.0",
3838
"container-interop/container-interop": "^1.1.0",

src/Test/EventListenerIntrospectionTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace Zend\EventManager\Test;
1111

12-
use PHPUnit_Framework_Assert as Assert;
12+
use PHPUnit\Framework\Assert as Assert;
1313
use ReflectionProperty;
1414
use Zend\EventManager\EventManager;
1515

test/EventManagerAwareTraitTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@
99

1010
namespace ZendTest\EventManager;
1111

12-
use PHPUnit_Framework_TestCase as TestCase;
12+
use PHPUnit\Framework\TestCase;
1313
use Zend\EventManager\EventManager;
14+
use Zend\EventManager\EventManagerAwareTrait;
15+
use Zend\EventManager\EventManagerInterface;
1416
use ZendTest\EventManager\TestAsset\MockEventManagerAwareTrait;
1517

1618
class EventManagerAwareTraitTest extends TestCase
1719
{
1820
public function testSetEventManager()
1921
{
20-
$object = $this->getObjectForTrait('\Zend\EventManager\EventManagerAwareTrait');
22+
$object = $this->getObjectForTrait(EventManagerAwareTrait::class);
2123

2224
$this->assertAttributeEquals(null, 'events', $object);
2325

@@ -30,9 +32,9 @@ public function testSetEventManager()
3032

3133
public function testGetEventManager()
3234
{
33-
$object = $this->getObjectForTrait('\Zend\EventManager\EventManagerAwareTrait');
35+
$object = $this->getObjectForTrait(EventManagerAwareTrait::class);
3436

35-
$this->assertInstanceOf('\Zend\EventManager\EventManagerInterface', $object->getEventManager());
37+
$this->assertInstanceOf(EventManagerInterface::class, $object->getEventManager());
3638

3739
$eventManager = new EventManager;
3840

test/EventManagerPriorityTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace ZendTest\EventManager;
1111

1212
use SplQueue;
13-
use PHPUnit_Framework_TestCase as TestCase;
13+
use PHPUnit\Framework\TestCase;
1414
use Zend\EventManager\Event;
1515
use Zend\EventManager\EventManager;
1616
use Zend\EventManager\SharedEventManager;

test/EventManagerTest.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace ZendTest\EventManager;
1111

12+
use PHPUnit\Framework\TestCase;
1213
use Prophecy\Argument;
1314
use ReflectionProperty;
1415
use stdClass;
@@ -17,10 +18,11 @@
1718
use Zend\EventManager\EventManager;
1819
use Zend\EventManager\Exception;
1920
use Zend\EventManager\ListenerAggregateInterface;
21+
use Zend\EventManager\ResponseCollection;
2022
use Zend\EventManager\SharedEventManager;
2123
use Zend\EventManager\SharedEventManagerInterface;
2224

23-
class EventManagerTest extends \PHPUnit_Framework_TestCase
25+
class EventManagerTest extends TestCase
2426
{
2527
public function setUp()
2628
{
@@ -124,7 +126,7 @@ public function testTriggerShouldReturnAllListenerReturnValues()
124126
return str_rot13($string);
125127
});
126128
$responses = $this->events->trigger('string.transform', $this, ['string' => ' foo ']);
127-
$this->assertInstanceOf('Zend\EventManager\ResponseCollection', $responses);
129+
$this->assertInstanceOf(ResponseCollection::class, $responses);
128130
$this->assertEquals(2, $responses->count());
129131
$this->assertEquals('foo', $responses->first());
130132
$this->assertEquals(\str_rot13(' foo '), $responses->last());
@@ -148,7 +150,7 @@ public function testTriggerUntilShouldReturnAsSoonAsCallbackReturnsTrue()
148150
$this,
149151
['string' => 'foo', 'search' => 'f']
150152
);
151-
$this->assertInstanceOf('Zend\EventManager\ResponseCollection', $responses);
153+
$this->assertInstanceOf(ResponseCollection::class, $responses);
152154
$this->assertSame(0, $responses->last());
153155
}
154156

@@ -191,7 +193,7 @@ public function testTriggerUntilShouldMarkResponseCollectionStoppedWhenCondition
191193
$responses = $this->events->triggerUntil(function ($result) {
192194
return ($result === 'found');
193195
}, 'foo.bar', $this);
194-
$this->assertInstanceOf('Zend\EventManager\ResponseCollection', $responses);
196+
$this->assertInstanceOf(ResponseCollection::class, $responses);
195197
$this->assertTrue($responses->stopped());
196198
$result = $responses->last();
197199
$this->assertEquals('found', $result);
@@ -210,7 +212,7 @@ public function testTriggerUntilShouldMarkResponseCollectionStoppedWhenCondition
210212
$responses = $this->events->triggerUntil(function ($result) {
211213
return ($result === 'found');
212214
}, 'foo.bar', $this);
213-
$this->assertInstanceOf('Zend\EventManager\ResponseCollection', $responses);
215+
$this->assertInstanceOf(ResponseCollection::class, $responses);
214216
$this->assertTrue($responses->stopped());
215217
$this->assertEquals('found', $responses->last());
216218
}
@@ -227,7 +229,7 @@ public function testResponseCollectionIsNotStoppedWhenNoCallbackMatchedByTrigger
227229
$responses = $this->events->triggerUntil(function ($result) {
228230
return ($result === 'never found');
229231
}, 'foo.bar', $this);
230-
$this->assertInstanceOf('Zend\EventManager\ResponseCollection', $responses);
232+
$this->assertInstanceOf(ResponseCollection::class, $responses);
231233
$this->assertFalse($responses->stopped());
232234
$this->assertEquals('zero', $responses->last());
233235
}
@@ -242,7 +244,7 @@ public function testCallingEventsStopPropagationMethodHaltsEventEmission()
242244
// @codingStandardsIgnoreEnd
243245

244246
$responses = $this->events->trigger('foo.bar');
245-
$this->assertInstanceOf('Zend\EventManager\ResponseCollection', $responses);
247+
$this->assertInstanceOf(ResponseCollection::class, $responses);
246248
$this->assertTrue($responses->stopped());
247249
$this->assertEquals('nada', $responses->last());
248250
$this->assertTrue($responses->contains('bogus'));
@@ -479,7 +481,8 @@ public function testAttachRaisesExceptionForInvalidEventType($event)
479481
{
480482
$callback = function () {
481483
};
482-
$this->setExpectedException(Exception\InvalidArgumentException::class, 'string');
484+
$this->expectException(Exception\InvalidArgumentException::class);
485+
$this->expectExceptionMessage('string');
483486
$this->events->attach($event, $callback);
484487
}
485488

@@ -704,7 +707,8 @@ public function testPassingInvalidEventTypeToDetachRaisesException($event)
704707
$listener = function ($e) {
705708
};
706709

707-
$this->setExpectedException(Exception\InvalidArgumentException::class, 'string');
710+
$this->expectException(Exception\InvalidArgumentException::class);
711+
$this->expectExceptionMessage('string');
708712
$this->events->detach($listener, $event);
709713
}
710714

@@ -750,7 +754,8 @@ public function eventsMissingNames()
750754
*/
751755
public function testTriggeringAnEventWithAnEmptyNameRaisesAnException($event, $method, $callback)
752756
{
753-
$this->setExpectedException(Exception\RuntimeException::class, 'missing a name');
757+
$this->expectException(Exception\RuntimeException::class);
758+
$this->expectExceptionMessage('missing a name');
754759
if ($callback) {
755760
$this->events->$method($callback, $event);
756761
} else {

test/EventTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99

1010
namespace ZendTest\EventManager;
1111

12+
use PHPUnit\Framework\TestCase;
1213
use Zend\EventManager\Event;
14+
use Zend\EventManager\Exception;
1315

1416
/**
1517
* @group Zend_Stdlib
1618
*/
17-
class EventTest extends \PHPUnit_Framework_TestCase
19+
class EventTest extends TestCase
1820
{
1921

2022
public function testConstructorWithArguments()
@@ -33,7 +35,7 @@ public function testConstructorWithArguments()
3335
public function testSetParamsWithInvalidParameter()
3436
{
3537
$event = new Event('foo');
36-
$this->setExpectedException('Zend\EventManager\Exception\InvalidArgumentException');
38+
$this->expectException(Exception\InvalidArgumentException::class);
3739
$event->setParams('test');
3840
}
3941

test/FilterChainTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99

1010
namespace ZendTest\EventManager;
1111

12+
use PHPUnit\Framework\TestCase;
13+
use Zend\EventManager\Filter\FilterIterator;
1214
use Zend\EventManager\FilterChain;
1315

1416
/**
1517
* @group Zend_Stdlib
1618
*/
17-
class FilterChainTest extends \PHPUnit_Framework_TestCase
19+
class FilterChainTest extends TestCase
1820
{
1921
/**
2022
* @var FilterChain
@@ -136,7 +138,7 @@ public function filterTestCallback1($context, array $params)
136138

137139
public function filterReceivalCallback($context, array $params, $chain)
138140
{
139-
$this->assertInstanceOf('Zend\EventManager\Filter\FilterIterator', $chain);
141+
$this->assertInstanceOf(FilterIterator::class, $chain);
140142
}
141143

142144
public function testRunReturnsNullWhenChainIsEmpty()

test/FilterIteratorTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99

1010
namespace ZendTest\EventManager;
1111

12+
use PHPUnit\Framework\TestCase;
1213
use Zend\EventManager\Exception\InvalidArgumentException;
1314
use Zend\EventManager\Filter\FilterIterator;
1415

1516
/**
1617
* @group Zend_Stdlib
1718
*/
18-
class FilterIteratorTest extends \PHPUnit_Framework_TestCase
19+
class FilterIteratorTest extends TestCase
1920
{
2021

2122
public function testNextReturnsNullOnEmptyChain()
@@ -103,7 +104,8 @@ public function invalidFilters()
103104
public function testInsertShouldRaiseExceptionOnNonCallableDatum($filter)
104105
{
105106
$iterator = new FilterIterator();
106-
$this->setExpectedException(InvalidArgumentException::class, 'callables');
107+
$this->expectException(InvalidArgumentException::class);
108+
$this->expectExceptionMessage('callables');
107109
$iterator->insert($filter, 1);
108110
}
109111
}

test/LazyEventListenerTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public function testConstructorRaisesExceptionForMissingEvent()
2929
'listener' => 'listener',
3030
'method' => 'method',
3131
];
32-
$this->setExpectedException(InvalidArgumentException::class, 'missing a valid "event"');
32+
$this->expectException(InvalidArgumentException::class);
33+
$this->expectExceptionMessage('missing a valid "event"');
3334
new $class($struct, $this->container->reveal());
3435
}
3536

@@ -44,7 +45,8 @@ public function testConstructorRaisesExceptionForInvalidEventType($event)
4445
'listener' => 'listener',
4546
'method' => 'method',
4647
];
47-
$this->setExpectedException(InvalidArgumentException::class, 'missing a valid "event"');
48+
$this->expectException(InvalidArgumentException::class);
49+
$this->expectExceptionMessage('missing a valid "event"');
4850
new $class($struct, $this->container->reveal());
4951
}
5052

test/LazyListenerAggregateTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace ZendTest\EventManager;
1111

1212
use Interop\Container\ContainerInterface;
13-
use PHPUnit_Framework_TestCase as TestCase;
13+
use PHPUnit\Framework\TestCase;
1414
use Prophecy\Argument;
1515
use ReflectionProperty;
1616
use Zend\EventManager\EventInterface;
@@ -70,7 +70,8 @@ public function invalidListeners()
7070
*/
7171
public function testPassingInvalidListenerTypesAtInstantiationRaisesException($listener)
7272
{
73-
$this->setExpectedException(InvalidArgumentException::class, 'must be LazyEventListener instances');
73+
$this->expectException(InvalidArgumentException::class);
74+
$this->expectExceptionMessage('must be LazyEventListener instances');
7475
new LazyListenerAggregate([$listener], $this->container->reveal());
7576
}
7677

@@ -79,7 +80,8 @@ public function testPassingInvalidListenerTypesAtInstantiationRaisesException($l
7980
*/
8081
public function testPassingInvalidListenersAtInstantiationRaisesException($listener)
8182
{
82-
$this->setExpectedException(InvalidArgumentException::class, 'missing a valid');
83+
$this->expectException(InvalidArgumentException::class);
84+
$this->expectExceptionMessage('missing a valid');
8385
new LazyListenerAggregate([$listener], $this->container->reveal());
8486
}
8587

0 commit comments

Comments
 (0)