Code Duplication    Length = 28-28 lines in 2 locations

src/Graviton/CoreBundle/Tests/Controller/ShowcaseControllerTest.php 2 locations

@@ 752-779 (lines=28) @@
749
     * @group ref
750
     * @return void
751
     */
752
    public function testPatchAddComplexObjectToSpecificIndexInArray()
753
    {
754
        // Apply PATCH request, add new element
755
        $client = static::createRestClient();
756
        $newApp = ['$ref' => 'http://localhost/core/app/admin'];
757
        $patchJson = json_encode(
758
            [
759
                [
760
                    'op' => 'add',
761
                    'path' => '/nestedApps/0',
762
                    'value' => $newApp
763
                ]
764
            ]
765
        );
766
        $client->request('PATCH', '/hans/showcase/500', [], [], [], $patchJson);
767
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
768
769
        // Check patched result
770
        $client = static::createRestClient();
771
        $client->request('GET', '/hans/showcase/500');
772
773
        $result = $client->getResults();
774
        $this->assertEquals(3, count($result->nestedApps));
775
        $this->assertEquals(
776
            'http://localhost/core/app/admin',
777
            $result->nestedApps[0]->{'$ref'}
778
        );
779
    }
780
781
    /**
782
     * Test PATCH: add complex object App to array
@@ 787-814 (lines=28) @@
784
     * @group ref
785
     * @return void
786
     */
787
    public function testPatchAddComplexObjectToTheEndOfArray()
788
    {
789
        // Apply PATCH request, add new element
790
        $client = static::createRestClient();
791
        $newApp = ['$ref' => 'http://localhost/core/app/test'];
792
        $patchJson = json_encode(
793
            [
794
                [
795
                    'op' => 'add',
796
                    'path' => '/nestedApps/-',
797
                    'value' => $newApp
798
                ]
799
            ]
800
        );
801
        $client->request('PATCH', '/hans/showcase/500', [], [], [], $patchJson);
802
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
803
804
        // Check patched result
805
        $client = static::createRestClient();
806
        $client->request('GET', '/hans/showcase/500');
807
808
        $result = $client->getResults();
809
        $this->assertEquals(3, count($result->nestedApps));
810
        $this->assertEquals(
811
            'http://localhost/core/app/test',
812
            $result->nestedApps[2]->{'$ref'}
813
        );
814
    }
815
816
    /**
817
     * Test PATCH: test operation to undefined index