From 70f91294cf1ff31052aec6de2c37ae61cd780943 Mon Sep 17 00:00:00 2001 From: Dmytro Sokil Date: Thu, 24 Mar 2016 09:24:23 +0200 Subject: [PATCH] change add to set --- src/Sokil/Vast/Ad/Wrapper.php | 11 ++++++++--- tests/Sokil/Vast/DocumentTest.php | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Sokil/Vast/Ad/Wrapper.php b/src/Sokil/Vast/Ad/Wrapper.php index 30bcaa7..74c5785 100644 --- a/src/Sokil/Vast/Ad/Wrapper.php +++ b/src/Sokil/Vast/Ad/Wrapper.php @@ -11,11 +11,16 @@ class Wrapper extends \Sokil\Vast\Ad * @param $uri * @return $this */ - public function addVASTAdTagURI($uri) + public function setVASTAdTagURI($uri) { + // get VASTAdTagURI dom node + $VASTAdTagURIDomElement = $this->domElement->getElementsByTagName('VASTAdTagURI')->item(0); + // create VASTAdTagURI-Node - $VASTAdTagURIDomElement = $this->domElement->ownerDocument->createElement('VASTAdTagURI'); - $this->domElement->firstChild->appendChild($VASTAdTagURIDomElement); + if(!$VASTAdTagURIDomElement) { + $VASTAdTagURIDomElement = $this->domElement->ownerDocument->createElement('VASTAdTagURI'); + $this->domElement->firstChild->appendChild($VASTAdTagURIDomElement); + } // create VASTAdTagURI-cdata $cdata = $this->domElement->ownerDocument->createCDATASection($uri); diff --git a/tests/Sokil/Vast/DocumentTest.php b/tests/Sokil/Vast/DocumentTest.php index 36ab2c4..2428613 100644 --- a/tests/Sokil/Vast/DocumentTest.php +++ b/tests/Sokil/Vast/DocumentTest.php @@ -47,7 +47,7 @@ public function testCreateWrapperAdSection() $ad1 = $document->createWrapperAdSection() ->setId('ad1') ->setAdSystem('Ad Server Name') - ->addVASTAdTagURI('http://entertainmentserver.com/vart.xml'); + ->setVASTAdTagURI('http://entertainmentserver.com/vart.xml'); $actualXml = str_replace(array("\r", "\n"), '', $document->toString());