public function testToFromArray() { $mockStatus = "status"; $mockStart = "start"; $mockEnd = "end"; $mockObjects = "objects"; $mockAdAccountId = "ad account"; $mockPageId = "page id"; $mockAccessToken = "mock access token"; $mockType = 'mock type'; $mockMediaUrl = 'mock media url'; $mockPrimary = [FacebookCreativeData::MEDIA_URL => $mockMediaUrl, FacebookCreativeData::VERSION => FacebookCreativeData::CURRENT_VERSION]; $mockFacebookCreative = $this->buildMock('PaperG\\FirehoundBlob\\Facebook\\FacebookCreative'); $mockArray = [FacebookCreative::TYPE => $mockType, FacebookCreative::VERSION => FacebookCreative::CURRENT_VERSION, FacebookCreative::PRIMARY => $mockPrimary, FacebookCreative::CHILD_ATTACHMENTS => []]; $this->addExpectation($mockFacebookCreative, $this->once(), 'toArray', null, $mockArray); $mockCreatives = [$mockFacebookCreative]; $this->sut->setStatus($mockStatus); $this->sut->setStartDate($mockStart); $this->sut->setEndDate($mockEnd); $this->sut->setObjectsToUpdate($mockObjects); $this->sut->setAdAccountId($mockAdAccountId); $this->sut->setPageId($mockPageId); $this->sut->setAccessToken($mockAccessToken); $this->sut->setCreatives($mockCreatives); $array = $this->sut->toArray(); $new = new UnmanagedFacebookBlob(); $new->fromArray($array); $creatives = $new->getCreatives(); $this->sut->setCreatives([]); $new->setCreatives([]); $this->assertEquals($this->sut, $new); $this->assertEquals($mockMediaUrl, $creatives[0]->getPrimary()->getMediaUrl()); $this->assertEquals($mockType, $creatives[0]->getType()); }
public function testValidateCreateReturnsFalse() { $adSet = new FacebookAdSet(); $blob = new UnmanagedFacebookBlob(); $blob->setStatus("blah"); $blob->setAdSets([$adSet]); $blob->setAdAccountId('ad account id'); $blob->setPageId(1234); $result = $this->sut->validateCreate($blob); $this->assertFalse($result->getResult()); $this->assertEquals('[accessToken] NULL value found, but a string is required. ' . '[status] Does not have a value in the enumeration ["active","inactive"]. ' . '[creatives] NULL value found, but an array is required. ' . '[] Failed to match all schemas.', $result->getMessage()); }
public function test_isValidUpdateBlob_UsingInvalidBlobForUpdate_ReturnsFalseAndErrorMessage() { $mockScenarioBlob = $this->getMockBuilder('PaperG\\FirehoundBlob\\ScenarioBlob')->disableOriginalConstructor()->getMock(); $mockAdSet = $this->getMockBuilder('PaperG\\FirehoundBlob\\Facebook\\FacebookAdSet')->disableOriginalConstructor()->getMock(); $mockCreative = $this->getMockBuilder('PaperG\\FirehoundBlob\\Facebook\\FacebookCreative')->disableOriginalConstructor()->getMock(); $mockBudget = new Budget("invalid", "impression", "lifetime"); $mockUnmanagedFbBlob = new UnmanagedFacebookBlob(); $mockUnmanagedFbBlob->setAdAccountId(1123); $mockUnmanagedFbBlob->setPageId([1, 2, 3]); $mockUnmanagedFbBlob->setAccessToken(["helloworld"]); $mockUnmanagedFbBlob->setStatus(''); $mockUnmanagedFbBlob->setCreatives([$mockCreative]); $mockUnmanagedFbBlob->setAdSets([$mockAdSet]); $mockUnmanagedFbBlob->setBudget($mockBudget); $mockScenarioBlob->expects($this->once())->method('getBlob')->will($this->returnValue($mockUnmanagedFbBlob)); $results = $this->sut->isValidUpdateBlob($mockScenarioBlob); $this->assertEquals('[adAccountId] Integer value found, but a string is required. ' . '[pageId] Array value found, but a string or a number is required. ' . '[accessToken] Array value found, but a string is required. ' . '[budget.amount] String value found, but a number is required. ' . '[budget.budget_type] Does not have a value in the enumeration ["daily"]. ' . '[budget.type] Does not have a value in the enumeration ["dollar"]. ' . '[budget] Failed to match all schemas. [budget] Object value found, but a null is required. ' . '[budget] Failed to match exactly one schema. [adSets[0]] NULL value found, but an object is required. ' . '[adSets] Array value found, but a null is required. [adSets] Failed to match exactly one schema. ' . '[creatives[0]] NULL value found, but an object is required. ' . '[creatives] Array value found, but a null is required. [creatives] Failed to match exactly one schema. ' . '[status] Does not have a value in the enumeration ["active","inactive"]. ' . '[status] String value found, but a null is required. [status] Failed to match exactly one schema. ' . '[] Failed to match all schemas.', $results->getMessage()); $this->assertEquals(false, $results->getResult()); }