Code Duplication    Length = 42-42 lines in 2 locations

tests/OptimizelyPHPTest/Service/v2/EventsTest.php 2 locations

@@ 146-187 (lines=42) @@
143
        $this->assertTrue($createdEvent->getName()=='Add to Cart');                
144
    }
145
    
146
    public function testCreateCustomEvent()
147
    {
148
        // Mock 'OptimizelyApiClient' object to avoid real API calls
149
        $optimizelyApiClientMock = $this->getMockBuilder('\WebMarketingROI\OptimizelyPHP\OptimizelyApiClient')
150
                            ->disableOriginalConstructor()
151
                            ->getMock();
152
153
        $result = new Result(array(
154
                            "archived" => true,
155
                            "category" => "add_to_cart",
156
                            "description" => "string",
157
                            "event_type" => "custom",
158
                            "key" => "loaded_new_app",
159
                            "name" => "Loaded New App",
160
                            "created" => "2016-10-18T05:07:04.163Z",
161
                            "id" => 0,
162
                            "is_classic" => false,
163
                            "is_editable" => true,
164
                            "page_id" => 0,
165
                            "project_id" => 1000  
166
                        ), 201);
167
        
168
        $optimizelyApiClientMock->method('sendApiRequest')
169
                    ->willReturn($result);
170
        
171
        $eventsService = new Events($optimizelyApiClientMock);
172
        
173
        $event = new CustomEvent(array(
174
                "archived" => true,
175
                "category" => "add_to_cart",
176
                "description" => "string",
177
                "event_type" => "custom",
178
                "key" => "loaded_new_app",
179
                "name" => "Loaded New App"
180
        ));
181
        
182
        $result = $eventsService->createCustomEvent(0, $event);
183
        $createdEvent = $result->getPayload();
184
        
185
        $this->assertTrue($createdEvent instanceOf CustomEvent);
186
        $this->assertTrue($createdEvent->getName()=='Loaded New App');                
187
    }
188
    
189
    public function testUpdateClickEvent()
190
    {
@@ 240-281 (lines=42) @@
237
        $this->assertTrue($updatedEvent->getName()=='Add to Cart');                
238
    }
239
    
240
    public function testUpdateCustomEvent()
241
    {
242
        // Mock 'OptimizelyApiClient' object to avoid real API calls
243
        $optimizelyApiClientMock = $this->getMockBuilder('\WebMarketingROI\OptimizelyPHP\OptimizelyApiClient')
244
                            ->disableOriginalConstructor()
245
                            ->getMock();
246
247
        $result = new Result(array(
248
                            "archived" => true,
249
                            "category" => "add_to_cart",
250
                            "description" => "string",
251
                            "event_type" => "custom",
252
                            "key" => "loaded_new_app",
253
                            "name" => "Loaded New App",
254
                            "created" => "2016-10-18T05:07:04.163Z",
255
                            "id" => 0,
256
                            "is_classic" => false,
257
                            "is_editable" => true,
258
                            "page_id" => 0,
259
                            "project_id" => 1000  
260
                        ), 200);
261
        
262
        $optimizelyApiClientMock->method('sendApiRequest')
263
                    ->willReturn($result);
264
        
265
        $eventsService = new Events($optimizelyApiClientMock);
266
        
267
        $event = new CustomEvent(array(
268
                "archived" => true,
269
                "category" => "add_to_cart",
270
                "description" => "string",
271
                "event_type" => "custom",
272
                "key" => "loaded_new_app",
273
                "name" => "Loaded New App"
274
        ));
275
        
276
        $result = $eventsService->updateCustomEvent(0, 0, $event);
277
        $updatedEvent = $result->getPayload();
278
        
279
        $this->assertTrue($updatedEvent instanceOf CustomEvent);
280
        $this->assertTrue($updatedEvent->getName()=='Loaded New App');                
281
    }
282
    
283
    public function testIntegration()
284
    {