diff --git a/composer.json b/composer.json index 3d68148..001ed7c 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,8 @@ "autoload-dev": { "psr-4": { "Zoomyboy\\MedialibraryHelper\\Tests\\": "tests/", - "Workbench\\App\\": "tests/workbench/app/" + "Workbench\\App\\": "tests/workbench/app/", + "Database\\Factories\\": "tests/workbench/database/factories/" } }, "authors": [ diff --git a/config/media-library.php b/config/media-library.php index b700c8d..a478468 100644 --- a/config/media-library.php +++ b/config/media-library.php @@ -2,4 +2,5 @@ return [ 'temp_storage' => 'temp', + 'middleware' => ['web', 'auth:web'], ]; diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index e4d7597..a4bfcbc 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -2,9 +2,7 @@ namespace Zoomyboy\MedialibraryHelper; -use Illuminate\Foundation\Events\VendorTagPublished; use Illuminate\Routing\Router; -use Illuminate\Support\Facades\Event; use Illuminate\Support\ServiceProvider as BaseServiceProvider; use Spatie\MediaLibrary\MediaCollections\MediaCollection; diff --git a/tests/TestCase.php b/tests/TestCase.php index f203672..c47890d 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -7,6 +7,7 @@ use Illuminate\Support\Facades\Gate; use Orchestra\Testbench\Concerns\WithWorkbench; use Orchestra\Testbench\TestCase as BaseTestCase; use Workbench\App\Models\Post; +use Workbench\App\Models\User; class TestCase extends BaseTestCase { @@ -49,6 +50,7 @@ class TestCase extends BaseTestCase protected function auth(array $policies = []): self { + $this->be(User::factory()->create()); $policies = [ 'storeMedia' => true, 'updateMedia' => true, @@ -63,9 +65,4 @@ class TestCase extends BaseTestCase return $this; } - - protected function defineEnvironment($app) - { - $app['config']->set('media-library.middleware', ['web']); - } } diff --git a/tests/workbench/app/Models/User.php b/tests/workbench/app/Models/User.php new file mode 100644 index 0000000..f236a54 --- /dev/null +++ b/tests/workbench/app/Models/User.php @@ -0,0 +1,13 @@ + + */ +class UserFactory extends Factory +{ + protected $model = User::class; + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'email' => $this->faker->safeEmail, + 'password' => Hash::make('password'), + 'name' => $this->faker->firstName, + ]; + } +}