-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
314 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
framework: | ||
default_locale: '%env(APP_LOCALE)%' | ||
translator: | ||
default_path: '%kernel.project_dir%/translations' | ||
fallbacks: | ||
- en | ||
providers: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
sylius: | ||
form: | ||
login: | ||
username: 'Identifiant' | ||
password: 'Mot de passe' | ||
remember_me: 'Rester connecté' | ||
ui: | ||
actions: 'Actions' | ||
add_new_entry: 'Nouvel item' | ||
administration_panel_login: 'Connexion à l''espace d''administration' | ||
all: 'Tous' | ||
are_your_sure_you_want_to_perform_this_action: 'Êtes-vous sûr de vouloir effectuer cette action ?' | ||
cancel: 'Annuler' | ||
contains: 'Contient' | ||
create: 'Créer' | ||
dashboard: 'Tableau de bord' | ||
date_filter: '%label% | %altLabel%' | ||
delete: 'Supprimer' | ||
details: 'Détails' | ||
edit: 'Modifier' | ||
error: 'Erreur' | ||
filter: 'Filtrer' | ||
filters: 'Filtres' | ||
from: 'De' | ||
hello: 'Bonjour' | ||
info: 'Info' | ||
login: 'Connexion' | ||
login_to_your_account: 'Connection à votre compte' | ||
logout: 'Déconnexion' | ||
new: 'Nouveau' | ||
no_label: 'Non' | ||
no_results: 'Aucun résultat' | ||
no_results_adjust_your_search: 'Modifie ta recherche et réessaie' | ||
pagination: | ||
number_of_results: 'Affiche de %from à %to sur %total% items' | ||
reset: 'Réinitialiser' | ||
search: 'Rechercher' | ||
search_menu: 'Recherche menu' | ||
show: 'Afficher' | ||
success: 'Succès' | ||
this_form_contains_errors: 'Ce formulaire contient des erreurs.' | ||
to: 'À' | ||
update: 'Mise à jour' | ||
value: 'Valeur' | ||
warning: 'Avertissement' | ||
yes_label: 'Oui' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,193 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MainTests\Sylius\Translations; | ||
|
||
use App\Entity\Book; | ||
use App\Factory\BookFactory; | ||
use App\Factory\UserFactory; | ||
use Symfony\Bundle\FrameworkBundle\KernelBrowser; | ||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Zenstruck\Foundry\Persistence\Proxy; | ||
use Zenstruck\Foundry\Test\Factories; | ||
use Zenstruck\Foundry\Test\ResetDatabase; | ||
|
||
final class FrenchTranslatedUiTest extends WebTestCase | ||
{ | ||
Use Factories; | ||
use ResetDatabase; | ||
use MarkTestSkippedTrait; | ||
|
||
private KernelBrowser $client; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->client = static::createClient(); | ||
|
||
$user = UserFactory::new() | ||
->admin() | ||
->create() | ||
; | ||
|
||
$this->client->loginUser($user->_real()); | ||
} | ||
|
||
public function testShowItem(): void | ||
{ | ||
$this->markTestSkippedIfNecessary('fr'); | ||
|
||
$book = BookFactory::new() | ||
->withTitle('Shinning') | ||
->withAuthorName('Stephen King') | ||
->create() | ||
; | ||
|
||
$this->client->request('GET', sprintf('/admin/books/%s', $book->getId())); | ||
|
||
self::assertResponseIsSuccessful(); | ||
|
||
// Validate Header | ||
self::assertSelectorTextContains('h1.page-title', 'Afficher Livre'); | ||
} | ||
|
||
public function testBrowsingItems(): void | ||
{ | ||
$this->markTestSkippedIfNecessary('fr'); | ||
|
||
BookFactory::new() | ||
->withTitle('Shinning') | ||
->withAuthorName('Stephen King') | ||
->create() | ||
; | ||
|
||
BookFactory::new() | ||
->withTitle('Carrie') | ||
->withAuthorName('Stephen King') | ||
->create() | ||
; | ||
|
||
$this->client->request('GET', '/admin/books'); | ||
|
||
self::assertResponseIsSuccessful(); | ||
|
||
// Validate Header | ||
self::assertSelectorTextContains('h1.page-title', 'Livres'); | ||
|
||
// Validate Table header | ||
self::assertSelectorTextContains('.sylius-table-column-title', 'Titre'); | ||
self::assertSelectorTextContains('.sylius-table-column-authorName', 'Auteur'); | ||
self::assertSelectorTextContains('.sylius-table-column-actions', 'Actions'); | ||
} | ||
|
||
public function testAddingNewItem(): void | ||
{ | ||
$this->markTestSkippedIfNecessary('fr'); | ||
|
||
$this->client->request('GET', '/admin/books/new'); | ||
|
||
$this->client->submitForm('Créer', [ | ||
'sylius_resource[title]' => 'Shinning', | ||
'sylius_resource[authorName]' => 'Stephen King', | ||
]); | ||
|
||
self::assertResponseRedirects(expectedCode: Response::HTTP_FOUND); | ||
|
||
$this->client->request('GET', '/admin/books'); | ||
|
||
// Test flash message | ||
self::assertSelectorTextContains('[data-test-sylius-flash-message]', 'Book a bien été créé.'); | ||
} | ||
|
||
public function testValidationErrorsWhenAddingNewItem(): void | ||
{ | ||
$this->markTestSkippedIfNecessary('fr'); | ||
|
||
$this->client->request('GET', '/admin/books/new'); | ||
$this->client->submitForm('Créer', [ | ||
'sylius_resource[title]' => null, | ||
'sylius_resource[authorName]' => null, | ||
]); | ||
|
||
self::assertResponseStatusCodeSame(Response::HTTP_UNPROCESSABLE_ENTITY); | ||
self::assertSelectorTextContains('[data-test-form-error-alert] .alert-title', 'Erreur'); | ||
self::assertSelectorTextContains('[data-test-form-error-alert] .text-secondary', 'Ce formulaire contient des erreurs.'); | ||
self::assertSelectorTextContains('#sylius_resource_title + .invalid-feedback', 'Cette valeur ne doit pas être vide.'); | ||
self::assertSelectorTextContains('#sylius_resource_authorName + .invalid-feedback', 'Cette valeur ne doit pas être vide.'); | ||
} | ||
|
||
public function testEditingItem(): void | ||
{ | ||
$this->markTestSkippedIfNecessary('fr'); | ||
|
||
$book = BookFactory::new() | ||
->withTitle('Shinning') | ||
->withAuthorName('Stephen King') | ||
->create(); | ||
|
||
$this->client->request('GET', sprintf('/admin/books/%s/edit', $book->getId())); | ||
|
||
$this->client->submitForm('Mise à jour', [ | ||
'sylius_resource[title]' => 'Carrie', | ||
'sylius_resource[authorName]' => 'Stephen King', | ||
]); | ||
|
||
self::assertResponseRedirects(expectedCode: Response::HTTP_FOUND); | ||
|
||
$this->client->request('GET', '/admin/books'); | ||
|
||
// Test flash message | ||
self::assertSelectorTextContains('[data-test-sylius-flash-message]', 'Book a bien été mis à jour.'); | ||
|
||
/** @var Proxy<Book> $book */ | ||
$book = BookFactory::find(['title' => 'Carrie']); | ||
|
||
self::assertSame('Carrie', $book->getTitle()); | ||
self::assertSame('Stephen King', $book->getAuthorName()); | ||
} | ||
|
||
public function testValidationErrorsWhenEditingItem(): void | ||
{ | ||
$this->markTestSkippedIfNecessary('fr'); | ||
|
||
$book = BookFactory::new() | ||
->withTitle('Shinning') | ||
->withAuthorName('Stephen King') | ||
->create(); | ||
|
||
$this->client->request('GET', sprintf('/admin/books/%s/edit', $book->getId())); | ||
$this->client->submitForm('Mise à jour', [ | ||
'sylius_resource[title]' => null, | ||
'sylius_resource[authorName]' => null, | ||
]); | ||
|
||
self::assertResponseStatusCodeSame(Response::HTTP_UNPROCESSABLE_ENTITY); | ||
self::assertSelectorTextContains('[data-test-form-error-alert] .alert-title', 'Erreur'); | ||
self::assertSelectorTextContains('[data-test-form-error-alert] .text-secondary', 'Ce formulaire contient des erreurs.'); | ||
self::assertSelectorTextContains('#sylius_resource_title + .invalid-feedback', 'Cette valeur ne doit pas être vide.'); | ||
self::assertSelectorTextContains('#sylius_resource_authorName + .invalid-feedback', 'Cette valeur ne doit pas être vide.'); | ||
} | ||
|
||
public function testRemovingItem(): void | ||
{ | ||
$this->markTestSkippedIfNecessary('fr'); | ||
|
||
BookFactory::new() | ||
->withTitle('Shinning') | ||
->withAuthorName('Stephen King') | ||
->create(); | ||
|
||
$this->client->request('GET', '/admin/books'); | ||
$deleteButton = $this->client->getCrawler()->filter('tr.item:first-child [data-test-confirm-button]'); | ||
|
||
$this->client->submit($deleteButton->form()); | ||
|
||
self::assertResponseRedirects(); | ||
|
||
$this->client->request('GET', '/admin/books'); | ||
|
||
// Test flash message | ||
self::assertSelectorTextContains('[data-test-sylius-flash-message]', 'Book a bien été supprimé.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace MainTests\Sylius\Translations; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; | ||
|
||
/** | ||
* @mixin KernelTestCase | ||
*/ | ||
trait MarkTestSkippedTrait | ||
{ | ||
private function markTestSkippedIfNecessary(string $locale): void | ||
{ | ||
if ($this->getContainer()->getParameter('kernel.default_locale') !== $locale) { | ||
$this->markTestSkipped(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.