Code Duplication    Length = 59-59 lines in 2 locations

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

@@ 119-177 (lines=59) @@
116
        $this->assertTrue($audience->getName()=='Spanish speaking San Franciscans');        
117
    }
118
    
119
    public function testCreate()
120
    {
121
        // Mock 'OptimizelyApiClient' object to avoid real API calls
122
        $optimizelyApiClientMock = $this->getMockBuilder('\WebMarketingROI\OptimizelyPHP\OptimizelyApiClient')
123
                            ->disableOriginalConstructor()
124
                            ->getMock();
125
126
        $result = new Result(array(
127
                            "project_id" => 1000,
128
                            "archived" => false,
129
                            "conditions" => array(
130
                              "and",
131
                              array(
132
                                "type" => "language",
133
                                "value" => "es"
134
                              ),
135
                              array(
136
                                "type" => "location",
137
                                "value" => "US-CA-SANFRANCISCO"
138
                              )
139
                            ),
140
                            "description" => "People that speak spanish and are in San Francisco",
141
                            "name" => "Spanish speaking San Franciscans",
142
                            "segmentation" => true,
143
                            "created" => "2016-10-18T05:07:04.083Z",
144
                            "id" => 5000,
145
                            "last_modified" => "2016-10-18T05:07:04.083Z"
146
                        ), 201);
147
        
148
        $optimizelyApiClientMock->method('sendApiRequest')
149
                    ->willReturn($result);
150
        
151
        $audiencesService = new Audiences($optimizelyApiClientMock);
152
        
153
        $audience = new Audience(array(
154
                "project_id" => 1000,
155
                "archived" => false,
156
                "conditions" => array(
157
                  "and",
158
                  array(
159
                    "type" => "language",
160
                    "value" => "es"
161
                  ),
162
                  array(
163
                    "type" => "location",
164
                    "value" => "US-CA-SANFRANCISCO"
165
                  )
166
                ),
167
                "description" => "People that speak spanish and are in San Francisco",
168
                "name" => "Spanish speaking San Franciscans",
169
                "segmentation" => true
170
        ));
171
        
172
        $result = $audiencesService->create($audience);
173
        $createdAudience = $result->getPayload();
174
        
175
        $this->assertTrue($createdAudience instanceOf Audience);
176
        $this->assertTrue($createdAudience->getName()=='Spanish speaking San Franciscans');                
177
    }
178
    
179
    public function testUpdate()
180
    {
@@ 179-237 (lines=59) @@
176
        $this->assertTrue($createdAudience->getName()=='Spanish speaking San Franciscans');                
177
    }
178
    
179
    public function testUpdate()
180
    {
181
        // Mock 'OptimizelyApiClient' object to avoid real API calls
182
        $optimizelyApiClientMock = $this->getMockBuilder('\WebMarketingROI\OptimizelyPHP\OptimizelyApiClient')
183
                            ->disableOriginalConstructor()
184
                            ->getMock();
185
186
        $result = new Result(array(
187
                            "project_id" => 1000,
188
                            "archived" => false,
189
                            "conditions" => array(
190
                              "and",
191
                              array(
192
                                "type" => "language",
193
                                "value" => "es"
194
                              ),
195
                              array(
196
                                "type" => "location",
197
                                "value" => "US-CA-SANFRANCISCO"
198
                              )
199
                            ),
200
                            "description" => "People that speak spanish and are in San Francisco",
201
                            "name" => "Spanish speaking San Franciscans",
202
                            "segmentation" => true,
203
                            "created" => "2016-10-18T05:07:04.083Z",
204
                            "id" => 5000,
205
                            "last_modified" => "2016-10-18T05:07:04.083Z"
206
                        ), 200);
207
        
208
        $optimizelyApiClientMock->method('sendApiRequest')
209
                    ->willReturn($result);
210
        
211
        $audiencesService = new Audiences($optimizelyApiClientMock);
212
        
213
        $audience = new Audience(array(
214
                "project_id" => 1000,
215
                "archived" => false,
216
                "conditions" => array(
217
                  "and",
218
                  array(
219
                    "type" => "language",
220
                    "value" => "es"
221
                  ),
222
                  array(
223
                    "type" => "location",
224
                    "value" => "US-CA-SANFRANCISCO"
225
                  )
226
                ),
227
                "description" => "People that speak spanish and are in San Francisco",
228
                "name" => "Spanish speaking San Franciscans",
229
                "segmentation" => true
230
        ));
231
        
232
        $result = $audiencesService->update(5000, $audience);
233
        $createdAudience = $result->getPayload();
234
        
235
        $this->assertTrue($createdAudience instanceOf Audience);
236
        $this->assertTrue($createdAudience->getName()=='Spanish speaking San Franciscans');                
237
    }
238
    
239
    public function testIntegration()
240
    {