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

testGetActionWithVersion() public method

    public function testGetActionWithVersion()
    {
        $footballTeam = new FootballTeam();
        $footballTeam->name = 'Steelers';
        $footballTeam->conference = 'AFC';
        $footballTeam->league = 'Amercian';
        $this->em->persist($footballTeam);
        $this->em->flush($footballTeam);
        $this->em->clear();
        $request = $this->makeRequest('GET', '/footballTeam/' . $footballTeam->id, null, array(), array('HTTP_ACCEPT' => 'application/json;version=0.9.2'));
        /** @var \Symfony\Component\HttpFoundation\Response $response */
        $response = $this->controller->getAction($request, 'footballTeam', $footballTeam->id);
        $data = json_decode($response->getContent());
        $this->assertEquals($footballTeam->league, $data->league);
        $this->assertTrue(!isset($data->conference));
        $request = $this->makeRequest('GET', '/footballTeam/' . $footballTeam->id, null, array(), array('HTTP_ACCEPT' => 'application/json;version=1.1.2'));
        /** @var \Symfony\Component\HttpFoundation\Response $response */
        $response = $this->controller->getAction($request, 'footballTeam', $footballTeam->id);
        $data = json_decode($response->getContent());
        $this->assertEquals($footballTeam->conference, $data->conference);
        $this->assertTrue(!isset($data->league));
    }