Skip to content

Commit

Permalink
Updated basic test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomas Voslar committed Jan 22, 2017
1 parent 9646622 commit c81fc8b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
15 changes: 0 additions & 15 deletions src/Webcook/Cms/CoreBundle/Base/BaseRestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,6 @@ protected function getLockVersion($key)
}
}

/**
* @param [type] $permission [description]
*
* @return [type] [description]
*/
protected function checkPermission($permission)
{
$controller = $this->container->get('request_stack')->getCurrentRequest()->get('_controller');
$resource = SecurityHelper::extractName($controller);

if (false === $this->get('security.authorization_checker')->isGranted($permission, $resource)) {
throw new AccessDeniedException('Unauthorised access!');
}
}

/**
* Returns entity manager.
*
Expand Down
18 changes: 18 additions & 0 deletions src/Webcook/Cms/CoreBundle/Tests/BasicTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,24 @@ protected function printResponseContent()
print_r($this->client->getResponse()->getContent());
}

protected function jsonRequest($method, $url, $data = array(), $addPostfix = true)
{
$this->createTestClient();

$crawler = $this->client->request(
$method,
$url . ($addPostfix ? '.json' : ''),
array(),
array(),
array(
'CONTENT_TYPE' => 'application/json'
),
json_encode($data)
);

return $crawler;
}

protected function logIn()
{
$session = $this->client->getContainer()->get('session');
Expand Down

0 comments on commit c81fc8b

Please sign in to comment.