Skip to content

Commit

Permalink
update workbench flow
Browse files Browse the repository at this point in the history
  • Loading branch information
3x1io committed Nov 8, 2024
1 parent a4e08d1 commit 3362bd2
Show file tree
Hide file tree
Showing 11 changed files with 298 additions and 38 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ jobs:
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.carbon }}" "nunomaduro/collision:${{ matrix.collision }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
composer db
- name: Execute tests
run: vendor/bin/pest
250 changes: 235 additions & 15 deletions .idea/workspace.xml

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"autoload-dev": {
"psr-4": {
"TomatoPHP\\FilamentTranslations\\Tests\\": "tests/src/",
"TomatoPHP\\FilamentTranslations\\Tests\\Database\\Factories\\": "tests/database/factories"
"TomatoPHP\\FilamentTranslations\\Tests\\Database\\Factories\\": "tests/database/factories",
"TomatoPHP\\FilamentTranslations\\Tests\\Database\\Seeders\\": "tests/database/seeders"
}
},
"extra": {
Expand All @@ -47,6 +48,7 @@
],
"scripts": {
"testbench": "vendor/bin/testbench package:discover --ansi",
"db": "vendor/bin/testbench package:create-sqlite-db && vendor/bin/testbench migrate",
"analyse": "vendor/bin/phpstan analyse src tests",
"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest --coverage",
Expand Down
4 changes: 1 addition & 3 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
</include>
</source>
<php>
<env name="APP_ENV" value="self-testing"/>
<env name="APP_KEY" value="base64:yk+bUVuZa1p86Dqjk9OjVK2R1pm6XHxC6xEKFq8utH0="/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value="/vendor/tomatophp/filament-translations/tests/database/database.sqlite"/>
<env name="DB_CONNECTION" value="testing"/>
</php>
</phpunit>
3 changes: 1 addition & 2 deletions src/Filament/Resources/TranslationResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ public static function getPages(): array
return [
'index' => \TomatoPHP\FilamentTranslations\Filament\Resources\TranslationResource\Pages\ListTranslations::route('/'),
'create' => \TomatoPHP\FilamentTranslations\Filament\Resources\TranslationResource\Pages\CreateTranslation::route('/create'),
'edit' => \TomatoPHP\FilamentTranslations\Filament\Resources\TranslationResource\Pages\EditTranslation::route('/{record}/edit'),
'view' => \TomatoPHP\FilamentTranslations\Filament\Resources\TranslationResource\Pages\ViewTranslations::route('/{record}'),
'edit' => \TomatoPHP\FilamentTranslations\Filament\Resources\TranslationResource\Pages\EditTranslation::route('/{record}/edit')
];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public static function make(): array
private static function getDefaultActions(): array
{
return [
Actions\ViewAction::make(),
Actions\EditAction::make(),
Actions\DeleteAction::make(),
];
Expand Down
25 changes: 25 additions & 0 deletions testbench.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
providers:
- BladeUI\Icons\BladeIconsServiceProvider
- BladeUI\Heroicons\BladeHeroiconsServiceProvider
- Filament\Actions\ActionsServiceProvider
- Filament\FilamentServiceProvider
- Filament\Forms\FormsServiceProvider
- Filament\Infolists\InfolistsServiceProvider
- Filament\Notifications\NotificationsServiceProvider
- Filament\Support\SupportServiceProvider
- Filament\Tables\TablesServiceProvider
- Filament\Widgets\WidgetsServiceProvider
- RyanChandler\BladeCaptureDirective\BladeCaptureDirectiveServiceProvider
- TomatoPHP\FilamentTranslationComponent\FilamentTranslationComponentServiceProvider
- TomatoPHP\FilamentTranslations\FilamentTranslationsServiceProvider
- TomatoPHP\FilamentTranslations\Tests\AdminPanelProvider
workbench:
welcome: true
install: true
start: /
guard: testing
discovers:
web: true
api: false
commands: false
views: true
Binary file removed tests/database/database.sqlite
Binary file not shown.
22 changes: 22 additions & 0 deletions tests/database/seeders/UserSeed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace TomatoPHP\FilamentTranslations\Tests\Database\Seeders;

use Illuminate\Database\Seeder;
use TomatoPHP\FilamentTranslations\Tests\Models\User;

class UserSeed extends Seeder
{
/**
* Seed the application's database.
*/
public function run(): void
{
User::factory()->create([
'name' => 'Fady Mondy',
'email' => '[email protected]',
'password' => bcrypt('password'),
'email_verified_at' => now(),
]);
}
}
13 changes: 10 additions & 3 deletions tests/src/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@
use Filament\Support\SupportServiceProvider;
use Filament\Tables\TablesServiceProvider;
use Filament\Widgets\WidgetsServiceProvider;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Livewire\LivewireServiceProvider;
use Orchestra\Testbench\Concerns\WithWorkbench;
use Orchestra\Testbench\TestCase as BaseTestCase;
use RyanChandler\BladeCaptureDirective\BladeCaptureDirectiveServiceProvider;
use TomatoPHP\FilamentTranslationComponent\FilamentTranslationComponentServiceProvider;
use TomatoPHP\FilamentTranslations\FilamentTranslationsServiceProvider;
use TomatoPHP\FilamentTranslations\Tests\Models\User;

abstract class TestCase extends BaseTestCase
{
use WithWorkbench;
use RefreshDatabase;

protected function defineDatabaseMigrations(): void
{
Expand Down Expand Up @@ -52,11 +55,15 @@ protected function getPackageProviders($app): array
public function getEnvironmentSetUp($app): void
{
$app['config']->set('filament-translations.use_queue_on_scan', false);
$app['config']->set('database.default', 'sqlite');
$app['config']->set('database.connections.sqlite.database', __DIR__ . '/../database/database.sqlite');
$app['config']->set('database.default', 'testing');
$app['config']->set('auth.guards.testing.driver', 'session');
$app['config']->set('auth.guards.testing.provider', 'testing');
$app['config']->set('auth.providers.testing.driver', 'eloquent');
$app['config']->set('auth.providers.testing.model', User::class);


$app['config']->set('filament-translations.paths', [
__DIR__ . '/../..',
__DIR__ . '/../../vendor/orchestra/testbench-core/laravel',
]);

$app['config']->set('view.paths', [
Expand Down
13 changes: 0 additions & 13 deletions tests/src/TranslationResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,6 @@
livewire(\TomatoPHP\FilamentTranslations\Filament\Resources\TranslationResource\Pages\ListTranslations::class)->assertSuccessful();
});

it('can render view translations page', function () {
if (config('filament-translations.modal')) {
livewire(TranslationResource\Pages\ManageTranslations::class, [
'record' => Translation::factory()->create(),
])
->mountAction('view')
->assertSuccessful();
} else {
get(TranslationResource::getUrl('view', [
'record' => Translation::factory()->create(),
]))->assertSuccessful();
}
});

it('can render translation create page', function () {
if (filament('filament-translations')->allowCreate) {
Expand Down

0 comments on commit 3362bd2

Please sign in to comment.