| @@ 13-45 (lines=33) @@ | ||
| 10 | ||
| 11 | class AttributesTest extends BaseServiceTest |
|
| 12 | { |
|
| 13 | public function testListAll() |
|
| 14 | { |
|
| 15 | // Mock 'OptimizelyApiClient' object to avoid real API calls |
|
| 16 | $optimizelyApiClientMock = $this->getMockBuilder('\WebMarketingROI\OptimizelyPHP\OptimizelyApiClient') |
|
| 17 | ->disableOriginalConstructor() |
|
| 18 | ->getMock(); |
|
| 19 | ||
| 20 | $result = new Result(array( |
|
| 21 | array( |
|
| 22 | "key" => "subscriber_status", |
|
| 23 | "project_id" => 0, |
|
| 24 | "archived" => false, |
|
| 25 | "description" => "string", |
|
| 26 | "name" => "Subscriber Status", |
|
| 27 | "condition_type" => "custom_attribute", |
|
| 28 | "id" => 0, |
|
| 29 | "last_modified" => "2017-05-08T03:34:01.035Z" |
|
| 30 | ) |
|
| 31 | ), 200); |
|
| 32 | ||
| 33 | ||
| 34 | $optimizelyApiClientMock->method('sendApiRequest') |
|
| 35 | ->willReturn($result); |
|
| 36 | ||
| 37 | $attributesService = new Attributes($optimizelyApiClientMock); |
|
| 38 | ||
| 39 | $result = $attributesService->listAll(0); |
|
| 40 | $attributes = $result->getPayload(); |
|
| 41 | ||
| 42 | $this->assertTrue(count($attributes)==1); |
|
| 43 | $this->assertTrue($attributes[0] instanceOf Attribute); |
|
| 44 | $this->assertTrue($attributes[0]->getName()=='Subscriber Status'); |
|
| 45 | } |
|
| 46 | ||
| 47 | /** |
|
| 48 | * @expectedException Exception |
|
| @@ 13-46 (lines=34) @@ | ||
| 10 | ||
| 11 | class AudiencesTest extends BaseServiceTest |
|
| 12 | { |
|
| 13 | public function testListAll() |
|
| 14 | { |
|
| 15 | // Mock 'OptimizelyApiClient' object to avoid real API calls |
|
| 16 | $optimizelyApiClientMock = $this->getMockBuilder('\WebMarketingROI\OptimizelyPHP\OptimizelyApiClient') |
|
| 17 | ->disableOriginalConstructor() |
|
| 18 | ->getMock(); |
|
| 19 | ||
| 20 | $result = new Result(array( |
|
| 21 | array( |
|
| 22 | "project_id" => 1000, |
|
| 23 | "archived" => false, |
|
| 24 | "conditions" => "\"[\"and\", {\"type\": \"language\", \"value\": \"es\"}, {\"type\": \"location\", \"value\": \"US-CA-SANFRANCISCO\"}]\"", |
|
| 25 | "description" => "People that speak spanish and are in San Francisco", |
|
| 26 | "name" => "Spanish speaking San Franciscans", |
|
| 27 | "segmentation" => true, |
|
| 28 | "created" => "2016-10-18T05:07:04.066Z", |
|
| 29 | "id" => 5000, |
|
| 30 | "last_modified" => "2016-10-18T05:07:04.066Z" |
|
| 31 | ) |
|
| 32 | ), 200); |
|
| 33 | ||
| 34 | ||
| 35 | $optimizelyApiClientMock->method('sendApiRequest') |
|
| 36 | ->willReturn($result); |
|
| 37 | ||
| 38 | $audiencesService = new Audiences($optimizelyApiClientMock); |
|
| 39 | ||
| 40 | $result = $audiencesService->listAll(1000); |
|
| 41 | $audiences = $result->getPayload(); |
|
| 42 | ||
| 43 | $this->assertTrue(count($audiences)==1); |
|
| 44 | $this->assertTrue($audiences[0] instanceOf Audience); |
|
| 45 | $this->assertTrue($audiences[0]->getName()=='Spanish speaking San Franciscans'); |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * @expectedException Exception |
|