diff --git a/src/Controller/CapsuleGroupController.php b/src/Controller/CapsuleGroupController.php index fb61dd0269b16d823db01ed85b162c451efc9647..f69a6fd1c4c657f73acb468b00ac1b53f2e48460 100755 --- a/src/Controller/CapsuleGroupController.php +++ b/src/Controller/CapsuleGroupController.php @@ -12,10 +12,12 @@ use App\Form\SelectCapsuleGroupsFormType; use App\Repository\CapsuleRepository; use App\Repository\GroupRepository; use Doctrine\ORM\EntityManagerInterface; +use Exception; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Component\Routing\Annotation\Route; @@ -41,7 +43,7 @@ class CapsuleGroupController extends AbstractController $groups = $current_user->getGroups()->toArray(); return $this->render('capsule/groups/user_groups.html.twig', [ - 'groups' => $groups + 'groups' => $groups, ]); } @@ -77,10 +79,13 @@ class CapsuleGroupController extends AbstractController } return $this->renderForm('capsule/groups/create.html.twig', [ - 'createCapsuleGroupsForm' => $form + 'createCapsuleGroupsForm' => $form, ]); } + /** + * @throws Exception The group doesn't exist + */ #[Route('/{_locale<%app.supported_locales%>}/my_groups/{group_id}/delete', name:'delete_group')] public function deleteGroup(int $group_id, Request $request): Response { @@ -91,7 +96,7 @@ class CapsuleGroupController extends AbstractController $group = $this->group_repository->findOneBy(['id' => $group_id]); if (! $group instanceof Group) { - throw new \Exception('Group not found'); + throw new Exception('Group not found'); } $form = $this->createForm(DeleteGroupFormType::class); @@ -125,10 +130,13 @@ class CapsuleGroupController extends AbstractController return $this->renderForm('capsule/groups/delete.html.twig', [ 'deleteGroupForm' => $form, - 'group_name' => $group->getName() + 'group_name' => $group->getName(), ]); } + /** + * @throws Exception the capsule doesn't exist + */ #[Route('/{_locale<%app.supported_locales%>}/capsule/{capsule_id}/groups/edit', name:'edit_capsule_groups')] public function edit(int $capsule_id, Request $request): Response { @@ -141,7 +149,7 @@ class CapsuleGroupController extends AbstractController $capsule = $this->capsule_repository->findOneBy(['id' => $capsule_id]); if (! $capsule instanceof Capsule) { - throw new \Exception("Capsule does not exist"); + throw new Exception("Capsule does not exist"); } $capsule_groups_by_author = $current_user->getGroupsByCapsule($capsule); @@ -174,7 +182,7 @@ class CapsuleGroupController extends AbstractController ); return $this->redirectToRoute('edit_capsule_groups', [ - 'capsule_id' => $capsule_id + 'capsule_id' => $capsule_id, ]); } @@ -186,6 +194,9 @@ class CapsuleGroupController extends AbstractController ]); } + /** + * @throws Exception the capsule is not found or the group is not found + */ #[Route('/{_locale<%app.supported_locales%>}/capsule/{capsule_id}/groups/{group_id}/remove', name:'remove_group')] public function remove( int $capsule_id, @@ -194,12 +205,12 @@ class CapsuleGroupController extends AbstractController ): Response { $capsule = $this->capsule_repository->findOneBy(['id' => $capsule_id]); if (! $capsule instanceof Capsule) { - throw new \Exception('Capsule not found'); + throw new Exception('Capsule not found'); } $group = $this->group_repository->findOneBy(['id' => $group_id]); if (! $group instanceof Group) { - throw new \Exception('Group not found'); + throw new Exception('Group not found'); } $current_user = $this->getUser(); @@ -238,7 +249,7 @@ class CapsuleGroupController extends AbstractController return $this->renderForm('capsule/groups/remove.html.twig', [ 'removeGroupForm' => $form, 'group_name' => $group->getName(), - 'capsule_id' => $capsule_id + 'capsule_id' => $capsule_id, ]); } @@ -254,7 +265,7 @@ class CapsuleGroupController extends AbstractController $group_db = $this->group_repository->findOneBy(['id' => $group_data->getId()]); if (! $group_db instanceof Group) { - throw new \Exception('Group not found'); + throw new Exception('Group not found'); } $groups[] = $group_db; diff --git a/templates/capsule/delete.html.twig b/templates/capsule/delete.html.twig index 67d6f794bedbd58b3d1ccb9481b72b1dfcbaf9a8..df950587951bc3b379a5ab556f5ec4a638d24fe5 100644 --- a/templates/capsule/delete.html.twig +++ b/templates/capsule/delete.html.twig @@ -23,7 +23,7 @@ {{ form_start(deleteCapsuleForm, {'attr': {novalidate: 'novalidate', 'class': 'd-flex flex-row justify-content-center'}}) }} {{ form_row(deleteCapsuleForm.delete, {'row_attr': {'class' : 'm-auto mb-2 me-3'}}) }} - <a href="/"> + <a href="{{ path('home') }}"> {{ form_row(deleteCapsuleForm.cancel, {'row_attr': {'class' : 'm-auto mb-2 bg-secondary rounded ms-3'}}) }} </a> {{ form_end(deleteCapsuleForm) }} diff --git a/templates/capsule/editors/list_editors.html.twig b/templates/capsule/editors/list_editors.html.twig index 355ec3640f684795957c9ef547e04b113dc1dd02..d6d82fe7347f2680e1d30f135ca998bed63ee1e4 100644 --- a/templates/capsule/editors/list_editors.html.twig +++ b/templates/capsule/editors/list_editors.html.twig @@ -48,7 +48,7 @@ {{ editor.getFirstName() }} {{ editor.getLastName() }} {% if editor is not same as capsule.getCreationAuthor() %} - - <a href="{{ path('remove_editor', {'_locale': current_user.getLocale(), 'capsule_id' : capsule.getId(), 'editor_id': editor.getId()}) }}" + <a href="{{ path('remove_editor', { 'capsule_id' : capsule.getId(), 'editor_id': editor.getId()}) }}" class="remove-link"> {{ 'editors.remove.editor.link'|trans }} </a> @@ -63,8 +63,7 @@ {% for pending_editor in pending_editors %} <li class="text-secondary list-unstyled p-1"> {{ pending_editor.getEmail() }} - <a href="{{ path('remove_pending_editor', {'_locale': current_user.getLocale(), 'capsule_id' : capsule.getId(), 'pending_editor_invitation_id': pending_editor.getId()}) }}" - class="remove-link"> + <a href="{{ path('remove_editor', { 'capsule_id': capsule.getId(), 'editor_id': pending_editor.getId() }) }}" class="remove-link"> {{ 'editors.remove.pending_editor.link'|trans }} </a> </li> diff --git a/templates/capsule/editors/remove_editor.html.twig b/templates/capsule/editors/remove_editor.html.twig index ddfd703f8eebfc2dde4012ad8d5bffafd9b9b4e5..b8f32bf160065233e687d346887eddcd8c04b8fd 100644 --- a/templates/capsule/editors/remove_editor.html.twig +++ b/templates/capsule/editors/remove_editor.html.twig @@ -23,7 +23,7 @@ {{ form_start(removeEditorForm, {'attr': {novalidate: 'novalidate', 'class': 'd-flex flex-row justify-content-center'}}) }} {{ form_row(removeEditorForm.remove, {'row_attr': {'class' : 'm-auto mb-2 me-3'}}) }} - <a href="/capsule/{{ capsule_id }}/editors"> + <a href="{{ path('edit_capsule_editors', { 'capsule_id': capsule_id }) }}"> {{ form_row(removeEditorForm.cancel, {'row_attr': {'class' : 'm-auto mb-2 bg-secondary rounded ms-3'}}) }} </a> {{ form_end(removeEditorForm) }} diff --git a/templates/capsule/editors/remove_pending_editor.html.twig b/templates/capsule/editors/remove_pending_editor.html.twig index bd96a9193560995c33445dad36946b2de7114512..d1156702541071fed53588e1e63e0cc5238196cb 100644 --- a/templates/capsule/editors/remove_pending_editor.html.twig +++ b/templates/capsule/editors/remove_pending_editor.html.twig @@ -23,7 +23,7 @@ {{ form_start(removeEditorForm, {'attr': {novalidate: 'novalidate', 'class': 'd-flex flex-row justify-content-center'}}) }} {{ form_row(removeEditorForm.remove, {'row_attr': {'class' : 'm-auto mb-2 me-3'}}) }} - <a href="/capsule/{{ capsule_id }}/editors"> + <a href="{{ path('edit_capsule_editors', { 'capsule_id': capsule_id }) }}"> {{ form_row(removeEditorForm.cancel, {'row_attr': {'class' : 'm-auto mb-2 bg-secondary rounded ms-3'}}) }} </a> {{ form_end(removeEditorForm) }} diff --git a/templates/capsule/groups/capsule_groups.html.twig b/templates/capsule/groups/capsule_groups.html.twig index ebc4298a2881f46a8cca38f2f1fe3f33d353f1c9..608582f983b54d40c33bd6de8b03d5a314626008 100644 --- a/templates/capsule/groups/capsule_groups.html.twig +++ b/templates/capsule/groups/capsule_groups.html.twig @@ -44,7 +44,7 @@ {{ group.getName() }} </span> - - <a href="/capsule/{{ capsule.getId() }}/groups/{{ group.getId() }}/remove" class="remove-link"> + <a href="{{ path('remove_group', { 'capsule_id': capsule.getId(), 'group_id':group.getId() }) }}" class="remove-link"> {{ 'groups.remove.link'|trans }} </a> </li> diff --git a/templates/capsule/groups/create.html.twig b/templates/capsule/groups/create.html.twig index aa0da53e162d2c444d521ab75e5ecf514f5f6bb9..9f4c16c43662b1a9dc39c7efbdebb576379969e8 100644 --- a/templates/capsule/groups/create.html.twig +++ b/templates/capsule/groups/create.html.twig @@ -23,7 +23,8 @@ <div class="d-flex flex-column flex-sm-row justify-content-center align-items-center align-items-sm-start"> {{ form_row(createCapsuleGroupsForm.validate, {'row_attr': {'class' : 'me-sm-3 mb-3'}}) }} - <a href="/my_groups"> + <a href="{{ path('edit_user_groups') }}"> + <a href="{{ path('edit_user_groups') }}"> {{ form_row(createCapsuleGroupsForm.go_back) }} </a> </div> diff --git a/templates/capsule/groups/delete.html.twig b/templates/capsule/groups/delete.html.twig index 80dcb3e8135c58a1ae22da7886572c75900a6334..a73829063d672f73a40908487225267aad751805 100644 --- a/templates/capsule/groups/delete.html.twig +++ b/templates/capsule/groups/delete.html.twig @@ -23,7 +23,7 @@ {{ form_start(deleteGroupForm, {'attr': {novalidate: 'novalidate', 'class': 'd-flex flex-row justify-content-center'}}) }} {{ form_row(deleteGroupForm.delete, {'row_attr': {'class' : 'm-auto mb-2 me-3'}}) }} - <a href="/my_groups"> + <a href="{{ path('edit_user_groups') }}"> {{ form_row(deleteGroupForm.cancel, {'row_attr': {'class' : 'm-auto mb-2 bg-secondary rounded ms-3'}}) }} </a> {{ form_end(deleteGroupForm) }} diff --git a/templates/capsule/groups/remove.html.twig b/templates/capsule/groups/remove.html.twig index 9894b62642153b5b19f1e7aaec4e74452ca56f09..1e2df223c05565cd01f5bfd25a3822c5c1b883b0 100644 --- a/templates/capsule/groups/remove.html.twig +++ b/templates/capsule/groups/remove.html.twig @@ -23,7 +23,7 @@ {{ form_start(removeGroupForm, {'attr': {novalidate: 'novalidate', 'class': 'd-flex flex-row justify-content-center'}}) }} {{ form_row(removeGroupForm.remove, {'row_attr': {'class' : 'm-auto mb-2 me-3'}}) }} - <a href="/capsule/{{ capsule_id }}/editors"> + <a href="{{ path('edit_capsule_editors', { 'capsule_id': capsule_id }) }}"> {{ form_row(removeGroupForm.cancel, {'row_attr': {'class' : 'm-auto mb-2 bg-secondary rounded ms-3'}}) }} </a> {{ form_end(removeGroupForm) }} diff --git a/templates/capsule/groups/user_groups.html.twig b/templates/capsule/groups/user_groups.html.twig index f5a410fe80a4b512c282e234dd08384add0ca3e0..f4dcc40e353595ce3f39f63e279290595c02adad 100644 --- a/templates/capsule/groups/user_groups.html.twig +++ b/templates/capsule/groups/user_groups.html.twig @@ -43,7 +43,7 @@ {{ group.getName() }} </span> - - <a href="/my_groups/{{ group.getId() }}/delete" class="remove-link"> + <a href="{{ path('delete_group', { 'group_id': group.getId() }) }}" class="remove-link"> {{ 'general.delete'|trans }} </a> </li> @@ -54,7 +54,7 @@ </div> <div class="d-flex align-items-center mt-3 mt-md-0"> - <a href="/my_groups/create" class="btn btn-primary"> + <a href="{{ path('create_group') }}" class="btn btn-primary"> {{ 'groups.create.title'|trans }} </a> </div> diff --git a/templates/capsule/index.html.twig b/templates/capsule/index.html.twig index f3d0c508324a3b236ad12158f2f0e7d4643bbc8a..242a6fcc6e0baad08c710becfdd4e2abad63be07 100644 --- a/templates/capsule/index.html.twig +++ b/templates/capsule/index.html.twig @@ -50,7 +50,7 @@ <div class="capsule-item pb-4 col-12 col-sm-11 col-md-10 col-xxl-8"> <div class="d-flex flex-column flex-md-row justify-content-center align-items-center mt-sm-4"> <div class="list-item"> - <a href="{{ path('preview_capsule', {'_locale': current_user.getLocale(), 'path': capsule.getLinkPath()}) }}" class="capsule-title"> + <a href="{{ path('preview_capsule', { 'path': capsule.getLinkPath() } ) }}" class="capsule-title"> {{ capsule.getName() }} </a> </div> @@ -73,7 +73,7 @@ <i class="fa-thin fa-gears"></i> <div class="list-item text-nowrap"> - <a href="{{ path('edit_capsule_editors', {'_locale': current_user.getLocale(), 'capsule_id': capsule.getId()}) }}" + <a href="{{ path('edit_capsule_editors', {'capsule_id': capsule.getId()}) }}" class="links text-decoration-none"> <i class="fas fa-cog m-2"></i> {{ 'capsule.edit_permissions.link'|trans }} @@ -81,7 +81,7 @@ </div> <div class="list-item text-nowrap"> - <a href="{{ path('edit_video_url', {'_locale': current_user.getLocale(), 'capsule_id': capsule.getId()}) }}" + <a href="{{ path('edit_video_url', {'capsule_id': capsule.getId()}) }}" class="links text-decoration-none"> <i class="fas fa-link m-2"></i> {{ 'capsule.edit.video_url.link'|trans }} @@ -90,7 +90,7 @@ <div class="list-item text-nowrap"> - <a href="{{ path('edit_capsule_groups', {'_locale': current_user.getLocale(), 'capsule_id' : capsule.getId()}) }}" + <a href="{{ path('edit_capsule_groups', {'capsule_id' : capsule.getId()}) }}" class="links text-decoration-none"> <i class="fas fa-layer-group m-2"></i> {{ 'groups.edit.title'|trans({'%capsule_name%': capsule.getName()}) }} @@ -98,7 +98,7 @@ </div> <div class="list-item text-nowrap"> - <a href="{{ path('duplicate_capsule', {'_locale': current_user.getLocale(), 'capsule_id' : capsule.getId()}) }}" + <a href="{{ path('duplicate_capsule', {'capsule_id' : capsule.getId()}) }}" class="links text-decoration-none"> <i class="far fa-clone m-2"></i> {{ 'capsule.duplicate.link'|trans }} @@ -107,7 +107,7 @@ {% if capsule.getCreationauthor() is same as current_user %} <div class="list-item text-nowrap"> - <a href="{{ path('delete_capsule', {'_locale': current_user.getLocale(), 'capsule_id' : capsule.getId()}) }}" + <a href="{{ path('delete_capsule', {'capsule_id' : capsule.getId()}) }}" class="links text-decoration-none"> <i class="fas fa-trash m-2"></i> {{ 'capsule.delete.link'|trans }} @@ -115,7 +115,7 @@ </div> {% endif %} - <a href="{{ path('edit_capsule', {'_locale': current_user.getLocale(), 'path' : capsule.getLinkPath()}) }}" + <a href="{{ path('edit_capsule', {'path' : capsule.getLinkPath()}) }}" class="list-item text-nowrap lh-md"> <button class="btn btn-primary btn-lg rounded-3 col-12"> {{ 'capsule.edit.link'|trans }} diff --git a/tests/acceptance/BasePageTest.php b/tests/acceptance/BasePageTest.php new file mode 100644 index 0000000000000000000000000000000000000000..efa274c70cd388a0e1bd82627cab43f380040a25 --- /dev/null +++ b/tests/acceptance/BasePageTest.php @@ -0,0 +1,73 @@ +<?php + +namespace App\Tests\acceptance; + +use App\Entity\User; +use Symfony\Bundle\FrameworkBundle\KernelBrowser; +use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; + +abstract class BasePageTest extends WebTestCase +{ + protected KernelBrowser $client; + protected ?User $user; + + protected function givenUser(string $userName): BasePageTest + { + $object_manager = $this->client->getContainer() + ->get('doctrine') + ->getManager(); + $user_repository = $object_manager->getRepository(User::class); + $user = $user_repository + ->findOneBy(['email' => $userName ]); + + if (! $user instanceof User) { + throw new \Exception("User does not exist."); + } + + $this->user = $user; + + return $this; + } + + protected function onPage(string $uri): BasePageTest + { + $this->client->request('GET', $uri); + $this->assertResponseIsSuccessful(); + + return $this; + } + + protected function clickLink(string $linkText, ?string $errorMessageText): BasePageTest + { + $this->client->clickLink($linkText); + $this->assertResponseIsSuccessful($errorMessageText ?? ''); + + return $this; + } + + /** + * @throws \Exception the user is not initialized + */ + protected function logged(): BasePageTest + { + if (null === $this->user) { + throw new \Exception("User is not initialized."); + } + $this->client->loginUser($this->user); + + return $this; + } + + protected function setUp(): void + { + self::ensureKernelShutdown(); + + $this->client = static::createClient(); + } + + protected function tearDown(): void + { + parent::tearDown(); + self::ensureKernelShutdown(); + } +} diff --git a/tests/acceptance/CreateCapsuleGroupPageTest.php b/tests/acceptance/CreateCapsuleGroupPageTest.php new file mode 100644 index 0000000000000000000000000000000000000000..195c2199dce98b45990dcba3855dd492d427b16d --- /dev/null +++ b/tests/acceptance/CreateCapsuleGroupPageTest.php @@ -0,0 +1,36 @@ +<?php + +namespace App\Tests\acceptance; + +class CreateCapsuleGroupPageTest extends BasePageTest +{ + public function testUserShouldGoBackToUserCapsuleGroupsOnCancel(): void + { + $this->clickLink('Go back to my groups', 'The user should access to its group list'); + } + + public function testUserShouldGoBackToUserCapsuleGroups(): void + { + $this->clickLink( + 'Go back to my groups', + 'The user should access to the user capsule group from create a capsule group page' + ); + } + + protected function setUp(): void + { + parent::setUp(); + $this->setInitialPage(); + } + + private function setInitialPage(): void + { + $this->givenUser('defaultUser@localhost.com') + ->logged() + ->onPage('en/my_groups') + ->clickLink( + 'Create a new group', + 'The use should be able to access to the capsule group creation page' + ); + } +} diff --git a/tests/acceptance/DeleteCapsuleGroupPageTest.php b/tests/acceptance/DeleteCapsuleGroupPageTest.php new file mode 100644 index 0000000000000000000000000000000000000000..0dd05da29496ac1f5bc291e6a9d3abb596c37c68 --- /dev/null +++ b/tests/acceptance/DeleteCapsuleGroupPageTest.php @@ -0,0 +1,33 @@ +<?php + +namespace App\Tests\acceptance; + +class DeleteCapsuleGroupPageTest extends BasePageTest +{ + public function testUserShouldAllowCancelGroupDeletion(): void + { + $this->clickLink( + 'Cancel', + 'The user should be able to delete one group from the user the capsule groups page' + ); + } + + public function testUserShouldBeRedirectedToTheCapsuleGroupListOnCancelGroupDeletion(): void + { + $this->clickLink('Cancel', 'The user should be able to cancel capsule group deletion'); + } + + protected function setUp(): void + { + parent::setUp(); + $this->setInitialPage(); + } + + private function setInitialPage(): void + { + $this->givenUser('defaultUser@localhost.com') + ->logged() + ->onPage('en/my_groups') + ->clickLink('Delete', 'The user should access to a capsule group deletion page'); + } +} diff --git a/tests/acceptance/IndexPageTest.php b/tests/acceptance/IndexPageTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b7c3381f273a1d38f5ea8f55cfcb534a25e43a15 --- /dev/null +++ b/tests/acceptance/IndexPageTest.php @@ -0,0 +1,27 @@ +<?php + +namespace App\Tests\acceptance; + +class IndexPageTest extends BasePageTest +{ + public function testUserShoudAccessToCapsuleGroupList(): void + { + $this->clickLink( + 'My groups', + 'The user should access to its group list from index page' + ); + } + + protected function setUp(): void + { + parent::setUp(); + $this->setInitialPage(); + } + + private function setInitialPage(): void + { + $this->givenUser('defaultUser@localhost.com') + ->logged() + ->onPage('en'); + } +} diff --git a/tests/acceptance/UserCapsuleGroupsPageTest.php b/tests/acceptance/UserCapsuleGroupsPageTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d56bfc283604752c3a1d05ad781104a86654aacd --- /dev/null +++ b/tests/acceptance/UserCapsuleGroupsPageTest.php @@ -0,0 +1,34 @@ +<?php + +namespace App\Tests\acceptance; + +class UserCapsuleGroupsPageTest extends BasePageTest +{ + public function testUserShouldAccessToCapsuleGroupCreationPage(): void + { + $this->client->clickLink('Create a new group'); + $this->assertResponseIsSuccessful('The user should access capsule group creation'); + } + + public function testUserShouldAccessDeleteGroupPageFromUserCapsuleGroupList(): void + { + $this->clickLink('Delete', 'The user should access to its capsule groups list'); + $this->assertResponseIsSuccessful( + 'The user should be able to delete one group from the user the capsule groups page' + ); + } + + protected function setUp(): void + { + parent::setUp(); + $this->setCapsuleGroupPage(); + } + + private function setCapsuleGroupPage(): void + { + $this->givenUser('defaultUser@localhost.com') + ->logged() + ->onPage('en/my_groups'); + $this->assertResponseIsSuccessful(); + } +} diff --git a/tests/functional/CapsuleGroupControllerTest.php b/tests/functional/CapsuleGroupControllerTest.php index 9ebea5b10547933bad422fac6aac4b5686b9933f..c66655ec89ab01f81d08ea03fd271efef29e7a7a 100644 --- a/tests/functional/CapsuleGroupControllerTest.php +++ b/tests/functional/CapsuleGroupControllerTest.php @@ -24,31 +24,6 @@ class CapsuleGroupControllerTest extends WebTestCase private Group $group_pop_own_by_user_1; private Group $group_rock_own_by_user_1; - protected function setUp(): void - { - self::ensureKernelShutdown(); - - $this->client = static::createClient(); - - $this->object_manager = $this->client->getContainer() - ->get('doctrine') - ->getManager(); - - $this->user_repository = $this->object_manager->getRepository(User::class); - $this->capsule_repository = $this->object_manager->getRepository(Capsule::class); - $this->group_repository = $this->object_manager->getRepository(Group::class); - - $this->setUsers(); - $this->setCapsuleGroupPop(); - $this->setCapsuleGroupRock(); - } - - protected function tearDown(): void - { - parent::tearDown(); - self::ensureKernelShutdown(); - } - public function testUserShouldNotBeAbleToCreateACapsuleGroupWithExistingGroupName(): void { $this->client->loginUser($this->user_1); @@ -85,6 +60,25 @@ class CapsuleGroupControllerTest extends WebTestCase $this->assertTrue($this->client->getResponse()->isRedirect()); } + protected function setUp(): void + { + self::ensureKernelShutdown(); + + $this->client = static::createClient(); + + $this->object_manager = $this->client->getContainer() + ->get('doctrine') + ->getManager(); + + $this->user_repository = $this->object_manager->getRepository(User::class); + $this->capsule_repository = $this->object_manager->getRepository(Capsule::class); + $this->group_repository = $this->object_manager->getRepository(Group::class); + + $this->setUsers(); + $this->setCapsuleGroupPop(); + $this->setCapsuleGroupRock(); + } + private function setUsers(): void { $verified_user_1 = $this->user_repository @@ -127,4 +121,10 @@ class CapsuleGroupControllerTest extends WebTestCase $this->group_rock_own_by_user_1 = $group_rock; } + + protected function tearDown(): void + { + parent::tearDown(); + self::ensureKernelShutdown(); + } }