function it_converts_a_youtube_object_tag(EventInterface $event, ElementInterface $element, Element $child, Element $containerElement, Element $ampYoutubeElement) { $event->stopPropagation()->shouldBeCalled(); $element->getChildren()->shouldBeCalled()->willReturn([$child]); $child->getAttribute('value')->shouldBeCalled()->willReturn('http://www.youtube.com/embed/XGSy3_Czz8k?autoplay=1'); $element->createWritableElement('div', ['class' => 'youtube-container'])->shouldBeCalled()->willReturn($containerElement); $containerElement->appendChild($ampYoutubeElement)->shouldBeCalled(); $element->replaceWith($containerElement)->shouldBeCalled(); $element->createWritableElement('amp-youtube', ['data-videoid' => 'XGSy3_Czz8k', 'layout' => 'responsive', 'width' => '560', 'height' => '315'])->shouldBeCalled()->willReturn($ampYoutubeElement); $this->handleObject($event, $element); }
public function it_can_append_an_element(Element $element) { $doc = new DOMDocument('1.0', 'utf-8'); $div = $doc->createElement('div'); $p = $doc->createElement('p', 'Hello World'); $element->getNode()->willReturn($p); $this->beConstructedWith($div); $this->appendChild($element)->shouldReturn(null); }
/** * Append an Element as a child of the current element * * @param Element $element The element to append as a child * @return null */ public function appendChild(Element $element) { $this->getNode()->appendChild($element->getNode()); }