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