public function testFormatterCanListenToEvents() { $handler = Phake::mock('Fabricius\\Formatter\\Handler\\FormatHandlerInterface'); Phake::when($handler)->getExtensions()->thenReturn(array('markdown')); $this->formatter->addFormatHandler($handler); $dispatcher = new EventDispatcher(); $dispatcher->addListener(Events::CONTENT_PARSED, array($this->formatter, 'onContentItemParsed')); $contentItem = new ContentItem(); $contentItem->setFormat('markdown'); $event = Phake::mock('Fabricius\\Event\\ContentParsedEvent'); Phake::when($event)->getContentItem()->thenReturn($contentItem); $dispatcher->dispatch(Events::CONTENT_PARSED, $event); Phake::verify($event, Phake::times(1))->getContentItem(); }
public function testValidatorCanListenToEvents() { $dispatcher = new EventDispatcher(); $dispatcher->addListener(Events::CONTENT_PARSED, array($this->validator, 'onContentItemParsed')); $contentItem = new ContentItem(); $contentItem->setBody('body'); $contentItem->setCreated(new \DateTime()); $contentItem->setFormat('format'); $contentItem->setSlug('slug'); $contentItem->setTitle('title'); $event = Phake::mock('Fabricius\\Event\\ContentParsedEvent'); Phake::when($event)->getContentItem()->thenReturn($contentItem); $dispatcher->dispatch(Events::CONTENT_PARSED, $event); Phake::verify($event, Phake::times(1))->getContentItem(); }