-
-
Notifications
You must be signed in to change notification settings - Fork 104
/
TestCase.php
75 lines (61 loc) · 1.92 KB
/
TestCase.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
namespace EasyPanelTest;
use EasyPanel\EasyPanelServiceProvider;
use EasyPanel\Parsers\StubParser;
use EasyPanelTest\Dependencies\Article;
use EasyPanelTest\Dependencies\User;
use Faker\Factory;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Hash;
use Iya30n\DynamicAcl\Providers\DynamicAclServiceProvider;
use Javoscript\MacroableModels\MacroableModelsServiceProvider;
use Livewire\LivewireServiceProvider;
abstract class TestCase extends \Orchestra\Testbench\TestCase
{
/**
* @var Collection|Model
*/
protected $user;
/**
* @var StubParser
*/
protected $parser;
public function getAdmin()
{
$this->user->panelAdmin()->create([
'is_superuser' => true
]);
return $this->user->refresh();
}
protected function setUp(): void
{
parent::setUp();
$this->loadMigrationsFrom(__DIR__ . '/Dependencies/database/migrations');
$this->loadMigrationsFrom(__DIR__ . '/../vendor/iya30n/dynamic-acl/database/migrations');
$this->setUser();
$this->setParser();
config()->set('easy_panel.user_model', User::class);
config()->set('easy_panel.database.panel_admin_table', 'panel_admins');
config()->set('easy_panel.database.crud_table', 'cruds');
}
protected function setUser()
{
$faker = Factory::create();
$user = User::create(['name' => $faker->name, 'password' => Hash::make('password')]);
$this->user = $user;
}
private function setParser()
{
$this->parser = new StubParser('article', Article::class);
}
protected function getPackageProviders($app)
{
return [
EasyPanelServiceProvider::class,
LivewireServiceProvider::class,
MacroableModelsServiceProvider::class,
DynamicAclServiceProvider::class,
];
}
}