| 1 | <?php  | 
            ||
| 9 | class NotificationSubscriberTest extends TestCase  | 
            ||
| 10 | { | 
            ||
| 11 | /**  | 
            ||
| 12 | * The subscriber should subscribe to the notify event.  | 
            ||
| 13 | */  | 
            ||
| 14 | public function testGetSubscribedEvents()  | 
            ||
| 15 |     { | 
            ||
| 16 | $this  | 
            ||
| 17 | ->assertEquals([  | 
            ||
| 18 | NotificationEvent::NAME => 'notify'  | 
            ||
| 19 | ], NotificationSubscriber::getSubscribedEvents());  | 
            ||
| 20 | }  | 
            ||
| 21 | |||
| 22 | /**  | 
            ||
| 23 | * Notify method should add a notification into the subscriber. Clear method should reset the notification array.  | 
            ||
| 24 | */  | 
            ||
| 25 | public function testNotify()  | 
            ||
| 26 |     { | 
            ||
| 27 | $event = new NotificationEvent();  | 
            ||
| 28 |         $event->setMessage('What a test'); | 
            ||
| 29 | |||
| 30 | $subscriber = new NotificationSubscriber();  | 
            ||
| 31 | $subscriber->notify($event);  | 
            ||
| 32 | |||
| 33 | $this->assertCount(1, $subscriber->getNotifications());  | 
            ||
| 34 |         $this->assertEquals('What a test', $subscriber->getNotifications()[0]); | 
            ||
| 35 | |||
| 36 | $subscriber->clearNotifications();  | 
            ||
| 37 | $this->assertEquals([], $subscriber->getNotifications());  | 
            ||
| 38 | }  | 
            ||
| 39 | }  | 
            ||
| 40 |