Skip to content

Commit cfe84d9

Browse files
Add initial test suite and GitHub Actions workflow
The commit introduces a test suite with example tests and an architectural test. The test case setup has been added, defining several required service providers and setting up the application environment. Additionally, a new GitHub Actions workflow for running tests on different PHP and Laravel versions has been added. Changes also include an update to `composer.json` to autoload the test suite classes.
1 parent 232c614 commit cfe84d9

File tree

6 files changed

+131
-0
lines changed

6 files changed

+131
-0
lines changed

.github/workflows/run-tests.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: run-tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: true
14+
matrix:
15+
os: [ubuntu-latest, windows-latest]
16+
php: [8.2, 8.1]
17+
laravel: [10.*]
18+
stability: [prefer-lowest, prefer-stable]
19+
include:
20+
- laravel: 10.*
21+
testbench: 8.*
22+
carbon: 2.*
23+
24+
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
25+
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v4
29+
30+
- name: Setup PHP
31+
uses: shivammathur/setup-php@v2
32+
with:
33+
php-version: ${{ matrix.php }}
34+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
35+
coverage: none
36+
37+
- name: Setup problem matchers
38+
run: |
39+
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
40+
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
41+
42+
- name: Install dependencies
43+
run: |
44+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.carbon }}" --no-interaction --no-update
45+
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
46+
47+
- name: List Installed Dependencies
48+
run: composer show -D
49+
50+
- name: Execute tests
51+
run: vendor/bin/pest --ci

composer.json

+5
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@
4343
"JeffersonSimaoGoncalves\\FilamentCheckWhoisWidget\\": "src/"
4444
}
4545
},
46+
"autoload-dev": {
47+
"psr-4": {
48+
"JeffersonSimaoGoncalves\\FilamentCheckWhoisWidget\\Tests\\": "tests/"
49+
}
50+
},
4651
"scripts": {
4752
"post-autoload-dump": "@php ./vendor/bin/testbench package:discover --ansi",
4853
"analyse": "vendor/bin/phpstan analyse",

tests/ArchTest.php

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
it('will not use debugging functions')
4+
->expect(['dd', 'dump', 'ray'])
5+
->each->not->toBeUsed();

tests/ExampleTest.php

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
it('can test', function () {
4+
expect(true)->toBeTrue();
5+
});

tests/Pest.php

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
use Joaopaulolndev\FilamentGeneralSettings\Tests\TestCase;
4+
5+
uses(TestCase::class)->in(__DIR__);

tests/TestCase.php

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
namespace Joaopaulolndev\FilamentGeneralSettings\Tests;
4+
5+
use BladeUI\Heroicons\BladeHeroiconsServiceProvider;
6+
use BladeUI\Icons\BladeIconsServiceProvider;
7+
use Filament\Actions\ActionsServiceProvider;
8+
use Filament\FilamentServiceProvider;
9+
use Filament\Forms\FormsServiceProvider;
10+
use Filament\Infolists\InfolistsServiceProvider;
11+
use Filament\Notifications\NotificationsServiceProvider;
12+
use Filament\Support\SupportServiceProvider;
13+
use Filament\Tables\TablesServiceProvider;
14+
use Filament\Widgets\WidgetsServiceProvider;
15+
use Illuminate\Database\Eloquent\Factories\Factory;
16+
use Joaopaulolndev\FilamentGeneralSettings\FilamentGeneralSettingsServiceProvider;
17+
use Livewire\LivewireServiceProvider;
18+
use Orchestra\Testbench\TestCase as Orchestra;
19+
use RyanChandler\BladeCaptureDirective\BladeCaptureDirectiveServiceProvider;
20+
21+
class TestCase extends Orchestra
22+
{
23+
protected function setUp(): void
24+
{
25+
parent::setUp();
26+
27+
Factory::guessFactoryNamesUsing(
28+
fn (string $modelName) => 'Joaopaulolndev\\FilamentGeneralSettings\\Database\\Factories\\' . class_basename($modelName) . 'Factory'
29+
);
30+
}
31+
32+
protected function getPackageProviders($app)
33+
{
34+
return [
35+
ActionsServiceProvider::class,
36+
BladeCaptureDirectiveServiceProvider::class,
37+
BladeHeroiconsServiceProvider::class,
38+
BladeIconsServiceProvider::class,
39+
FilamentServiceProvider::class,
40+
FormsServiceProvider::class,
41+
InfolistsServiceProvider::class,
42+
LivewireServiceProvider::class,
43+
NotificationsServiceProvider::class,
44+
SupportServiceProvider::class,
45+
TablesServiceProvider::class,
46+
WidgetsServiceProvider::class,
47+
FilamentGeneralSettingsServiceProvider::class,
48+
];
49+
}
50+
51+
public function getEnvironmentSetUp($app)
52+
{
53+
config()->set('database.default', 'testing');
54+
55+
/*
56+
$migration = include __DIR__.'/../database/migrations/create_filament-general-settings_table.php.stub';
57+
$migration->up();
58+
*/
59+
}
60+
}

0 commit comments

Comments
 (0)