We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
1 | <?php |
||
2 | |||
3 | namespace Backpack\CRUD\Tests\config\CrudPanel; |
||
4 | |||
5 | use Backpack\CRUD\app\Library\CrudPanel\CrudPanel; |
||
6 | use Illuminate\Foundation\Testing\RefreshDatabase; |
||
7 | |||
8 | abstract class BaseDBCrudPanel extends BaseCrudPanel |
||
9 | { |
||
10 | use RefreshDatabase; |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
11 | |||
12 | /** |
||
13 | * @var CrudPanel |
||
14 | */ |
||
15 | protected $crudPanel; |
||
16 | |||
17 | protected $model; |
||
18 | |||
19 | /** |
||
20 | * Setup the test environment. |
||
21 | * |
||
22 | * @return void |
||
23 | */ |
||
24 | protected function setUp(): void |
||
25 | { |
||
26 | parent::setUp(); |
||
27 | |||
28 | // call migrations specific to our tests |
||
29 | $this->loadMigrationsFrom([ |
||
30 | '--database' => 'testing', |
||
31 | '--path' => realpath(__DIR__.'/../../config/database/migrations'), |
||
32 | ]); |
||
33 | |||
34 | $this->seed('Backpack\CRUD\Tests\config\database\seeds\UsersRolesTableSeeder'); |
||
35 | $this->seed('Backpack\CRUD\Tests\config\database\seeds\UsersTableSeeder'); |
||
36 | $this->seed('Backpack\CRUD\Tests\config\database\seeds\ArticlesTableSeeder'); |
||
37 | $this->seed('Backpack\CRUD\Tests\config\database\seeds\MorphableSeeders'); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * Define environment setup. |
||
42 | * |
||
43 | * @param \Illuminate\Foundation\Application $app |
||
44 | * @return void |
||
45 | */ |
||
46 | protected function getEnvironmentSetUp($app) |
||
47 | { |
||
48 | $app['config']->set('database.default', 'testing'); |
||
49 | $app['config']->set('backpack.base.route_prefix', 'admin'); |
||
50 | |||
51 | $app->bind('App\Http\Middleware\CheckIfAdmin', function () { |
||
52 | return new class |
||
53 | { |
||
54 | public function handle($request, $next) |
||
55 | { |
||
56 | return $next($request); |
||
57 | } |
||
58 | }; |
||
59 | }); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * Assert that the attributes of a model entry are equal to the expected array of attributes. |
||
64 | * |
||
65 | * @param array $expected attributes |
||
66 | * @param \Illuminate\Database\Eloquent\Model $actual model |
||
67 | */ |
||
68 | protected function assertEntryEquals($expected, $actual) |
||
69 | { |
||
70 | foreach ($expected as $key => $value) { |
||
71 | if (is_array($value)) { |
||
72 | $this->assertEquals(count($value), $actual->{$key}->count()); |
||
73 | } else { |
||
74 | $this->assertEquals($value, $actual->{$key}); |
||
75 | } |
||
76 | } |
||
77 | |||
78 | $this->assertNotNull($actual->created_at); |
||
79 | $this->assertNotNull($actual->updated_at); |
||
80 | } |
||
81 | } |
||
82 |