diff --git a/composer.json b/composer.json index a548e4f..3d68148 100644 --- a/composer.json +++ b/composer.json @@ -5,10 +5,15 @@ "license": "MIT", "autoload": { "psr-4": { - "Zoomyboy\\MedialibraryHelper\\Tests\\": "tests/", "Zoomyboy\\MedialibraryHelper\\": "src/" } }, + "autoload-dev": { + "psr-4": { + "Zoomyboy\\MedialibraryHelper\\Tests\\": "tests/", + "Workbench\\App\\": "tests/workbench/app/" + } + }, "authors": [ { "name": "Philipp Lang", @@ -28,7 +33,20 @@ }, "scripts": { "post-autoload-dump": [ + "@clear", + "@prepare", "@php vendor/bin/testbench package:discover --ansi" + ], + "clear": "@php vendor/bin/testbench package:purge-skeleton --ansi", + "prepare": "@php vendor/bin/testbench package:discover --ansi", + "build": "@php vendor/bin/testbench workbench:build --ansi", + "serve": [ + "Composer\\Config::disableProcessTimeout", + "@build", + "@php vendor/bin/testbench serve" + ], + "test": [ + "@php vendor/bin/pest" ] }, "config": { diff --git a/composer.lock b/composer.lock index cb7650d..eaab92e 100644 --- a/composer.lock +++ b/composer.lock @@ -8682,16 +8682,16 @@ "packages-dev": [ { "name": "fakerphp/faker", - "version": "v1.23.0", + "version": "v1.23.1", "source": { "type": "git", "url": "https://github.com/FakerPHP/Faker.git", - "reference": "e3daa170d00fde61ea7719ef47bb09bb8f1d9b01" + "reference": "bfb4fe148adbf78eff521199619b93a52ae3554b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FakerPHP/Faker/zipball/e3daa170d00fde61ea7719ef47bb09bb8f1d9b01", - "reference": "e3daa170d00fde61ea7719ef47bb09bb8f1d9b01", + "url": "https://api.github.com/repos/FakerPHP/Faker/zipball/bfb4fe148adbf78eff521199619b93a52ae3554b", + "reference": "bfb4fe148adbf78eff521199619b93a52ae3554b", "shasum": "" }, "require": { @@ -8717,11 +8717,6 @@ "ext-mbstring": "Required for multibyte Unicode string functionality." }, "type": "library", - "extra": { - "branch-alias": { - "dev-main": "v1.21-dev" - } - }, "autoload": { "psr-4": { "Faker\\": "src/Faker/" @@ -8744,9 +8739,9 @@ ], "support": { "issues": "https://github.com/FakerPHP/Faker/issues", - "source": "https://github.com/FakerPHP/Faker/tree/v1.23.0" + "source": "https://github.com/FakerPHP/Faker/tree/v1.23.1" }, - "time": "2023-06-12T08:44:38+00:00" + "time": "2024-01-02T13:46:09+00:00" }, { "name": "hamcrest/hamcrest-php", diff --git a/testbench.yaml b/testbench.yaml new file mode 100644 index 0000000..d495615 --- /dev/null +++ b/testbench.yaml @@ -0,0 +1,7 @@ +providers: + - Spatie\MediaLibrary\MediaLibraryServiceProvider + - Spatie\LaravelData\LaravelDataServiceProvider + - Zoomyboy\MedialibraryHelper\ServiceProvider + +migrations: + - tests/workbench/database/migrations diff --git a/tests/Feature/DestroyTest.php b/tests/Feature/DestroyTest.php index c861790..1e57e03 100644 --- a/tests/Feature/DestroyTest.php +++ b/tests/Feature/DestroyTest.php @@ -3,8 +3,8 @@ namespace Zoomyboy\MedialibraryHelper\Tests\Feature; use Illuminate\Support\Facades\Event; -use Zoomyboy\MedialibraryHelper\Tests\Events\MediaChange; -use Zoomyboy\MedialibraryHelper\Tests\Events\MediaDestroyed; +use Workbench\App\Events\MediaChange; +use Workbench\App\Events\MediaDestroyed; test('it deletes multiple media', function () { $this->auth()->registerModel()->withoutExceptionHandling(); diff --git a/tests/Feature/ReorderTest.php b/tests/Feature/ReorderTest.php index d331f5d..1abd814 100644 --- a/tests/Feature/ReorderTest.php +++ b/tests/Feature/ReorderTest.php @@ -3,7 +3,7 @@ namespace Zoomyboy\MedialibraryHelper\Tests\Feature; use Illuminate\Support\Facades\Event; -use Zoomyboy\MedialibraryHelper\Tests\Events\MediaChange; +use Workbench\App\Events\MediaChange; test('it can reorder media', function () { Event::fake(); diff --git a/tests/Feature/UpdateTest.php b/tests/Feature/UpdateTest.php index 68e788c..9bd8031 100644 --- a/tests/Feature/UpdateTest.php +++ b/tests/Feature/UpdateTest.php @@ -3,7 +3,7 @@ namespace Zoomyboy\MedialibraryHelper\Tests\Feature; use Illuminate\Support\Facades\Event; -use Zoomyboy\MedialibraryHelper\Tests\Events\MediaChange; +use Workbench\App\Events\MediaChange; test('it updates a single files properties', function () { Event::fake(); diff --git a/tests/Feature/UploadTest.php b/tests/Feature/UploadTest.php index 7c30723..04d1377 100644 --- a/tests/Feature/UploadTest.php +++ b/tests/Feature/UploadTest.php @@ -4,8 +4,8 @@ namespace Zoomyboy\MedialibraryHelper\Tests\Feature; use Carbon\Carbon; use Illuminate\Support\Facades\Event; -use Zoomyboy\MedialibraryHelper\Tests\Events\MediaChange; -use Zoomyboy\MedialibraryHelper\Tests\Events\MediaStored; +use Workbench\App\Events\MediaChange; +use Workbench\App\Events\MediaStored; test('it uploads a single file to a single file collection', function () { $this->auth()->registerModel(); diff --git a/tests/TestCase.php b/tests/TestCase.php index c641035..f203672 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -4,30 +4,14 @@ namespace Zoomyboy\MedialibraryHelper\Tests; use Illuminate\Http\File; use Illuminate\Support\Facades\Gate; +use Orchestra\Testbench\Concerns\WithWorkbench; use Orchestra\Testbench\TestCase as BaseTestCase; -use Spatie\LaravelData\LaravelDataServiceProvider; -use Spatie\MediaLibrary\MediaLibraryServiceProvider; -use Zoomyboy\MedialibraryHelper\ServiceProvider; -use Zoomyboy\MedialibraryHelper\Tests\Models\Post; +use Workbench\App\Models\Post; class TestCase extends BaseTestCase { - /** - * Define database migrations. - */ - protected function defineDatabaseMigrations(): void - { - $this->loadMigrationsFrom(__DIR__ . '/migrations'); - } - protected function getPackageProviders($app): array - { - return [ - ServiceProvider::class, - MediaLibraryServiceProvider::class, - LaravelDataServiceProvider::class, - ]; - } + use WithWorkbench; /** * Generate a pdf file with a filename and get path. diff --git a/tests/Events/MediaChange.php b/tests/workbench/app/Events/MediaChange.php similarity index 86% rename from tests/Events/MediaChange.php rename to tests/workbench/app/Events/MediaChange.php index 2c1fd85..c41f4b5 100644 --- a/tests/Events/MediaChange.php +++ b/tests/workbench/app/Events/MediaChange.php @@ -1,6 +1,6 @@