|
@@ 107-146 (lines=40) @@
|
| 104 |
|
$this->assertTrue($attribute->getName()=='Subscriber Status'); |
| 105 |
|
} |
| 106 |
|
|
| 107 |
|
public function testCreate() |
| 108 |
|
{ |
| 109 |
|
// Mock 'OptimizelyApiClient' object to avoid real API calls |
| 110 |
|
$optimizelyApiClientMock = $this->getMockBuilder('\WebMarketingROI\OptimizelyPHP\OptimizelyApiClient') |
| 111 |
|
->disableOriginalConstructor() |
| 112 |
|
->getMock(); |
| 113 |
|
|
| 114 |
|
$result = new Result(array( |
| 115 |
|
"key" => "subscriber_status", |
| 116 |
|
"project_id" => 0, |
| 117 |
|
"archived" => false, |
| 118 |
|
"description" => "string", |
| 119 |
|
"name" => "Subscriber Status", |
| 120 |
|
"condition_type" => "custom_attribute", |
| 121 |
|
"id" => 0, |
| 122 |
|
"last_modified" => "2017-05-08T03:34:01.035Z" |
| 123 |
|
), 201); |
| 124 |
|
|
| 125 |
|
$optimizelyApiClientMock->method('sendApiRequest') |
| 126 |
|
->willReturn($result); |
| 127 |
|
|
| 128 |
|
$attributesService = new Attributes($optimizelyApiClientMock); |
| 129 |
|
|
| 130 |
|
$attribute = new Attribute(array( |
| 131 |
|
"key" => "subscriber_status", |
| 132 |
|
"project_id" => 0, |
| 133 |
|
"archived" => false, |
| 134 |
|
"description" => "string", |
| 135 |
|
"name" => "Subscriber Status", |
| 136 |
|
"condition_type" => "custom_attribute", |
| 137 |
|
"id" => 0, |
| 138 |
|
"last_modified" => "2017-05-08T03:34:01.035Z" |
| 139 |
|
)); |
| 140 |
|
|
| 141 |
|
$result = $attributesService->create($attribute); |
| 142 |
|
$createdAttribute = $result->getPayload(); |
| 143 |
|
|
| 144 |
|
$this->assertTrue($createdAttribute instanceOf Attribute); |
| 145 |
|
$this->assertTrue($createdAttribute->getName()=='Subscriber Status'); |
| 146 |
|
} |
| 147 |
|
|
| 148 |
|
public function testUpdate() |
| 149 |
|
{ |
|
@@ 148-187 (lines=40) @@
|
| 145 |
|
$this->assertTrue($createdAttribute->getName()=='Subscriber Status'); |
| 146 |
|
} |
| 147 |
|
|
| 148 |
|
public function testUpdate() |
| 149 |
|
{ |
| 150 |
|
// Mock 'OptimizelyApiClient' object to avoid real API calls |
| 151 |
|
$optimizelyApiClientMock = $this->getMockBuilder('\WebMarketingROI\OptimizelyPHP\OptimizelyApiClient') |
| 152 |
|
->disableOriginalConstructor() |
| 153 |
|
->getMock(); |
| 154 |
|
|
| 155 |
|
$result = new Result(array( |
| 156 |
|
"key" => "subscriber_status", |
| 157 |
|
"project_id" => 0, |
| 158 |
|
"archived" => false, |
| 159 |
|
"description" => "string", |
| 160 |
|
"name" => "Subscriber Status", |
| 161 |
|
"condition_type" => "custom_attribute", |
| 162 |
|
"id" => 0, |
| 163 |
|
"last_modified" => "2017-05-08T03:34:01.035Z" |
| 164 |
|
), 200); |
| 165 |
|
|
| 166 |
|
$optimizelyApiClientMock->method('sendApiRequest') |
| 167 |
|
->willReturn($result); |
| 168 |
|
|
| 169 |
|
$attributesService = new Attributes($optimizelyApiClientMock); |
| 170 |
|
|
| 171 |
|
$attribute = new Attribute(array( |
| 172 |
|
"key" => "subscriber_status", |
| 173 |
|
"project_id" => 0, |
| 174 |
|
"archived" => false, |
| 175 |
|
"description" => "string", |
| 176 |
|
"name" => "Subscriber Status", |
| 177 |
|
"condition_type" => "custom_attribute", |
| 178 |
|
"id" => 0, |
| 179 |
|
"last_modified" => "2017-05-08T03:34:01.035Z" |
| 180 |
|
)); |
| 181 |
|
|
| 182 |
|
$result = $attributesService->update(0, $attribute); |
| 183 |
|
$createdAttribute = $result->getPayload(); |
| 184 |
|
|
| 185 |
|
$this->assertTrue($createdAttribute instanceOf Attribute); |
| 186 |
|
$this->assertTrue($createdAttribute->getName()=='Subscriber Status'); |
| 187 |
|
} |
| 188 |
|
|
| 189 |
|
public function testIntegration() |
| 190 |
|
{ |