99
1010namespace ZendTest \EventManager ;
1111
12+ use PHPUnit \Framework \TestCase ;
1213use Prophecy \Argument ;
1314use ReflectionProperty ;
1415use stdClass ;
1718use Zend \EventManager \EventManager ;
1819use Zend \EventManager \Exception ;
1920use Zend \EventManager \ListenerAggregateInterface ;
21+ use Zend \EventManager \ResponseCollection ;
2022use Zend \EventManager \SharedEventManager ;
2123use 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 {
0 commit comments