/** * @test */ public function testGenericListenerNotCalledWhenPropogationStopped() { $this->dispatcher->addListener('ul', function (TranscodeNodeEvent $event) use(&$count) { $event->stopPropagation(); }); $ulGenericListenerCalled = false; $this->dispatcher->addListener('*', function (TranscodeNodeEvent $event) use(&$ulGenericListenerCalled) { if ($event->getNode()->nodeName === 'ul') { $ulGenericListenerCalled = true; } }); $this->transcoder->setAdapter($this->getMockAdapter())->transcode(); $this->assertFalse($ulGenericListenerCalled); }
/** * @param TranscodeElementEvent $event */ protected function transcodeElementNode(TranscodeElementEvent $event) { $node = $event->getNode(); $this->dispatcher->dispatch($node->nodeName, $event); if ($event->isNodeRemoved()) { $node->parentNode->removeChild($node); } if (!$event->isPropagationStopped()) { $this->dispatcher->dispatch('*', $event); if ($event->isNodeRemoved()) { $node->parentNode->removeChild($node); } if (!$event->isPropagationStopped() && ($children = $node->childNodes)) { $this->transcodeList($children, $event); } } }
/** * @test * @covers addTransformer */ public function testAddTransformer_clonesTransformerWhenApplyingAutomaticConstraints() { $transformer = $this->getMockTransformer(); $transformer->shouldReceive('addConstraint')->with(m::type('\\Optimus\\Constraint\\HasAttributeConstraint')); $this->dispatcher->addTransformer(array('#container', 'div.container'), $transformer); $wildcardListeners = $this->dispatcher->getListeners('*'); $divListeners = $this->dispatcher->getListeners('div'); $this->assertCount(1, $wildcardListeners); $this->assertCount(1, $divListeners); }