diff --git a/tests/AppBundle/Controller/Admin/BlogControllerTest.php b/tests/AppBundle/Controller/Admin/BlogControllerTest.php index 99b68072e..7c4ed7d09 100644 --- a/tests/AppBundle/Controller/Admin/BlogControllerTest.php +++ b/tests/AppBundle/Controller/Admin/BlogControllerTest.php @@ -27,35 +27,55 @@ * Execute the application tests using this command (requires PHPUnit to be installed): * * $ cd your-symfony-project/ - * $ phpunit -c app + * $ ./vendor/bin/phpunit */ class BlogControllerTest extends WebTestCase { - public function testRegularUsersCannotAccessToTheBackend() + /** + * @dataProvider getUrlsForRegularUsers + */ + public function testRegularUsers($httpMethod, $url, $statusCode) { $client = static::createClient([], [ 'PHP_AUTH_USER' => 'john_user', 'PHP_AUTH_PW' => 'kitten', ]); - $client->request('GET', '/en/admin/post/'); + $client->request($httpMethod, $url); + $this->assertEquals($statusCode, $client->getResponse()->getStatusCode()); + } - $this->assertEquals(Response::HTTP_FORBIDDEN, $client->getResponse()->getStatusCode()); + public function getUrlsForRegularUsers() + { + yield ['GET', '/en/admin/post/', Response::HTTP_FORBIDDEN]; + yield ['GET', '/en/admin/post/1', Response::HTTP_FORBIDDEN]; + yield ['GET', '/en/admin/post/1/edit', Response::HTTP_FORBIDDEN]; + yield ['POST', '/en/admin/post/1/delete', Response::HTTP_FORBIDDEN]; } - public function testAdministratorUsersCanAccessToTheBackend() + /** + * @dataProvider getUrlsForAdminUsers + */ + public function testAdminUsers($httpMethod, $url, $statusCode) { $client = static::createClient([], [ 'PHP_AUTH_USER' => 'anna_admin', 'PHP_AUTH_PW' => 'kitten', ]); - $client->request('GET', '/en/admin/post/'); + $client->request($httpMethod, $url); + $this->assertEquals($statusCode, $client->getResponse()->getStatusCode()); + } - $this->assertEquals(Response::HTTP_OK, $client->getResponse()->getStatusCode()); + public function getUrlsForAdminUsers() + { + yield ['GET', '/en/admin/post/', Response::HTTP_OK]; + yield ['GET', '/en/admin/post/1', Response::HTTP_OK]; + yield ['GET', '/en/admin/post/1/edit', Response::HTTP_OK]; + yield ['POST', '/en/admin/post/1/delete', Response::HTTP_FOUND]; } - public function testIndex() + public function testBackendHomepage() { $client = static::createClient([], [ 'PHP_AUTH_USER' => 'anna_admin', @@ -70,26 +90,4 @@ public function testIndex() 'The backend homepage displays all the available posts.' ); } - - /** - * @dataProvider getPostUrls - */ - public function testOnlyAuthorCanAccessToThePostInTheBackend($method, $url, $statusCode) - { - $client = static::createClient([], [ - 'PHP_AUTH_USER' => 'anna_admin', - 'PHP_AUTH_PW' => 'kitten', - ]); - - $client->request($method, $url); - - $this->assertEquals($statusCode, $client->getResponse()->getStatusCode()); - } - - public function getPostUrls() - { - yield ['GET', '/en/admin/post/1', Response::HTTP_OK]; - yield ['GET', '/en/admin/post/1/edit', Response::HTTP_OK]; - yield ['POST', '/en/admin/post/1/delete', Response::HTTP_FOUND]; - } } diff --git a/tests/AppBundle/Controller/BlogControllerTest.php b/tests/AppBundle/Controller/BlogControllerTest.php index 80d05960c..dd1bba44c 100644 --- a/tests/AppBundle/Controller/BlogControllerTest.php +++ b/tests/AppBundle/Controller/BlogControllerTest.php @@ -22,7 +22,7 @@ * Execute the application tests using this command (requires PHPUnit to be installed): * * $ cd your-symfony-project/ - * $ phpunit -c app + * $ ./vendor/bin/phpunit */ class BlogControllerTest extends WebTestCase { diff --git a/tests/AppBundle/Controller/DefaultControllerTest.php b/tests/AppBundle/Controller/DefaultControllerTest.php index 1d359eab5..bc0a9ff86 100644 --- a/tests/AppBundle/Controller/DefaultControllerTest.php +++ b/tests/AppBundle/Controller/DefaultControllerTest.php @@ -21,7 +21,7 @@ * Execute the application tests using this command (requires PHPUnit to be installed): * * $ cd your-symfony-project/ - * $ phpunit -c app + * $ ./vendor/bin/phpunit */ class DefaultControllerTest extends WebTestCase { diff --git a/tests/AppBundle/Utils/SluggerTest.php b/tests/AppBundle/Utils/SluggerTest.php index 24c294e5f..d5d32def3 100644 --- a/tests/AppBundle/Utils/SluggerTest.php +++ b/tests/AppBundle/Utils/SluggerTest.php @@ -21,7 +21,7 @@ * Execute the application tests using this command (requires PHPUnit to be installed): * * $ cd your-symfony-project/ - * $ phpunit -c app + * $ ./vendor/bin/phpunit */ class SluggerTest extends \PHPUnit_Framework_TestCase {