Code Duplication    Length = 35-35 lines in 2 locations

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

@@ 716-750 (lines=35) @@
713
     * @group ref
714
     * @return void
715
     */
716
    public function testPatchAddComplexObjectToSpecificIndexInArray()
717
    {
718
        // Load fixtures
719
        $this->loadFixtures(
720
            ['GravitonDyn\ShowCaseBundle\DataFixtures\MongoDB\LoadShowCaseData'],
721
            null,
722
            'doctrine_mongodb'
723
        );
724
725
        // Apply PATCH request, add new element
726
        $client = static::createRestClient();
727
        $newApp = ['ref' => 'http://localhost/core/app/admin'];
728
        $patchJson = json_encode(
729
            [
730
                [
731
                    'op' => 'add',
732
                    'path' => '/nestedApps/0',
733
                    'value' => $newApp
734
                ]
735
            ]
736
        );
737
        $client->request('PATCH', '/hans/showcase/500', array(), array(), array(), $patchJson);
738
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
739
740
        // Check patched result
741
        $client = static::createRestClient();
742
        $client->request('GET', '/hans/showcase/500');
743
744
        $result = $client->getResults();
745
        $this->assertEquals(3, count($result->nestedApps));
746
        $this->assertEquals(
747
            'http://localhost/core/app/admin',
748
            $result->nestedApps[0]->{'$ref'}
749
        );
750
    }
751
752
    /**
753
     * Test PATCH: add complex object App to array
@@ 758-792 (lines=35) @@
755
     * @group ref
756
     * @return void
757
     */
758
    public function testPatchAddComplexObjectToTheEndOfArray()
759
    {
760
        // Load fixtures
761
        $this->loadFixtures(
762
            ['GravitonDyn\ShowCaseBundle\DataFixtures\MongoDB\LoadShowCaseData'],
763
            null,
764
            'doctrine_mongodb'
765
        );
766
767
        // Apply PATCH request, add new element
768
        $client = static::createRestClient();
769
        $newApp = ['ref' => 'http://localhost/core/app/test'];
770
        $patchJson = json_encode(
771
            [
772
                [
773
                    'op' => 'add',
774
                    'path' => '/nestedApps/-',
775
                    'value' => $newApp
776
                ]
777
            ]
778
        );
779
        $client->request('PATCH', '/hans/showcase/500', array(), array(), array(), $patchJson);
780
        $this->assertEquals(200, $client->getResponse()->getStatusCode());
781
782
        // Check patched result
783
        $client = static::createRestClient();
784
        $client->request('GET', '/hans/showcase/500');
785
786
        $result = $client->getResults();
787
        $this->assertEquals(3, count($result->nestedApps));
788
        $this->assertEquals(
789
            'http://localhost/core/app/test',
790
            $result->nestedApps[2]->{'$ref'}
791
        );
792
    }
793
794
    /**
795
     * Test PATCH: test operation to undefined index