Code Duplication    Length = 12-20 lines in 4 locations

test/ScopeTest.php 4 locations

@@ 475-494 (lines=20) @@
472
        $this->assertSame($expectedOutput, $rootScope->toArray());
473
    }
474
475
    public function testDefaultIncludeSuccess()
476
    {
477
        $manager = new Manager();
478
        $manager->setSerializer(new ArraySerializer());
479
480
        // Send this stub junk, it has a specific format anyhow
481
        $resource = new Item([], new DefaultIncludeBookTransformer());
482
483
        // Try without metadata
484
        $scope = new Scope($manager, $resource);
485
486
        $expected = [
487
            'a' => 'b',
488
            'author' => [
489
                'c' => 'd',
490
            ],
491
        ];
492
493
        $this->assertSame($expected, $scope->toArray());
494
    }
495
496
    public function testPrimitiveResourceIncludeSuccess()
497
    {
@@ 496-510 (lines=15) @@
493
        $this->assertSame($expected, $scope->toArray());
494
    }
495
496
    public function testPrimitiveResourceIncludeSuccess()
497
    {
498
        $manager = new Manager();
499
        $manager->setSerializer(new ArraySerializer());
500
501
        $resource = new Item(['price' => '49'], new PrimitiveIncludeBookTransformer);
502
503
        $scope = new Scope($manager, $resource);
504
        $expected = [
505
            'a' => 'b',
506
            'price' => 49,
507
        ];
508
509
        $this->assertSame($expected, $scope->toArray());
510
    }
511
512
    public function testNullResourceIncludeSuccess()
513
    {
@@ 512-528 (lines=17) @@
509
        $this->assertSame($expected, $scope->toArray());
510
    }
511
512
    public function testNullResourceIncludeSuccess()
513
    {
514
        $manager = new Manager();
515
        $manager->setSerializer(new ArraySerializerWithNull);
516
517
        // Send this stub junk, it has a specific format anyhow
518
        $resource = new Item([], new NullIncludeBookTransformer);
519
520
        // Try without metadata
521
        $scope = new Scope($manager, $resource);
522
        $expected = [
523
            'a' => 'b',
524
            'author' => null,
525
        ];
526
527
        $this->assertSame($expected, $scope->toArray());
528
    }
529
530
    /**
531
     * @covers \League\Fractal\Scope::toArray
@@ 533-544 (lines=12) @@
530
    /**
531
     * @covers \League\Fractal\Scope::toArray
532
     */
533
    public function testNullResourceDataAndJustMeta()
534
    {
535
        $manager = new Manager();
536
        $manager->setSerializer(new ArraySerializerWithNull);
537
538
        $resource = new NullResource();
539
        $resource->setMeta(['foo' => 'bar']);
540
541
        $scope = new Scope($manager, $resource);
542
543
        $this->assertSame(['meta' => ['foo' => 'bar']], $scope->toArray());
544
    }
545
546
    /**
547
     * @covers \League\Fractal\Scope::toArray