Code Duplication    Length = 31-33 lines in 2 locations

tests/ZendTransformer/Factory/AbstractTransformerFactoryTest.php 2 locations

@@ 241-271 (lines=31) @@
238
        self::assertEquals('Bob', $result->getBuz());
239
    }
240
    
241
    public function testTransformCustomKeyMapCallable()
242
    {
243
        $this->container->setService('config', [
244
            'abacaphiliac/zend-transformer' => [
245
                'transformers' => [
246
                    'FooBarToFizBuz' => [
247
                        'inputClass' => FooBar::class,
248
                        'transformer' => function (array $data) {
249
                            return [
250
                                'fiz' => $data['foo'],
251
                                'buz' => $data['bar'],
252
                            ];
253
                        },
254
                        'outputClass' => FizBuz::class,
255
                    ],
256
                ],
257
            ],
258
        ]);
259
        
260
        self::assertTrue($this->sut->canCreateServiceWithName($this->container, 'FooBarToFizBuz', 'FooBarToFizBuz'));
261
        
262
        $transformer = $this->sut->createServiceWithName($this->container, 'FooBarToFizBuz', 'FooBarToFizBuz');
263
        self::assertInstanceOf(TransformerInterface::class, $transformer);
264
        
265
        $result = $transformer->transform(new FooBar('Alice', 'Bob'), new FizBuz());
266
        self::assertInstanceOf(FizBuz::class, $result);
267
        
268
        /** @var FizBuz $result */
269
        self::assertEquals('Alice', $result->getFiz());
270
        self::assertEquals('Bob', $result->getBuz());
271
    }
272
    
273
    public function testTransformCustomKeyMapService()
274
    {
@@ 273-305 (lines=33) @@
270
        self::assertEquals('Bob', $result->getBuz());
271
    }
272
    
273
    public function testTransformCustomKeyMapService()
274
    {
275
        $this->container->setService('CustomKeyMapService', function (array $data) {
276
            return [
277
                'fiz' => $data['foo'],
278
                'buz' => $data['bar'],
279
            ];
280
        });
281
        
282
        $this->container->setService('config', [
283
            'abacaphiliac/zend-transformer' => [
284
                'transformers' => [
285
                    'FooBarToFizBuz' => [
286
                        'inputClass' => FooBar::class,
287
                        'transformer' => 'CustomKeyMapService',
288
                        'outputClass' => FizBuz::class,
289
                    ],
290
                ],
291
            ],
292
        ]);
293
        
294
        self::assertTrue($this->sut->canCreateServiceWithName($this->container, 'FooBarToFizBuz', 'FooBarToFizBuz'));
295
        
296
        $transformer = $this->sut->createServiceWithName($this->container, 'FooBarToFizBuz', 'FooBarToFizBuz');
297
        self::assertInstanceOf(TransformerInterface::class, $transformer);
298
        
299
        $result = $transformer->transform(new FooBar('Alice', 'Bob'), new FizBuz());
300
        self::assertInstanceOf(FizBuz::class, $result);
301
        
302
        /** @var FizBuz $result */
303
        self::assertEquals('Alice', $result->getFiz());
304
        self::assertEquals('Bob', $result->getBuz());
305
    }
306
    
307
    public function testTransformCustomInputValidatorInstance()
308
    {