Skip to content

Commit

Permalink
Renamed create mock translator. Added unit tests for listeners.
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentmuller committed Jun 12, 2024
1 parent 0a59f9e commit 5d7444e
Show file tree
Hide file tree
Showing 38 changed files with 1,060 additions and 55 deletions.
26 changes: 13 additions & 13 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/Captcha/AlphaCaptchaTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ abstract class AlphaCaptchaTestCase extends TestCase
protected function setUp(): void
{
$letters = \implode('', \range('A', 'Z'));
$this->translator = $this->createTranslator();
$this->translator = $this->createMockTranslator();
$this->service = $this->createMock(DictionaryService::class);
$this->service->expects(self::any())
->method('getRandomWord')
Expand Down
2 changes: 1 addition & 1 deletion tests/Chart/MonthChartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected function setUp(): void
$this->repository = $this->createMock(CalculationRepository::class);
$this->generator = $this->createMock(UrlGeneratorInterface::class);
$this->twig = $this->createMock(Environment::class);
$this->translator = $this->createTranslator();
$this->translator = $this->createMockTranslator();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Chart/StateChartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected function setUp(): void
$this->repository = $this->createMock(CalculationStateRepository::class);
$this->generator = $this->createMock(UrlGeneratorInterface::class);
$this->twig = $this->createMock(Environment::class);
$this->translator = $this->createTranslator();
$this->translator = $this->createMockTranslator();
}

public function testWithoutData(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/Controller/CaptchaControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private function createService(
private function getController(): CaptchaController
{
$controller = $this->getService(CaptchaController::class);
$controller->setTranslator($this->createTranslator());
$controller->setTranslator($this->createMockTranslator());

return $controller;
}
Expand Down
Binary file added tests/Data/images/user_example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/Enums/EntityActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function testSorted(): void
#[DataProvider('getLabel')]
public function testTranslate(string $expected, EntityAction $action): void
{
$translator = $this->createTranslator();
$translator = $this->createMockTranslator();
$actual = $action->trans($translator);
self::assertSame($expected, $actual);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Enums/EntityNameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public function testSorted(): void
#[DataProvider('getLabel')]
public function testTranslate(string $expected, EntityName $entity): void
{
$translator = $this->createTranslator();
$translator = $this->createMockTranslator();
$actual = $entity->trans($translator);
self::assertSame($expected, $actual);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Enums/EntityPermissionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function testSum(): void
#[DataProvider('getLabel')]
public function testTranslate(EntityPermission $permission, string $expected): void
{
$translator = $this->createTranslator();
$translator = $this->createMockTranslator();
$actual = $permission->trans($translator);
self::assertSame($expected, $actual);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Enums/EnvironmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function testLabel(Environment $environment, string $expected): void
#[DataProvider('getLabels')]
public function testTranslate(Environment $environment, string $expected): void
{
$translator = $this->createTranslator();
$translator = $this->createMockTranslator();
$actual = $environment->trans($translator);
self::assertSame($expected, $actual);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Enums/FlashTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function testStyle(FlashType $type, string $expected): void
#[DataProvider('getLabels')]
public function testTranslate(FlashType $type, string $expected): void
{
$translator = $this->createTranslator();
$translator = $this->createMockTranslator();
$actual = $type->trans($translator);
self::assertSame($expected, $actual);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Enums/ImportanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function testSorted(): void
#[DataProvider('getLabels')]
public function testTranslate(string $expected, Importance $importance): void
{
$translator = $this->createTranslator();
$translator = $this->createMockTranslator();
$actual = $importance->trans($translator);
self::assertSame($expected, $actual);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Enums/MessagePositionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function testSorted(): void
#[DataProvider('getTranslation')]
public function testTranslate(MessagePosition $position, string $expected): void
{
$translator = $this->createTranslator();
$translator = $this->createMockTranslator();
$actual = $position->trans($translator);
self::assertSame($expected, $actual);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Enums/StrengthLevelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function testSorted(): void
#[DataProvider('getLabels')]
public function testTranslate(string $expected, StrengthLevel $level): void
{
$translator = $this->createTranslator();
$translator = $this->createMockTranslator();
$actual = $level->trans($translator);
self::assertSame($expected, $actual);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Enums/TableViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function testSorted(): void

public function testTranslate(): void
{
$translator = $this->createTranslator();
$translator = $this->createMockTranslator();
self::assertSame('table_view.custom', TableView::CUSTOM->trans($translator));
self::assertSame('table_view.table', TableView::TABLE->trans($translator));
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Enums/ThemeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public function testTitle(Theme $theme, string $expected): void
#[DataProvider('getTranslates')]
public function testTranslate(Theme $theme, string $expected): void
{
$translator = $this->createTranslator();
$translator = $this->createMockTranslator();
$actual = $theme->trans($translator);
self::assertSame($expected, $actual);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Listener/LoginListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private function createListener(): LoginListener
{
$repository = $this->createMock(UserRepository::class);
$listener = new LoginListener($repository, 'Calculation');
$listener->setTranslator($this->createTranslator());
$listener->setTranslator($this->createMockTranslator());
$listener->setRequestStack($this->createRequestStack());

return $listener;
Expand Down
Loading

0 comments on commit 5d7444e

Please sign in to comment.