@@ 95-144 (lines=50) @@ | ||
92 | $this->assertTrue($event->getName()=='Add to Cart'); |
|
93 | } |
|
94 | ||
95 | public function testCreateClickEvent() |
|
96 | { |
|
97 | // Mock 'OptimizelyApiClient' object to avoid real API calls |
|
98 | $optimizelyApiClientMock = $this->getMockBuilder('\WebMarketingROI\OptimizelyPHP\OptimizelyApiClient') |
|
99 | ->disableOriginalConstructor() |
|
100 | ->getMock(); |
|
101 | ||
102 | $result = new Result(array( |
|
103 | "event_filter" => array( |
|
104 | "filter_type" => "target_selector", |
|
105 | "selector" => ".menu-options" |
|
106 | ), |
|
107 | "name" => "Add to Cart", |
|
108 | "archived" => true, |
|
109 | "category" => "add_to_cart", |
|
110 | "description" => "string", |
|
111 | "event_type" => "click", |
|
112 | "key" => "add_to_cart", |
|
113 | "created" => "2016-10-18T05:07:04.153Z", |
|
114 | "id" => 0, |
|
115 | "is_classic" => false, |
|
116 | "is_editable" => true, |
|
117 | "page_id" => 0, |
|
118 | "project_id" => 1000 |
|
119 | ), 201); |
|
120 | ||
121 | $optimizelyApiClientMock->method('sendApiRequest') |
|
122 | ->willReturn($result); |
|
123 | ||
124 | $eventsService = new Events($optimizelyApiClientMock); |
|
125 | ||
126 | $event = new ClickEvent(array( |
|
127 | "event_filter" => array( |
|
128 | "filter_type" => "target_selector", |
|
129 | "selector" => ".menu-options" |
|
130 | ), |
|
131 | "name" => "Add to Cart", |
|
132 | "archived" => true, |
|
133 | "category" => "add_to_cart", |
|
134 | "description" => "string", |
|
135 | "event_type" => "click", |
|
136 | "key" => "add_to_cart" |
|
137 | )); |
|
138 | ||
139 | $result = $eventsService->createClickEvent(0, $event); |
|
140 | $createdEvent = $result->getPayload(); |
|
141 | ||
142 | $this->assertTrue($createdEvent instanceOf ClickEvent); |
|
143 | $this->assertTrue($createdEvent->getName()=='Add to Cart'); |
|
144 | } |
|
145 | ||
146 | public function testCreateCustomEvent() |
|
147 | { |
|
@@ 189-238 (lines=50) @@ | ||
186 | $this->assertTrue($createdEvent->getName()=='Loaded New App'); |
|
187 | } |
|
188 | ||
189 | public function testUpdateClickEvent() |
|
190 | { |
|
191 | // Mock 'OptimizelyApiClient' object to avoid real API calls |
|
192 | $optimizelyApiClientMock = $this->getMockBuilder('\WebMarketingROI\OptimizelyPHP\OptimizelyApiClient') |
|
193 | ->disableOriginalConstructor() |
|
194 | ->getMock(); |
|
195 | ||
196 | $result = new Result(array( |
|
197 | "event_filter" => array( |
|
198 | "filter_type" => "target_selector", |
|
199 | "selector" => ".menu-options" |
|
200 | ), |
|
201 | "name" => "Add to Cart", |
|
202 | "archived" => true, |
|
203 | "category" => "add_to_cart", |
|
204 | "description" => "string", |
|
205 | "event_type" => "click", |
|
206 | "key" => "add_to_cart", |
|
207 | "created" => "2016-10-18T05:07:04.153Z", |
|
208 | "id" => 0, |
|
209 | "is_classic" => false, |
|
210 | "is_editable" => true, |
|
211 | "page_id" => 0, |
|
212 | "project_id" => 1000 |
|
213 | ), 200); |
|
214 | ||
215 | $optimizelyApiClientMock->method('sendApiRequest') |
|
216 | ->willReturn($result); |
|
217 | ||
218 | $eventsService = new Events($optimizelyApiClientMock); |
|
219 | ||
220 | $event = new ClickEvent(array( |
|
221 | "event_filter" => array( |
|
222 | "filter_type" => "target_selector", |
|
223 | "selector" => ".menu-options" |
|
224 | ), |
|
225 | "name" => "Add to Cart", |
|
226 | "archived" => true, |
|
227 | "category" => "add_to_cart", |
|
228 | "description" => "string", |
|
229 | "event_type" => "click", |
|
230 | "key" => "add_to_cart" |
|
231 | )); |
|
232 | ||
233 | $result = $eventsService->updateClickEvent(0, 0, $event); |
|
234 | $updatedEvent = $result->getPayload(); |
|
235 | ||
236 | $this->assertTrue($updatedEvent instanceOf ClickEvent); |
|
237 | $this->assertTrue($updatedEvent->getName()=='Add to Cart'); |
|
238 | } |
|
239 | ||
240 | public function testUpdateCustomEvent() |
|
241 | { |