Code Duplication    Length = 35-35 lines in 2 locations

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

@@ 800-834 (lines=35) @@
797
     * @group ref
798
     * @return void
799
     */
800
    public function testPatchAddComplexObjectToSpecificIndexInArray()
801
    {
802
        // Load fixtures
803
        $this->loadFixtures(
804
            ['GravitonDyn\ShowCaseBundle\DataFixtures\MongoDB\LoadShowCaseData'],
805
            null,
806
            'doctrine_mongodb'
807
        );
808
809
        // Apply PATCH request, add new element
810
        $client = static::createRestClient();
811
        $newApp = ['$ref' => 'http://localhost/core/app/admin'];
812
        $patchJson = json_encode(
813
            [
814
                [
815
                    'op' => 'add',
816
                    'path' => '/nestedApps/0',
817
                    'value' => $newApp
818
                ]
819
            ]
820
        );
821
        $client->request('PATCH', '/hans/showcase/500', array(), array(), array(), $patchJson);
822
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
823
824
        // Check patched result
825
        $client = static::createRestClient();
826
        $client->request('GET', '/hans/showcase/500');
827
828
        $result = $client->getResults();
829
        $this->assertEquals(3, count($result->nestedApps));
830
        $this->assertEquals(
831
            'http://localhost/core/app/admin',
832
            $result->nestedApps[0]->{'$ref'}
833
        );
834
    }
835
836
    /**
837
     * Test PATCH: add complex object App to array
@@ 842-876 (lines=35) @@
839
     * @group ref
840
     * @return void
841
     */
842
    public function testPatchAddComplexObjectToTheEndOfArray()
843
    {
844
        // Load fixtures
845
        $this->loadFixtures(
846
            ['GravitonDyn\ShowCaseBundle\DataFixtures\MongoDB\LoadShowCaseData'],
847
            null,
848
            'doctrine_mongodb'
849
        );
850
851
        // Apply PATCH request, add new element
852
        $client = static::createRestClient();
853
        $newApp = ['$ref' => 'http://localhost/core/app/test'];
854
        $patchJson = json_encode(
855
            [
856
                [
857
                    'op' => 'add',
858
                    'path' => '/nestedApps/-',
859
                    'value' => $newApp
860
                ]
861
            ]
862
        );
863
        $client->request('PATCH', '/hans/showcase/500', array(), array(), array(), $patchJson);
864
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
865
866
        // Check patched result
867
        $client = static::createRestClient();
868
        $client->request('GET', '/hans/showcase/500');
869
870
        $result = $client->getResults();
871
        $this->assertEquals(3, count($result->nestedApps));
872
        $this->assertEquals(
873
            'http://localhost/core/app/test',
874
            $result->nestedApps[2]->{'$ref'}
875
        );
876
    }
877
878
    /**
879
     * Test PATCH: test operation to undefined index