|
@@ 86-132 (lines=47) @@
|
| 83 |
|
$this->assertEquals('Home Page', $page->getName()); |
| 84 |
|
} |
| 85 |
|
|
| 86 |
|
public function testCreate() |
| 87 |
|
{ |
| 88 |
|
// Mock 'OptimizelyApiClient' object to avoid real API calls |
| 89 |
|
$optimizelyApiClientMock = $this->getMockBuilder('\WebMarketingROI\OptimizelyPHP\OptimizelyApiClient') |
| 90 |
|
->disableOriginalConstructor() |
| 91 |
|
->getMock(); |
| 92 |
|
|
| 93 |
|
$result = new Result(array( |
| 94 |
|
"edit_url" => "https://www.optimizely.com", |
| 95 |
|
"name" => "Home Page", |
| 96 |
|
"project_id" => 1000, |
| 97 |
|
"activation_code" => "string", |
| 98 |
|
"activation_type" => "immediate", |
| 99 |
|
"archived" => false, |
| 100 |
|
"category" => "article", |
| 101 |
|
"conditions" => "string", |
| 102 |
|
"key" => "home_page", |
| 103 |
|
"page_type" => "single_url", |
| 104 |
|
"created" => "2016-10-18T05:07:04.113Z", |
| 105 |
|
"id" => 4000, |
| 106 |
|
"last_modified" => "2016-10-18T05:07:04.113Z" |
| 107 |
|
), 201); |
| 108 |
|
|
| 109 |
|
$optimizelyApiClientMock->method('sendApiRequest') |
| 110 |
|
->willReturn($result); |
| 111 |
|
|
| 112 |
|
$pagesService = new Pages($optimizelyApiClientMock); |
| 113 |
|
|
| 114 |
|
$page = new Page(array( |
| 115 |
|
"edit_url" => "https://www.optimizely.com", |
| 116 |
|
"name" => "Home Page", |
| 117 |
|
"project_id" => 1000, |
| 118 |
|
"activation_code" => "string", |
| 119 |
|
"activation_type" => "immediate", |
| 120 |
|
"archived" => false, |
| 121 |
|
"category" => "article", |
| 122 |
|
"conditions" => "string", |
| 123 |
|
"key" => "home_page", |
| 124 |
|
"page_type" => "single_url" |
| 125 |
|
)); |
| 126 |
|
|
| 127 |
|
$result = $pagesService->create($page); |
| 128 |
|
$createdPage = $result->getPayload(); |
| 129 |
|
|
| 130 |
|
$this->assertTrue($createdPage instanceOf Page); |
| 131 |
|
$this->assertTrue($createdPage->getName()=='Home Page'); |
| 132 |
|
} |
| 133 |
|
|
| 134 |
|
public function testUpdate() |
| 135 |
|
{ |
|
@@ 134-180 (lines=47) @@
|
| 131 |
|
$this->assertTrue($createdPage->getName()=='Home Page'); |
| 132 |
|
} |
| 133 |
|
|
| 134 |
|
public function testUpdate() |
| 135 |
|
{ |
| 136 |
|
// Mock 'OptimizelyApiClient' object to avoid real API calls |
| 137 |
|
$optimizelyApiClientMock = $this->getMockBuilder('\WebMarketingROI\OptimizelyPHP\OptimizelyApiClient') |
| 138 |
|
->disableOriginalConstructor() |
| 139 |
|
->getMock(); |
| 140 |
|
|
| 141 |
|
$result = new Result(array( |
| 142 |
|
"edit_url" => "https://www.optimizely.com", |
| 143 |
|
"name" => "Home Page", |
| 144 |
|
"project_id" => 1000, |
| 145 |
|
"activation_code" => "string", |
| 146 |
|
"activation_type" => "immediate", |
| 147 |
|
"archived" => false, |
| 148 |
|
"category" => "article", |
| 149 |
|
"conditions" => "string", |
| 150 |
|
"key" => "home_page", |
| 151 |
|
"page_type" => "single_url", |
| 152 |
|
"created" => "2016-10-18T05:07:04.113Z", |
| 153 |
|
"id" => 4000, |
| 154 |
|
"last_modified" => "2016-10-18T05:07:04.113Z" |
| 155 |
|
), 200); |
| 156 |
|
|
| 157 |
|
$optimizelyApiClientMock->method('sendApiRequest') |
| 158 |
|
->willReturn($result); |
| 159 |
|
|
| 160 |
|
$pagesService = new Pages($optimizelyApiClientMock); |
| 161 |
|
|
| 162 |
|
$page = new Page(array( |
| 163 |
|
"edit_url" => "https://www.optimizely.com", |
| 164 |
|
"name" => "Home Page", |
| 165 |
|
"project_id" => 1000, |
| 166 |
|
"activation_code" => "string", |
| 167 |
|
"activation_type" => "immediate", |
| 168 |
|
"archived" => false, |
| 169 |
|
"category" => "article", |
| 170 |
|
"conditions" => "string", |
| 171 |
|
"key" => "home_page", |
| 172 |
|
"page_type" => "single_url" |
| 173 |
|
)); |
| 174 |
|
|
| 175 |
|
$result = $pagesService->update(1000, $page); |
| 176 |
|
$updatedPage = $result->getPayload(); |
| 177 |
|
|
| 178 |
|
$this->assertTrue($updatedPage instanceOf Page); |
| 179 |
|
$this->assertTrue($updatedPage->getName()=='Home Page'); |
| 180 |
|
} |
| 181 |
|
|
| 182 |
|
public function testDelete() |
| 183 |
|
{ |