Lemon\RestBundle\Tests\Controller\ResourceControllerTest::testPutActionWithNestedCollectionAndNewItemWithId0 PHP Method

testPutActionWithNestedCollectionAndNewItemWithId0() public method

    public function testPutActionWithNestedCollectionAndNewItemWithId0()
    {
        $person = new Person();
        $person->name = "Stan Lemon";
        $this->em->persist($person);
        $this->em->flush($person);
        $this->em->clear();
        $request = $this->makeRequest('PUT', '/person/' . $person->id, json_encode(array('name' => $person->name, 'cars' => array(array('id' => 0, 'name' => "Honda Odyssey", 'year' => 2006)))));
        /** @var \Symfony\Component\HttpFoundation\Response $response */
        $response = $this->controller->putAction($request, 'person', $person->id);
        $data = json_decode($response->getContent());
        $refresh = $this->em->getRepository('Lemon\\RestBundle\\Tests\\Fixtures\\Person')->findOneBy(array('id' => $data->id));
        $this->assertNotNull($refresh);
        $this->assertEquals($person->id, $refresh->id);
        $this->assertEquals($person->name, $refresh->name);
        $this->assertCount(1, $refresh->cars);
        $this->assertNotEquals(0, $refresh->cars[0]->id);
        $this->assertEquals("Honda Odyssey", $refresh->cars[0]->name);
        $this->assertEquals(2006, $refresh->cars[0]->year);
    }