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

testPostAction() public method

public testPostAction ( )
    public function testPostAction()
    {
        $created = date(DATE_ISO8601);
        $request = $this->makeRequest('POST', '/person', json_encode(array('name' => 'Stan Lemon', 'created' => $created)));
        /** @var \Symfony\Component\HttpFoundation\Response $response */
        $response = $this->controller->postAction($request, 'person');
        $this->assertEquals(201, $response->getStatusCode());
        $this->assertNotEmpty($response->headers->get('Location'));
        $data = json_decode($response->getContent());
        $this->assertEquals($data->name, "Stan Lemon");
        $this->em->clear();
        $refresh = $this->em->getRepository('Lemon\\RestBundle\\Tests\\Fixtures\\Person')->findOneBy(array('id' => $data->id));
        $this->assertNotNull($refresh);
        $this->assertEquals("Stan Lemon", $refresh->name);
        $this->assertEquals(new \DateTime($created), $refresh->created);
        $this->assertNull($refresh->updated, "Excluded properties, even when passed should not be set");
    }