function it_throws_exceptions_if_silent_mode_is_disabled(RuleInterface $rule, ConverterInterface $converter)
 {
     $document = new \DOMDocument();
     $converter->parseHtml(Argument::type('string'), Argument::cetera())->willReturn($document);
     $converter->toHtml($document)->willReturn('<html></html>');
     $this->setSilentMode(false);
     $rule->query($document)->shouldBeCalled()->willThrow('Exception');
     $this->addRule($rule);
     $this->loadHtml('<html></html>')->shouldReturn($this);
     $this->shouldThrow('Exception')->duringManipulate();
 }
 function it_manipulates(EventDispatcherInterface $eventDispatcher, RuleInterface $rule)
 {
     $document = new \DOMDocument();
     $element = $document->createElement('div');
     $rule->query(Argument::type('DOMDocument'))->willReturn(array($element));
     $rule->apply($element)->shouldBeCalled();
     $eventDispatcher->dispatch(Events::CREATE_MANIPULATOR, $this->eventArgument('CreateManipulator'))->shouldBeCalled()->will(function ($args) use($rule) {
         $args[1]->getFactory()->addRule($rule->getWrappedObject());
     });
     $eventDispatcher->dispatch(Events::LOAD_HTML, $this->eventArgument('LoadHtml'))->shouldBeCalled();
     $eventDispatcher->dispatch(Events::START_MANIPULATE, $this->eventArgument('DomManipulation'))->shouldBeCalled();
     $eventDispatcher->dispatch(Events::STOP_MANIPULATE, $this->eventArgument('DomManipulation'))->shouldBeCalled();
     $this->manipulate(static::BUFFER, static::TEMPLATE);
 }