/** * @param ScenarioBlob $blob * @return ValidationResult */ public function isValidUpdateBlob($blob) { /** * @var $dcmBlob UnmanagedDcmBlob */ $dcmBlob = $blob->getBlob(); $dcmResult = $this->isValid($dcmBlob); $valid = $dcmResult->getResult(); $messages = []; $message = $dcmResult->getMessage(); if (!empty($message)) { $messages[] = $message; } $assets = $dcmBlob->getCreativeAssets(); if (!empty($assets)) { foreach ($assets as $asset) { $result = $this->assetValidator->isValidUpdate($asset); if (!$result->getResult()) { $valid = false; $messages[] = $result->getMessage(); } } } return new ValidationResult($valid, implode(" ", $messages)); }
public function testIsValidUpdateBlob() { $assetArray = ["uuid" => "blah", "imageUrl" => "image url"]; $mockCreativeAsset = $this->buildMock('PaperG\\FirehoundBlob\\Dcm\\DcmCreativeAsset'); $this->addExpectation($mockCreativeAsset, $this->atLeastOnce(), 'toArray', null, $assetArray); $mockAssets = [$mockCreativeAsset]; $mockValidationResult = $this->buildMock('PaperG\\FirehoundBlob\\ScenarioValidators\\ValidationResult'); $this->addExpectation($mockValidationResult, $this->once(), 'getResult', null, true); $this->addExpectation($this->mockValidator, $this->once(), 'isValidUpdate', null, $mockValidationResult); $dcmBlob = new UnmanagedDcmBlob(); $dcmBlob->setAdvertiserId(1234); $dcmBlob->setCreativeAssets($mockAssets); $dcmBlob->setPublicationId(1234); $dcmBlob->setStatusCallbackUrl("mock callback url"); $dcmBlob->setStatusCallbackHeaders(["header" => "value"]); $testBlob = new ScenarioBlob(); $testBlob->setBlob($dcmBlob); $result = $this->sut->isValidUpdateBlob($testBlob); $this->assertTrue($result->getResult()); $this->assertEmpty($result->getMessage()); }