This commit is contained in:
philipp lang 2024-01-03 13:07:03 +01:00
parent 14ca7d312f
commit 1b2b148af5
6 changed files with 47 additions and 8 deletions

View File

@ -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": [

View File

@ -2,4 +2,5 @@
return [
'temp_storage' => 'temp',
'middleware' => ['web', 'auth:web'],
];

View File

@ -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;

View File

@ -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']);
}
}

View File

@ -0,0 +1,13 @@
<?php
namespace Workbench\App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use HasFactory;
public $guarded = [];
}

View File

@ -0,0 +1,29 @@
<?php
namespace Database\Factories\Models;
use Workbench\App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
/**
* @extends Factory<User>
*/
class UserFactory extends Factory
{
protected $model = User::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition()
{
return [
'email' => $this->faker->safeEmail,
'password' => Hash::make('password'),
'name' => $this->faker->firstName,
];
}
}