@@ 65-76 (lines=12) @@ | ||
62 | $this->assertEquals(1, count($content)); |
|
63 | } |
|
64 | ||
65 | public function testGetActionWithId() { |
|
66 | $repo = $this->client->getContainer()->get('doctrine_mongodb.odm.default_document_manager')->getRepository('TestTestBundle:Order'); |
|
67 | /** @var LoggableCursor $orders */ |
|
68 | $orders = $repo->findAll(); |
|
69 | $order = reset($orders); |
|
70 | $this->client->request('GET', '/orders/'.$order->getId().'.json'); |
|
71 | $this->assertEquals("200", $this->client->getResponse()->getStatusCode()); |
|
72 | $content = json_decode($this->client->getResponse()->getContent(), true); |
|
73 | $this->assertEquals($order->getId(), $content['id']); |
|
74 | $this->assertEquals($order->getName(), $content['name']); |
|
75 | $this->assertEquals($order->getTotalPrice(), $content['totalPrice']); |
|
76 | } |
|
77 | ||
78 | public function testPostAction() { |
|
79 | $this->client->request('POST', '/orders.json', array(), array(), array(), json_encode(array( |
@@ 94-105 (lines=12) @@ | ||
91 | $this->assertEquals(1, count($content)); |
|
92 | } |
|
93 | ||
94 | public function testGetActionWithId() { |
|
95 | $repo = $this->client->getContainer()->get('doctrine.orm.default_entity_manager')->getRepository('TestTestBundle:Car'); |
|
96 | $cars = $repo->findAll(); |
|
97 | /** @var Car $car */ |
|
98 | $car = $cars[0]; |
|
99 | $this->client->request('GET', '/cars/'.$car->getId().'.json'); |
|
100 | $this->assertEquals("200", $this->client->getResponse()->getStatusCode()); |
|
101 | $content = json_decode($this->client->getResponse()->getContent(), true); |
|
102 | $this->assertEquals($car->getId(), $content['id']); |
|
103 | $this->assertEquals($car->getName(), $content['name']); |
|
104 | $this->assertEquals($car->getPlateNumber(), $content['plateNumber']); |
|
105 | } |
|
106 | ||
107 | public function testPostAction() { |
|
108 | $this->client->request('POST', '/cars.json', array(), array(), array(), json_encode(array( |