Dont let Webclient catch exceptions during testing of the admin pages.

This commit is contained in:
Jan Böhmer 2019-10-31 23:05:20 +01:00
parent fdfb099cb5
commit 93716c8583

View file

@ -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');