Ejemplo n.º 1
0
 public function testShouldDispatchEventFromOtherSubscription()
 {
     $logger = new Logger();
     $this->app->subscribe('payment.failure', 'logger', function (Application $app) use($logger) {
         $logger->log('Payment failure');
         $app->dispatch('payment.attempt');
     });
     $counter = new Counter();
     $this->app->subscribe('payment.attempt', 'paymentCounter', function () use($counter) {
         $counter->increment();
     });
     $this->app->dispatch('payment.failure');
     $this->assertEquals(1, $counter->total());
 }
Ejemplo n.º 2
0
 public function testShouldNotifyListenersByPriorities()
 {
     $logger = new Logger();
     $this->app->subscribe('payment.failure', 'logger', function () use($logger) {
         $logger->log('Payment failure');
         return ['stop' => true];
     }, 10);
     $counter = new Counter();
     $this->app->subscribe('payment.failure', 'errorCounter', function () use($counter) {
         $counter->increment();
     }, 20);
     $this->app->dispatch('payment.failure');
     $this->assertEquals(1, $counter->total());
 }