From 4b5c5e0ef5855129566db327270d7690f0359cc0 Mon Sep 17 00:00:00 2001 From: Dmytro Sokil Date: Wed, 26 Jul 2017 01:22:47 +0300 Subject: [PATCH] test get ad sections --- tests/DocumentTest.php | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/DocumentTest.php b/tests/DocumentTest.php index 624040a..076c637 100644 --- a/tests/DocumentTest.php +++ b/tests/DocumentTest.php @@ -2,6 +2,8 @@ namespace Sokil\Vast; +use Sokil\Vast\Ad\InLine; + class DocumentTest extends AbstractTestCase { /** @@ -41,6 +43,49 @@ public function testCreateInLineAdSection() $this->assertVastXmlEquals($expectedXml, $document); } + /** + * Test for inline ad + */ + public function testGetAdSection() + { + $factory = new Factory(); + $document = $factory->create('2.0'); + $this->assertInstanceOf('\Sokil\Vast\Document', $document); + + // insert Ad section + $ad1 = $document + ->createInLineAdSection() + ->setId('ad1') + ->setAdSystem('Ad Server Name') + ->setAdTitle('Ad Title') + ->addImpression('http://ad.server.com/impression'); + + // create creative for ad section + $ad1 + ->createLinearCreative() + ->setDuration(128) + ->setVideoClicksClickThrough('http://entertainmentserver.com/landing') + ->addVideoClicksClickTracking('http://ad.server.com/videoclicks/clicktracking') + ->addVideoClicksCustomClick('http://ad.server.com/videoclicks/customclick') + ->addTrackingEvent('start', 'http://ad.server.com/trackingevent/start') + ->addTrackingEvent('pause', 'http://ad.server.com/trackingevent/stop') + ->createMediaFile() + ->setProgressiveDelivery() + ->setType('video/mp4') + ->setHeight(100) + ->setWidth(100) + ->setUrl('http://server.com/media.mp4'); + + $adSections = $document->getAdSections(); + $this->assertSame(1, count($adSections)); + + /** @var InLine $adSection */ + $adSection = $adSections[0]; + $this->assertInstanceOf('\\Sokil\\Vast\\Ad\\InLine', $adSection); + + $this->assertSame('ad1', $adSection->getId()); + } + /** * Test for wrapper ad */