|
@@ 101-114 (lines=14) @@
|
| 98 |
|
$this->assertNull($car->getCarOwner()); |
| 99 |
|
} |
| 100 |
|
|
| 101 |
|
public function testPutWithSameAssociation() { |
| 102 |
|
$record = $this->records[0]; |
| 103 |
|
$this->client->request('PUT', '/cars/'.$record->getId().'.json', array(), array(), array(), json_encode(array( |
| 104 |
|
'name'=>'Mazda', |
| 105 |
|
'plateNumber'=>'AA00', |
| 106 |
|
'carOwner' => array( |
| 107 |
|
'id' => $this->owner->getId() |
| 108 |
|
) |
| 109 |
|
))); |
| 110 |
|
$this->assertEquals("200", $this->client->getResponse()->getStatusCode(), $this->client->getResponse()->getContent()); |
| 111 |
|
$repo = $this->client->getContainer()->get('doctrine.orm.default_entity_manager')->getRepository('TestTestBundle:Car'); |
| 112 |
|
$car = $repo->find($record->getId()); |
| 113 |
|
$this->assertEquals($this->owner, $car->getCarOwner()); |
| 114 |
|
} |
| 115 |
|
|
| 116 |
|
public function testPutWithNoAssocation() { |
| 117 |
|
$record = $this->records[0]; |
|
@@ 129-142 (lines=14) @@
|
| 126 |
|
$this->assertNull($car->getCarOwner()); |
| 127 |
|
} |
| 128 |
|
|
| 129 |
|
public function testPutWithDifferentAssociation() { |
| 130 |
|
$record = $this->records[0]; |
| 131 |
|
$this->client->request('PUT', '/cars/'.$record->getId().'.json', array(), array(), array(), json_encode(array( |
| 132 |
|
'name'=>'Mazda', |
| 133 |
|
'plateNumber'=>'AA00', |
| 134 |
|
'carOwner' => array( |
| 135 |
|
'id' => $this->altOwner->getId() |
| 136 |
|
) |
| 137 |
|
))); |
| 138 |
|
$this->assertEquals("200", $this->client->getResponse()->getStatusCode(), $this->client->getResponse()->getContent()); |
| 139 |
|
$repo = $this->client->getContainer()->get('doctrine.orm.default_entity_manager')->getRepository('TestTestBundle:Car'); |
| 140 |
|
$car = $repo->find($record->getId()); |
| 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( |