| @@ 94-103 (lines=10) @@ | ||
| 91 | $this->assertEquals(2, $order->getLineItems()->count()); |
|
| 92 | } |
|
| 93 | ||
| 94 | public function testPatchWithNoAssocation() { |
|
| 95 | $this->client->request('PATCH', '/orders/'.$this->records[0]->getId().'.json', array(), array(), array(), json_encode(array( |
|
| 96 | 'lineItems'=>array() |
|
| 97 | ))); |
|
| 98 | $this->assertEquals("200", $this->client->getResponse()->getStatusCode()); |
|
| 99 | $repo = $this->client->getContainer()->get('doctrine_mongodb.odm.document_manager')->getRepository('TestTestBundle:Order'); |
|
| 100 | /** @var Order $order */ |
|
| 101 | $order = $repo->find($this->records[0]->getId()); |
|
| 102 | $this->assertEquals(1, $order->getLineItems()->count()); |
|
| 103 | } |
|
| 104 | } |
|
| @@ 144-154 (lines=11) @@ | ||
| 141 | $this->assertEquals($this->altOwner, $car->getCarOwner()); |
|
| 142 | } |
|
| 143 | ||
| 144 | public function testPatchWithDifferentAssociation() { |
|
| 145 | $this->client->request('PATCH', '/cars/'.$this->records[0]->getId().'.json', array(), array(), array(), json_encode(array( |
|
| 146 | 'carOwner'=>array( |
|
| 147 | 'id'=>$this->altOwner->getId() |
|
| 148 | ) |
|
| 149 | ))); |
|
| 150 | $this->assertEquals("200", $this->client->getResponse()->getStatusCode()); |
|
| 151 | $repo = $this->client->getContainer()->get('doctrine.orm.default_entity_manager')->getRepository('TestTestBundle:Car'); |
|
| 152 | $car = $repo->find($this->records[0]->getId()); |
|
| 153 | $this->assertEquals($this->altOwner, $car->getCarOwner()); |
|
| 154 | } |
|
| 155 | ||
| 156 | public function testPatchWithNoAssocation() { |
|
| 157 | $this->client->request('PATCH', '/cars/'.$this->records[0]->getId().'.json', array(), array(), array(), json_encode(array( |
|
| @@ 156-164 (lines=9) @@ | ||
| 153 | $this->assertEquals($this->altOwner, $car->getCarOwner()); |
|
| 154 | } |
|
| 155 | ||
| 156 | public function testPatchWithNoAssocation() { |
|
| 157 | $this->client->request('PATCH', '/cars/'.$this->records[0]->getId().'.json', array(), array(), array(), json_encode(array( |
|
| 158 | 'carOwner'=>null |
|
| 159 | ))); |
|
| 160 | $this->assertEquals("200", $this->client->getResponse()->getStatusCode()); |
|
| 161 | $repo = $this->client->getContainer()->get('doctrine.orm.default_entity_manager')->getRepository('TestTestBundle:Car'); |
|
| 162 | $car = $repo->find($this->records[0]->getId()); |
|
| 163 | $this->assertNull($car->getCarOwner()); |
|
| 164 | } |
|
| 165 | ||
| 166 | public function testPatchWithDifferentHasManyAssociation() { |
|
| 167 | $repo = $this->client->getContainer()->get('doctrine.orm.default_entity_manager')->getRepository('TestTestBundle:Car'); |
|