Skip to content

Commit 19dbaa2

Browse files
committed
Adjust test suites
1 parent 884c57c commit 19dbaa2

File tree

9 files changed

+140
-9
lines changed

9 files changed

+140
-9
lines changed

.github/workflows/run-tests-pcov-pull.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ jobs:
9393
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
9494

9595
- name: Run Unit Tests
96-
run: php ./vendor/bin/phpunit --cache-directory=".phpunit.cache/code-coverage" --strict-coverage --coverage-clover ./coverage.xml
96+
run: php ./vendor/bin/phpunit --testsuite "Laravel Livewire Tables Unit Test Suite" --cache-directory=".phpunit.cache/code-coverage" --strict-coverage --coverage-clover ./coverage.xml
9797

9898
- name: Upload coverage reports to Codecov
9999
uses: codecov/codecov-action@v4

.github/workflows/run-tests-pull.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
8484

8585
- name: Run Unit Tests
86-
run: php ./vendor/bin/phpunit --no-coverage
86+
run: php ./vendor/bin/phpunit --testsuite "Laravel Livewire Tables Unit Test Suite" --no-coverage
8787

8888

8989
test-laravel11:
@@ -162,4 +162,4 @@ jobs:
162162
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
163163

164164
- name: Run Unit Tests
165-
run: php ./vendor/bin/phpunit --no-coverage
165+
run: php ./vendor/bin/phpunit --testsuite "Laravel Livewire Tables Unit Test Suite" --no-coverage

.github/workflows/run-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
8686

8787
- name: Run Unit Tests
88-
run: php ./vendor/bin/phpunit --no-coverage
88+
run: php ./vendor/bin/phpunit --testsuite "Laravel Livewire Tables Unit Test Suite" --no-coverage
8989

9090

9191
test-laravel11:
@@ -164,4 +164,4 @@ jobs:
164164
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
165165

166166
- name: Run Unit Tests
167-
run: php ./vendor/bin/phpunit --no-coverage
167+
run: php ./vendor/bin/phpunit --testsuite "Laravel Livewire Tables Unit Test Suite" --no-coverage

