Code Duplication    Length = 58-59 lines in 2 locations

test/Serializer/JsonApiSerializerTest.php 2 locations

@@ 2455-2513 (lines=59) @@
2452
        $this->assertSame($expectedJson, $scope->toJson());
2453
    }
2454
2455
    public function testCustomLinkMerge()
2456
    {
2457
        $manager = new Manager();
2458
        $manager->setSerializer(new JsonApiSerializer('http://test.de'));
2459
2460
        $bookData = [
2461
            'id' => 1,
2462
            'title' => 'Foo',
2463
            'year' => '1991',
2464
            '_author' => [
2465
                'id' => 1,
2466
                'name' => 'Dave',
2467
            ],
2468
            'links' => [
2469
                'custom_link' => '/custom/link',
2470
            ],
2471
        ];
2472
2473
        $resource = new Item($bookData, new JsonApiBookTransformer('test.de'), 'books');
2474
2475
        $scope = new Scope($manager, $resource);
2476
2477
        $expected = [
2478
            'data' => [
2479
                'type' => 'books',
2480
                'id' => '1',
2481
                'attributes' => [
2482
                    'title' => 'Foo',
2483
                    'year' => 1991,
2484
                ],
2485
                'links' => [
2486
                    'self' => 'http://test.de/books/1',
2487
                    'custom_link' => '/custom/link',
2488
                ],
2489
                'relationships' => [
2490
                    'author' => [
2491
                        'links' => [
2492
                            'self' => 'http://test.de/books/1/relationships/author',
2493
                            'related' => 'http://test.de/books/1/author',
2494
                        ],
2495
                    ],
2496
                    'co-author' => [
2497
                        'links' => [
2498
                            'self' => 'http://test.de/books/1/relationships/co-author',
2499
                            'related' => 'http://test.de/books/1/co-author'
2500
                        ],
2501
                    ],
2502
                    'author-with-meta' => [
2503
                        'links' => [
2504
                            'self' => 'http://test.de/books/1/relationships/author-with-meta',
2505
                            'related' => 'http://test.de/books/1/author-with-meta'
2506
                        ],
2507
                    ],
2508
                ],
2509
            ],
2510
        ];
2511
2512
        $this->assertSame(json_encode($expected), $scope->toJson());
2513
    }
2514
2515
    public function testCustomLinkMergeNoLink()
2516
    {
@@ 2571-2628 (lines=58) @@
2568
        $this->assertSame(json_encode($expected), $scope->toJson());
2569
    }
2570
2571
    public function testCustomSelfLinkMerge()
2572
    {
2573
        $manager = new Manager();
2574
        $manager->setSerializer(new JsonApiSerializer('http://test.de'));
2575
2576
        $bookData = [
2577
            'id' => 1,
2578
            'title' => 'Foo',
2579
            'year' => '1991',
2580
            '_author' => [
2581
                'id' => 1,
2582
                'name' => 'Dave',
2583
            ],
2584
            'links' => [
2585
                'self' => '/custom/link',
2586
            ],
2587
        ];
2588
2589
        $resource = new Item($bookData, new JsonApiBookTransformer('test.de'), 'books');
2590
2591
        $scope = new Scope($manager, $resource);
2592
2593
        $expected = [
2594
            'data' => [
2595
                'type' => 'books',
2596
                'id' => '1',
2597
                'attributes' => [
2598
                    'title' => 'Foo',
2599
                    'year' => 1991,
2600
                ],
2601
                'links' => [
2602
                    'self' => '/custom/link',
2603
                ],
2604
                'relationships' => [
2605
                    'author' => [
2606
                        'links' => [
2607
                            'self' => 'http://test.de/books/1/relationships/author',
2608
                            'related' => 'http://test.de/books/1/author',
2609
                        ],
2610
                    ],
2611
                    'co-author' => [
2612
                        'links' => [
2613
                            'self' => 'http://test.de/books/1/relationships/co-author',
2614
                            'related' => 'http://test.de/books/1/co-author'
2615
                        ],
2616
                    ],
2617
                    'author-with-meta' => [
2618
                        'links' => [
2619
                            'self' => 'http://test.de/books/1/relationships/author-with-meta',
2620
                            'related' => 'http://test.de/books/1/author-with-meta'
2621
                        ],
2622
                    ],
2623
                ],
2624
            ],
2625
        ];
2626
2627
        $this->assertSame(json_encode($expected), $scope->toJson());
2628
    }
2629
2630
    public function testEmptyAttributesIsObject()
2631
    {