Author: Oliver Tischlinger
Inheritance: implements SplSubject
Esempio n. 1
0
 public function testWillThrowAnExcpetionIfObserverIsNotAnEvent()
 {
     $command = $this->createTestInstance(array('__invoke'));
     $subject = new Subject();
     $subject->attach($command);
     $this->setExpectedException('\\Exception');
     $subject->notify();
 }
 /**
  *
  */
 public function testCollectAllUpdatedSubjects()
 {
     $subject = new Subject();
     $observer = new SubjectHasUpdated();
     $subject->attach($observer);
     $this->assertNotContains($subject, $observer);
     $subject->notify();
     $this->assertContains($subject, $observer);
 }
Esempio n. 3
0
 /**
  * @param object           $subject
  * @param ProcessInterface $process
  * @param string           $stateName
  */
 public function __construct($subject, ProcessInterface $process, $stateName = null, TransitionSelectorInterface $transitonSelector = null)
 {
     parent::__construct();
     $this->subject = $subject;
     if ($stateName) {
         $this->currentState = $process->getState($stateName);
     } else {
         $this->currentState = $process->getInitialState();
     }
     if ($transitonSelector) {
         $this->transitonSelector = $transitonSelector;
     } else {
         $this->transitonSelector = new OneOrNoneActiveTransition();
     }
 }
Esempio n. 4
0
 /**
  * @param string $name
  */
 public function __construct($name)
 {
     parent::__construct();
     $this->name = $name;
     $this->metadata = new Nullable();
 }