function it_manipulates_the_dom(RuleInterface $rule, ConverterInterface $converter)
 {
     $document = new \DOMDocument();
     $converter->parseHtml(Argument::type('string'), Argument::cetera())->willReturn($document);
     $converter->toHtml($document)->willReturn('<html></html>');
     $element = $document->createElement('div');
     $rule->query($document)->shouldBeCalled()->willReturn(array($element));
     $rule->apply($element)->shouldBeCalled();
     $this->addRule($rule);
     $this->loadHtml('<html></html>')->shouldReturn($this);
     $this->manipulate()->shouldBeString();
 }
 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);
 }