phpunit.xml.dist

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@
99
failOnEmptyTestSuite="false"
1010
beStrictAboutOutputDuringTests="true" >
1111
<testsuites>
12-
<testsuite name="Laravel Livewire Tables Test Suite">
12+
<testsuite name="Laravel Livewire Tables Unit Test Suite">
1313
<directory>tests/Unit</directory>
1414
</testsuite>
15+
<testsuite name="Laravel Livewire Tables Localisations Unit">
16+
<directory>tests/Localisations/Unit</directory>
17+
</testsuite>
18+
<testsuite name="Laravel Livewire Tables Localisations Presence">
19+
<directory>tests/Localisations/Presence</directory>
20+
</testsuite>
1521
</testsuites>
1622
<source>
1723
<include>
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
3+
namespace Rappasoft\LaravelLivewireTables\Tests\Localisations;
4+
5+
use Rappasoft\LaravelLivewireTables\Tests\Models\Pet;
6+
use Rappasoft\LaravelLivewireTables\Tests\TestCase;
7+
use PHPUnit\Framework\Attributes\DataProvider;
8+
9+
class BaseLocalisationCase extends TestCase
10+
{
11+
12+
public static function getEnLocaleStrings(): array
13+
{
14+
$baseDir = __DIR__.'/../../resources/lang/';
15+
16+
$items = require($baseDir."en/core.php");
17+
return $items;
18+
}
19+
20+
public static function getLocaleStrings($locale): array
21+
{
22+
$baseDir = __DIR__.'/../../resources/lang/';
23+
24+
$items = require($baseDir.$locale."/core.php");
25+
return $items;
26+
}
27+
28+
public static function localisationProvider(): array
29+
{
30+
$baseDir = __DIR__.'/../../resources/lang/';
31+
32+
$localisations = [];
33+
34+
$availableLocales = [
35+
'ar',
36+
'ca',
37+
'da',
38+
'de',
39+
'en',
40+
'es',
41+
'fr',
42+
'id',
43+
'it',
44+
'ms',
45+
'nb',
46+
'nl',
47+
'pl',
48+
'pt',
49+
'pt_BR',
50+
'ru',
51+
'sq',
52+
'sv',
53+
'th',
54+
'tk',
55+
'tr',
56+
'tw',
57+
'uk',
58+
];
59+
//return $availableLocales;
60+
61+
foreach ($availableLocales as $availableLocale)
62+
{
63+
//$array = require($baseDir.$availableLocale.'/core.php');
64+
$localisations[] = [
65+
'locale' => $availableLocale,
66+
// 'localisationStrings' => $array,
67+
];
68+
}
69+
return $localisations;
70+
}
71+
72+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Rappasoft\LaravelLivewireTables\Tests\Localisations\Presence;
4+
5+
use Rappasoft\LaravelLivewireTables\Tests\Localisations\BaseLocalisationCase;
6+
use PHPUnit\Framework\Attributes\DataProvider;
7+
8+
final class CheckKeyPresenceTest extends BaseLocalisationCase
9+
{
10+
11+
#[DataProvider('localisationProvider')]
12+
public function test_can_get_localised_empty_message(string $locale): void
13+
{
14+
$localisedStrings = static::getLocaleStrings($locale);
15+
16+
$localisedString = $localisedStrings['No items found, try to broaden your search'] ?? $locale;
17+
$this->basicTable->changeLocale($locale);
18+
$this->assertEquals($localisedString, $this->basicTable->getEmptyMessage());
19+
}
20+
21+
#[DataProvider('localisationProvider')]
22+
public function test_can_check_presence_of_keys(string $locale): void
23+
{
24+
$engStrings = static::getEnLocaleStrings();
25+
$localisedStrings = static::getLocaleStrings($locale);
26+
foreach ($engStrings as $key => $value)
27+
{
28+
$this->assertNotNull($localisedStrings[$key]);
29+
}
30+
}
31+
32+
33+
34+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Rappasoft\LaravelLivewireTables\Tests\Localisations\Unit\Component;
4+
5+
use Rappasoft\LaravelLivewireTables\Tests\Localisations\BaseLocalisationCase;
6+
use PHPUnit\Framework\Attributes\DataProvider;
7+
8+
final class EmptyStringTest extends BaseLocalisationCase
9+
{
10+
11+
#[DataProvider('localisationProvider')]
12+
public function test_can_get_localised_empty_message(string $locale): void
13+
{
14+
$localisedString = $localisationStrings['No items found, try to broaden your search'] ?? $locale;
15+
$this->basicTable->changeLocale($locale);
16+
$this->assertEquals($localisedString, $this->basicTable->getEmptyMessage());
17+
}
18+
19+
}

tests/Unit/Traits/Configuration/SearchConfigurationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public function test_cant_set_search_throttle_with_other_search_modifiers(): voi
170170

171171
public function test_can_set_search_placeholder(): void
172172
{
173-
$this->assertSame(__('livewire-tables::Search'), $this->basicTable->getSearchPlaceholder());
173+
$this->assertSame(__('livewire-tables::core.Search'), $this->basicTable->getSearchPlaceholder());
174174

175175
$this->basicTable->setSearchPlaceholder('Anthony');
176176

tests/Unit/Traits/Helpers/ComponentHelpersTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ public function test_can_get_current_theme(): void
2222
$this->assertEquals('tailwind', $this->basicTable->getTheme());
2323
}
2424

25-
public function test_can_get_empty_message(): void
25+
public function test_can_get_default_empty_message(): void
2626
{
27-
$this->assertEquals('No items found. Try to broaden your search.', $this->basicTable->getEmptyMessage());
27+
$this->assertEquals(__('livewire-tables::core.No items found, try to broaden your search'), $this->basicTable->getEmptyMessage());
2828
}
2929

3030
public function test_can_get_offline_status(): void

0 commit comments

Comments
 (0)