Skip to content
Snippets Groups Projects
Commit dfd4c2f8 authored by Sebastien's avatar Sebastien
Browse files

Fix path on pages + Add test for navigation

parent ceda32be
No related branches found
No related tags found
1 merge request!89Tuleap 203 not able to open capsule preview from capsule edition
Pipeline #1027 passed
Showing
with 268 additions and 54 deletions
...@@ -12,10 +12,12 @@ use App\Form\SelectCapsuleGroupsFormType; ...@@ -12,10 +12,12 @@ use App\Form\SelectCapsuleGroupsFormType;
use App\Repository\CapsuleRepository; use App\Repository\CapsuleRepository;
use App\Repository\GroupRepository; use App\Repository\GroupRepository;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Exception;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
...@@ -41,7 +43,7 @@ class CapsuleGroupController extends AbstractController ...@@ -41,7 +43,7 @@ class CapsuleGroupController extends AbstractController
$groups = $current_user->getGroups()->toArray(); $groups = $current_user->getGroups()->toArray();
return $this->render('capsule/groups/user_groups.html.twig', [ return $this->render('capsule/groups/user_groups.html.twig', [
'groups' => $groups 'groups' => $groups,
]); ]);
} }
...@@ -77,10 +79,13 @@ class CapsuleGroupController extends AbstractController ...@@ -77,10 +79,13 @@ class CapsuleGroupController extends AbstractController
} }
return $this->renderForm('capsule/groups/create.html.twig', [ 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')] #[Route('/{_locale<%app.supported_locales%>}/my_groups/{group_id}/delete', name:'delete_group')]
public function deleteGroup(int $group_id, Request $request): Response public function deleteGroup(int $group_id, Request $request): Response
{ {
...@@ -91,7 +96,7 @@ class CapsuleGroupController extends AbstractController ...@@ -91,7 +96,7 @@ class CapsuleGroupController extends AbstractController
$group = $this->group_repository->findOneBy(['id' => $group_id]); $group = $this->group_repository->findOneBy(['id' => $group_id]);
if (! $group instanceof Group) { if (! $group instanceof Group) {
throw new \Exception('Group not found'); throw new Exception('Group not found');
} }
$form = $this->createForm(DeleteGroupFormType::class); $form = $this->createForm(DeleteGroupFormType::class);
...@@ -125,10 +130,13 @@ class CapsuleGroupController extends AbstractController ...@@ -125,10 +130,13 @@ class CapsuleGroupController extends AbstractController
return $this->renderForm('capsule/groups/delete.html.twig', [ return $this->renderForm('capsule/groups/delete.html.twig', [
'deleteGroupForm' => $form, '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')] #[Route('/{_locale<%app.supported_locales%>}/capsule/{capsule_id}/groups/edit', name:'edit_capsule_groups')]
public function edit(int $capsule_id, Request $request): Response public function edit(int $capsule_id, Request $request): Response
{ {
...@@ -141,7 +149,7 @@ class CapsuleGroupController extends AbstractController ...@@ -141,7 +149,7 @@ class CapsuleGroupController extends AbstractController
$capsule = $this->capsule_repository->findOneBy(['id' => $capsule_id]); $capsule = $this->capsule_repository->findOneBy(['id' => $capsule_id]);
if (! $capsule instanceof Capsule) { 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); $capsule_groups_by_author = $current_user->getGroupsByCapsule($capsule);
...@@ -174,7 +182,7 @@ class CapsuleGroupController extends AbstractController ...@@ -174,7 +182,7 @@ class CapsuleGroupController extends AbstractController
); );
return $this->redirectToRoute('edit_capsule_groups', [ return $this->redirectToRoute('edit_capsule_groups', [
'capsule_id' => $capsule_id 'capsule_id' => $capsule_id,
]); ]);
} }
...@@ -186,6 +194,9 @@ class CapsuleGroupController extends AbstractController ...@@ -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')] #[Route('/{_locale<%app.supported_locales%>}/capsule/{capsule_id}/groups/{group_id}/remove', name:'remove_group')]
public function remove( public function remove(
int $capsule_id, int $capsule_id,
...@@ -194,12 +205,12 @@ class CapsuleGroupController extends AbstractController ...@@ -194,12 +205,12 @@ class CapsuleGroupController extends AbstractController
): Response { ): Response {
$capsule = $this->capsule_repository->findOneBy(['id' => $capsule_id]); $capsule = $this->capsule_repository->findOneBy(['id' => $capsule_id]);
if (! $capsule instanceof Capsule) { if (! $capsule instanceof Capsule) {
throw new \Exception('Capsule not found'); throw new Exception('Capsule not found');
} }
$group = $this->group_repository->findOneBy(['id' => $group_id]); $group = $this->group_repository->findOneBy(['id' => $group_id]);
if (! $group instanceof Group) { if (! $group instanceof Group) {
throw new \Exception('Group not found'); throw new Exception('Group not found');
} }
$current_user = $this->getUser(); $current_user = $this->getUser();
...@@ -238,7 +249,7 @@ class CapsuleGroupController extends AbstractController ...@@ -238,7 +249,7 @@ class CapsuleGroupController extends AbstractController
return $this->renderForm('capsule/groups/remove.html.twig', [ return $this->renderForm('capsule/groups/remove.html.twig', [
'removeGroupForm' => $form, 'removeGroupForm' => $form,
'group_name' => $group->getName(), 'group_name' => $group->getName(),
'capsule_id' => $capsule_id 'capsule_id' => $capsule_id,
]); ]);
} }
...@@ -254,7 +265,7 @@ class CapsuleGroupController extends AbstractController ...@@ -254,7 +265,7 @@ class CapsuleGroupController extends AbstractController
$group_db = $this->group_repository->findOneBy(['id' => $group_data->getId()]); $group_db = $this->group_repository->findOneBy(['id' => $group_data->getId()]);
if (! $group_db instanceof Group) { if (! $group_db instanceof Group) {
throw new \Exception('Group not found'); throw new Exception('Group not found');
} }
$groups[] = $group_db; $groups[] = $group_db;
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
{{ form_start(deleteCapsuleForm, {'attr': {novalidate: 'novalidate', 'class': 'd-flex flex-row justify-content-center'}}) }} {{ 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'}}) }} {{ 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'}}) }} {{ form_row(deleteCapsuleForm.cancel, {'row_attr': {'class' : 'm-auto mb-2 bg-secondary rounded ms-3'}}) }}
</a> </a>
{{ form_end(deleteCapsuleForm) }} {{ form_end(deleteCapsuleForm) }}
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
{{ editor.getFirstName() }} {{ editor.getLastName() }} {{ editor.getFirstName() }} {{ editor.getLastName() }}
{% if editor is not same as capsule.getCreationAuthor() %} {% 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"> class="remove-link">
{{ 'editors.remove.editor.link'|trans }} {{ 'editors.remove.editor.link'|trans }}
</a> </a>
...@@ -63,8 +63,7 @@ ...@@ -63,8 +63,7 @@
{% for pending_editor in pending_editors %} {% for pending_editor in pending_editors %}
<li class="text-secondary list-unstyled p-1"> <li class="text-secondary list-unstyled p-1">
{{ pending_editor.getEmail() }} {{ pending_editor.getEmail() }}
<a href="{{ path('remove_pending_editor', {'_locale': current_user.getLocale(), 'capsule_id' : capsule.getId(), 'pending_editor_invitation_id': pending_editor.getId()}) }}" <a href="{{ path('remove_editor', { 'capsule_id': capsule.getId(), 'editor_id': pending_editor.getId() }) }}" class="remove-link">
class="remove-link">
{{ 'editors.remove.pending_editor.link'|trans }} {{ 'editors.remove.pending_editor.link'|trans }}
</a> </a>
</li> </li>
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
{{ form_start(removeEditorForm, {'attr': {novalidate: 'novalidate', 'class': 'd-flex flex-row justify-content-center'}}) }} {{ 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'}}) }} {{ 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'}}) }} {{ form_row(removeEditorForm.cancel, {'row_attr': {'class' : 'm-auto mb-2 bg-secondary rounded ms-3'}}) }}
</a> </a>
{{ form_end(removeEditorForm) }} {{ form_end(removeEditorForm) }}
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
{{ form_start(removeEditorForm, {'attr': {novalidate: 'novalidate', 'class': 'd-flex flex-row justify-content-center'}}) }} {{ 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'}}) }} {{ 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'}}) }} {{ form_row(removeEditorForm.cancel, {'row_attr': {'class' : 'm-auto mb-2 bg-secondary rounded ms-3'}}) }}
</a> </a>
{{ form_end(removeEditorForm) }} {{ form_end(removeEditorForm) }}
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
{{ group.getName() }} {{ group.getName() }}
</span> </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 }} {{ 'groups.remove.link'|trans }}
</a> </a>
</li> </li>
......
...@@ -23,7 +23,8 @@ ...@@ -23,7 +23,8 @@
<div class="d-flex flex-column flex-sm-row justify-content-center align-items-center align-items-sm-start"> <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'}}) }} {{ 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) }} {{ form_row(createCapsuleGroupsForm.go_back) }}
</a> </a>
</div> </div>
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
{{ form_start(deleteGroupForm, {'attr': {novalidate: 'novalidate', 'class': 'd-flex flex-row justify-content-center'}}) }} {{ 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'}}) }} {{ 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'}}) }} {{ form_row(deleteGroupForm.cancel, {'row_attr': {'class' : 'm-auto mb-2 bg-secondary rounded ms-3'}}) }}
</a> </a>
{{ form_end(deleteGroupForm) }} {{ form_end(deleteGroupForm) }}
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
{{ form_start(removeGroupForm, {'attr': {novalidate: 'novalidate', 'class': 'd-flex flex-row justify-content-center'}}) }} {{ 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'}}) }} {{ 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'}}) }} {{ form_row(removeGroupForm.cancel, {'row_attr': {'class' : 'm-auto mb-2 bg-secondary rounded ms-3'}}) }}
</a> </a>
{{ form_end(removeGroupForm) }} {{ form_end(removeGroupForm) }}
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
{{ group.getName() }} {{ group.getName() }}
</span> </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 }} {{ 'general.delete'|trans }}
</a> </a>
</li> </li>
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
</div> </div>
<div class="d-flex align-items-center mt-3 mt-md-0"> <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 }} {{ 'groups.create.title'|trans }}
</a> </a>
</div> </div>
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
<div class="capsule-item pb-4 col-12 col-sm-11 col-md-10 col-xxl-8"> <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="d-flex flex-column flex-md-row justify-content-center align-items-center mt-sm-4">
<div class="list-item"> <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() }} {{ capsule.getName() }}
</a> </a>
</div> </div>
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
<i class="fa-thin fa-gears"></i> <i class="fa-thin fa-gears"></i>
<div class="list-item text-nowrap"> <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"> class="links text-decoration-none">
<i class="fas fa-cog m-2"></i> <i class="fas fa-cog m-2"></i>
{{ 'capsule.edit_permissions.link'|trans }} {{ 'capsule.edit_permissions.link'|trans }}
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
</div> </div>
<div class="list-item text-nowrap"> <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"> class="links text-decoration-none">
<i class="fas fa-link m-2"></i> <i class="fas fa-link m-2"></i>
{{ 'capsule.edit.video_url.link'|trans }} {{ 'capsule.edit.video_url.link'|trans }}
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
<div class="list-item text-nowrap"> <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"> class="links text-decoration-none">
<i class="fas fa-layer-group m-2"></i> <i class="fas fa-layer-group m-2"></i>
{{ 'groups.edit.title'|trans({'%capsule_name%': capsule.getName()}) }} {{ 'groups.edit.title'|trans({'%capsule_name%': capsule.getName()}) }}
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
</div> </div>
<div class="list-item text-nowrap"> <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"> class="links text-decoration-none">
<i class="far fa-clone m-2"></i> <i class="far fa-clone m-2"></i>
{{ 'capsule.duplicate.link'|trans }} {{ 'capsule.duplicate.link'|trans }}
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
{% if capsule.getCreationauthor() is same as current_user %} {% if capsule.getCreationauthor() is same as current_user %}
<div class="list-item text-nowrap"> <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"> class="links text-decoration-none">
<i class="fas fa-trash m-2"></i> <i class="fas fa-trash m-2"></i>
{{ 'capsule.delete.link'|trans }} {{ 'capsule.delete.link'|trans }}
...@@ -115,7 +115,7 @@ ...@@ -115,7 +115,7 @@
</div> </div>
{% endif %} {% 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"> class="list-item text-nowrap lh-md">
<button class="btn btn-primary btn-lg rounded-3 col-12"> <button class="btn btn-primary btn-lg rounded-3 col-12">
{{ 'capsule.edit.link'|trans }} {{ 'capsule.edit.link'|trans }}
......
<?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();
}
}
<?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'
);
}
}
<?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');
}
}
<?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');
}
}
<?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();
}
}
...@@ -24,31 +24,6 @@ class CapsuleGroupControllerTest extends WebTestCase ...@@ -24,31 +24,6 @@ class CapsuleGroupControllerTest extends WebTestCase
private Group $group_pop_own_by_user_1; private Group $group_pop_own_by_user_1;
private Group $group_rock_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 public function testUserShouldNotBeAbleToCreateACapsuleGroupWithExistingGroupName(): void
{ {
$this->client->loginUser($this->user_1); $this->client->loginUser($this->user_1);
...@@ -85,6 +60,25 @@ class CapsuleGroupControllerTest extends WebTestCase ...@@ -85,6 +60,25 @@ class CapsuleGroupControllerTest extends WebTestCase
$this->assertTrue($this->client->getResponse()->isRedirect()); $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 private function setUsers(): void
{ {
$verified_user_1 = $this->user_repository $verified_user_1 = $this->user_repository
...@@ -127,4 +121,10 @@ class CapsuleGroupControllerTest extends WebTestCase ...@@ -127,4 +121,10 @@ class CapsuleGroupControllerTest extends WebTestCase
$this->group_rock_own_by_user_1 = $group_rock; $this->group_rock_own_by_user_1 = $group_rock;
} }
protected function tearDown(): void
{
parent::tearDown();
self::ensureKernelShutdown();
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment