Skip to content

Commit

Permalink
tests only and exclude parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
gpibarra committed Apr 25, 2024
1 parent 4d5dc8d commit 69d4587
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 2 deletions.
36 changes: 34 additions & 2 deletions tests/Commands/FindMissingTranslationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function it_does_not_report_about_synchronized_files(): void
{
$this->withoutMockingConsoleOutput();

$dir = __DIR__.'/sync_lang_files';
$dir = __DIR__ . '/sync_lang_files';
$exitCode = $this->artisan("translations:missing --dir=$dir --base=en");
$output = Artisan::output();

Expand All @@ -28,11 +28,43 @@ public function it_reports_about_missing_translation_keys(): void
{
$this->withoutMockingConsoleOutput();

$dir = __DIR__.'/unsync_lang_files';
$dir = __DIR__ . '/unsync_lang_files';
$exitCode = $this->artisan("translations:missing --dir=$dir --base=en");
$output = Artisan::output();

$this->assertSame(1, $exitCode);
$this->assertStringContainsString('| be | a.php | OK |', $output);
$this->assertStringContainsString('| es | a.php | OK |', $output);
$this->assertStringContainsString('| fr | a.php | OK |', $output);
}

#[Test]
public function it_reports_about_missing_translation_keys_only_lang(): void
{
$this->withoutMockingConsoleOutput();

$dir = __DIR__ . '/unsync_lang_files';
$exitCode = $this->artisan("translations:missing --dir=$dir --base=en --only=be,es");
$output = Artisan::output();

$this->assertSame(1, $exitCode);
$this->assertStringContainsString('| be | a.php | OK |', $output);
$this->assertStringContainsString('| es | a.php | OK |', $output);
$this->assertStringNotContainsString('| fr | a.php | OK |', $output);
}

#[Test]
public function it_reports_about_missing_translation_keys_exclude_lang(): void
{
$this->withoutMockingConsoleOutput();

$dir = __DIR__ . '/unsync_lang_files';
$exitCode = $this->artisan("translations:missing --dir=$dir --base=en --exclude=be,fr");
$output = Artisan::output();

$this->assertSame(1, $exitCode);
$this->assertStringNotContainsString('| be | a.php | OK |', $output);
$this->assertStringContainsString('| es | a.php | OK |', $output);
$this->assertStringNotContainsString('| fr | a.php | OK |', $output);
}
}
9 changes: 9 additions & 0 deletions tests/Commands/sync_lang_files/es/a.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

return [
'Yes' => 'Si',

'group' => [
'Help' => 'Ayuda',
],
];
9 changes: 9 additions & 0 deletions tests/Commands/sync_lang_files/fr/a.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

return [
'Yes' => 'Oui',

'group' => [
'Help' => 'Aide',
],
];
9 changes: 9 additions & 0 deletions tests/Commands/unsync_lang_files/es/a.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

return [
'Yes' => 'Si',
'No' => 'No',
// 'OK' => 'OK', missing key

// 'group' => [], // missing group
];
10 changes: 10 additions & 0 deletions tests/Commands/unsync_lang_files/fr/a.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

return [
#en frances
'Yes' => 'Oui',
'No' => 'Non',
// 'OK' => 'OK', missing key

// 'group' => [], // missing group
];

0 comments on commit 69d4587

Please sign in to comment.