Add auth
This commit is contained in:
parent
14ca7d312f
commit
1b2b148af5
|
@ -11,7 +11,8 @@
|
||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Zoomyboy\\MedialibraryHelper\\Tests\\": "tests/",
|
"Zoomyboy\\MedialibraryHelper\\Tests\\": "tests/",
|
||||||
"Workbench\\App\\": "tests/workbench/app/"
|
"Workbench\\App\\": "tests/workbench/app/",
|
||||||
|
"Database\\Factories\\": "tests/workbench/database/factories/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"authors": [
|
"authors": [
|
||||||
|
|
|
@ -2,4 +2,5 @@
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'temp_storage' => 'temp',
|
'temp_storage' => 'temp',
|
||||||
|
'middleware' => ['web', 'auth:web'],
|
||||||
];
|
];
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
|
|
||||||
namespace Zoomyboy\MedialibraryHelper;
|
namespace Zoomyboy\MedialibraryHelper;
|
||||||
|
|
||||||
use Illuminate\Foundation\Events\VendorTagPublished;
|
|
||||||
use Illuminate\Routing\Router;
|
use Illuminate\Routing\Router;
|
||||||
use Illuminate\Support\Facades\Event;
|
|
||||||
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
|
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
|
||||||
use Spatie\MediaLibrary\MediaCollections\MediaCollection;
|
use Spatie\MediaLibrary\MediaCollections\MediaCollection;
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ use Illuminate\Support\Facades\Gate;
|
||||||
use Orchestra\Testbench\Concerns\WithWorkbench;
|
use Orchestra\Testbench\Concerns\WithWorkbench;
|
||||||
use Orchestra\Testbench\TestCase as BaseTestCase;
|
use Orchestra\Testbench\TestCase as BaseTestCase;
|
||||||
use Workbench\App\Models\Post;
|
use Workbench\App\Models\Post;
|
||||||
|
use Workbench\App\Models\User;
|
||||||
|
|
||||||
class TestCase extends BaseTestCase
|
class TestCase extends BaseTestCase
|
||||||
{
|
{
|
||||||
|
@ -49,6 +50,7 @@ class TestCase extends BaseTestCase
|
||||||
|
|
||||||
protected function auth(array $policies = []): self
|
protected function auth(array $policies = []): self
|
||||||
{
|
{
|
||||||
|
$this->be(User::factory()->create());
|
||||||
$policies = [
|
$policies = [
|
||||||
'storeMedia' => true,
|
'storeMedia' => true,
|
||||||
'updateMedia' => true,
|
'updateMedia' => true,
|
||||||
|
@ -63,9 +65,4 @@ class TestCase extends BaseTestCase
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function defineEnvironment($app)
|
|
||||||
{
|
|
||||||
$app['config']->set('media-library.middleware', ['web']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 = [];
|
||||||
|
}
|
|
@ -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,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue