Esempio n. 1
0
 /**
  * Test notify method
  */
 public function testNotify()
 {
     // Generate observer
     $observer = $this->getMockBuilder('DesignPatterns\\Behavioral\\Observer\\Observer\\iObserver')->setMethods(array('eventsListener'))->getMock();
     // Expects that observer gets only one event with a certain data
     $observer->expects($this->once())->method('eventsListener')->with($this->equalTo(Procedure::EVENT_PUBLICATION), ['name' => self::PROCEDURE_TEST_NAME]);
     $procedure = new Procedure();
     $procedure->attach($observer, [Procedure::EVENT_PUBLICATION]);
     $procedure->saveDraft(self::PROCEDURE_TEST_NAME)->publish()->registrationOver()->publishProtocol()->archive();
 }
Esempio n. 2
0
 /**
  * Event listener
  * @param string $event
  * @param array $data
  */
 public function eventsListener($event, $data)
 {
     $eventText = Proc::getEventText($event);
     var_dump("Procedure logger: {$data['name']} -> {$eventText}");
 }