Skip to content

Commit a02f1d6

Browse files
committed
add test
1 parent 58a8799 commit a02f1d6

File tree

4 files changed

+57
-23
lines changed

4 files changed

+57
-23
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
7070
"@php artisan migrate --graceful --ansi"
7171
],
72-
"test": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --colors=always"
72+
"test": "@php artisan test"
7373
},
7474
"extra": {
7575
"laravel": {

tests/Feature/ExampleTest.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

tests/Feature/HomePageTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Tests\Feature;
6+
7+
// use Illuminate\Foundation\Testing\RefreshDatabase;
8+
9+
use PHPUnit\Framework\Attributes\DataProvider;
10+
use Tests\TestCase;
11+
12+
class HomePageTest extends TestCase
13+
{
14+
public function test_it_redirects_to_the_default_locale(): void
15+
{
16+
$this->get('/')
17+
->assertRedirect('/' . config('app.fallback_locale'));
18+
}
19+
20+
#[DataProvider('languages')]
21+
public function test_it_can_view_the_home_page_in(string $language)
22+
{
23+
$this->get("/{$language}")
24+
->assertStatus(200);
25+
}
26+
}

tests/TestCase.php

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,34 @@
88

99
abstract class TestCase extends BaseTestCase
1010
{
11-
//
11+
public static function languages(): array
12+
{
13+
return [
14+
'bulgarian' => ['bg'],
15+
'croatian' => ['hr'],
16+
'czech' => ['cs'],
17+
'danish' => ['da'],
18+
'dutch' => ['nl'],
19+
'english' => ['en'],
20+
'estonian' => ['et'],
21+
'finnish' => ['fi'],
22+
'french' => ['fr'],
23+
'german' => ['de'],
24+
'greek' => ['el'],
25+
'hungarian' => ['hu'],
26+
'irish' => ['ga'],
27+
'italian' => ['it'],
28+
'luxembourgish' => ['lb'],
29+
'latvian' => ['lv'],
30+
'lithuanian' => ['lt'],
31+
'maltese' => ['mt'],
32+
'polish' => ['pl'],
33+
'portuguese' => ['pt'],
34+
'romanian' => ['ro'],
35+
'slovak' => ['sk'],
36+
'slovene' => ['sl'],
37+
'spanish' => ['es'],
38+
'swedish' => ['sv'],
39+
];
40+
}
1241
}

0 commit comments

Comments
 (0)