From 93716c8583827200631b059f51e9babd27faf12f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Thu, 31 Oct 2019 23:05:20 +0100 Subject: [PATCH] Dont let Webclient catch exceptions during testing of the admin pages. --- .../AdminPages/AbstractAdminControllerTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/Controller/AdminPages/AbstractAdminControllerTest.php b/tests/Controller/AdminPages/AbstractAdminControllerTest.php index 45e33c39..d78aabf4 100644 --- a/tests/Controller/AdminPages/AbstractAdminControllerTest.php +++ b/tests/Controller/AdminPages/AbstractAdminControllerTest.php @@ -36,6 +36,7 @@ use App\Entity\Attachments\AttachmentType; use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\Security\Core\Exception\AccessDeniedException; use Symfony\Component\Security\Core\Security; /** @@ -77,6 +78,12 @@ abstract class AbstractAdminControllerTest extends WebTestCase 'PHP_AUTH_PW' => 'test', ]); + if ($read == false) { + $this->expectException(AccessDeniedException::class); + } + + $client->catchExceptions(false); + //Test read/list access by access /new overview page $crawler = $client->request('GET', static::$base_path . '/new'); $this->assertFalse($client->getResponse()->isRedirect()); @@ -97,6 +104,11 @@ abstract class AbstractAdminControllerTest extends WebTestCase 'PHP_AUTH_PW' => 'test', ]); + $client->catchExceptions(false); + if ($read == false) { + $this->expectException(AccessDeniedException::class); + } + //Test read/list access by access /new overview page $crawler = $client->request('GET', static::$base_path . '/1'); $this->assertFalse($client->getResponse()->isRedirect()); @@ -127,6 +139,11 @@ abstract class AbstractAdminControllerTest extends WebTestCase 'PHP_AUTH_PW' => 'test', ]); + $client->catchExceptions(false); + if ($delete == false) { + $this->expectException(AccessDeniedException::class); + } + //Test read/list access by access /new overview page $crawler = $client->request('DELETE', static::$base_path . '/7');