Code Duplication    Length = 28-30 lines in 2 locations

tests/unit/Task/CollectionTest.php 2 locations

@@ 204-233 (lines=30) @@
201
        verify($state['three'])->equals('First and Second');
202
    }
203
204
    public function testDeferredInitializationWithMessageStorage()
205
    {
206
        $collection = new Collection();
207
208
        $first = new ValueProviderTask();
209
        $first->provideMessage('1st');
210
211
        $second = new ValueProviderTask();
212
        $second->provideData('other', '2nd');
213
214
        $third = new ValueProviderTask();
215
216
        $result = $collection
217
            ->add($first)
218
                ->storeState($first, 'one')
219
            ->add($second)
220
                ->storeState($second, 'two', 'other')
221
            ->add($third)
222
                ->defer(
223
                    $third,
224
                    function ($task, $state) {
225
                        $task->provideData('three', "{$state['one']} and {$state['two']}");
226
                    }
227
                )
228
            ->run();
229
230
        $state = $collection->getState();
231
        verify($state['one'])->equals('1st');
232
        verify($state['three'])->equals('1st and 2nd');
233
    }
234
    public function testDeferredInitializationWithChainedInitialization()
235
    {
236
        $collection = new Collection();
@@ 234-261 (lines=28) @@
231
        verify($state['one'])->equals('1st');
232
        verify($state['three'])->equals('1st and 2nd');
233
    }
234
    public function testDeferredInitializationWithChainedInitialization()
235
    {
236
        $collection = new Collection();
237
238
        $first = new ValueProviderTask();
239
        $first->provideMessage('1st');
240
241
        $second = new ValueProviderTask();
242
        $second->provideMessage('2nd');
243
244
        $third = new ValueProviderTask();
245
246
        $result = $collection
247
            ->add($first)
248
                ->storeState($first, 'one')
249
            ->add($second)
250
                ->storeState($second, 'two')
251
            ->add($third)
252
                ->chainState($third, 'provideItem', 'one')
253
                ->chainState($third, 'provideMessage', 'two')
254
                ->storeState($third, 'final')
255
            ->run();
256
257
        $state = $collection->getState();
258
        verify($state['one'])->equals('1st');
259
        verify($state['item'])->equals('1st');
260
        verify($state['final'])->equals('2nd');
261
    }
262
}
263
264