Example #1
0
 public function run(Event $event)
 {
     $onError = function ($errno, $errstr, $errfile, $errline) use($event) {
         $message = sprintf("Error (%d) %s executing task %s", $errno, $errstr, $this->getName());
         if ($errno == E_WARNING || $errno == E_NOTICE || $errno == E_CORE_WARNING || $errno == E_COMPILE_WARNING || $errno == E_USER_WARNING || $errno == E_USER_NOTICE) {
             $this->warning($message);
         } else {
             $this->error($message);
             $event->stopPropagation(true);
         }
     };
     set_error_handler($onError);
     $return = eval($this->code);
     if (false === $return && null !== ($error = error_get_last())) {
         $onError($error['type'], $error['message'], $error['file'], $error['line']);
     }
     restore_error_handler();
 }
Example #2
0
 /**
  * @covers Phossa\Event\Event::isPropagationStopped
  */
 public function testIsPropagationStopped()
 {
     $this->assertTrue(false === $this->object->isPropagationStopped());
     $this->object->stopPropagation();
     $this->assertTrue(true === $this->object->isPropagationStopped());
 }
Example #3
0
 public function testShouldBeAbleToStoppedPropagation()
 {
     $event = new Event('whatever');
     $event->stopPropagation();
     $this->assertTrue($event->isPropagationStopped());
 }
Example #4
0
 /**
  */
 public function testIsPropagationStopped()
 {
     $event = new Event();
     $event->stopPropagation();
     $this->assertEquals(true, $event->isPropagationStopped());
 }