public function case_set_source() { $this->given($bucket = new SUT(), $sourceA = new \Mock\Hoa\Event\Source())->when($result = $bucket->setSource($sourceA))->then->variable($result)->isNull()->object($bucket->getSource())->isIdenticalTo($sourceA)->given($sourceB = new \Mock\Hoa\Event\Source())->when($result = $bucket->setSource($sourceB))->then->object($result)->isIdenticalTo($sourceA)->object($bucket->getSource())->isIdenticalTo($sourceB); }
/** * Notify, i.e. send data to observers. * * @param string $eventId Event ID. * @param \Hoa\Event\Source $source Source. * @param \Hoa\Event\Bucket $data Data. * @return void * @throws \Hoa\Event\Exception */ public static function notify($eventId, Source $source, Bucket $data) { if (false === self::eventExists($eventId)) { throw new Exception('Event ID %s does not exist, cannot send notification.', 3, $eventId); } $data->setSource($source); $event = self::getEvent($eventId); foreach ($event->_callable as $callable) { $callable($data); } return; }