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 | use Illuminate\Support\Facades\DB; |
||
8 | |||
9 | abstract class BasePrefixedDBCrudPanel extends BaseCrudPanel |
||
10 | { |
||
11 | use RefreshDatabase; |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
12 | |||
13 | /** |
||
14 | * @var CrudPanel |
||
15 | */ |
||
16 | protected $crudPanel; |
||
17 | |||
18 | protected $model; |
||
19 | |||
20 | /** |
||
21 | * Setup the test environment. |
||
22 | * |
||
23 | * @return void |
||
24 | */ |
||
25 | protected function setUp(): void |
||
26 | { |
||
27 | parent::setUp(); |
||
28 | |||
29 | DB::connection('testing')->getSchemaGrammar()->setTablePrefix('test_'); |
||
30 | // call migrations specific to our tests |
||
31 | $this->loadMigrationsFrom([ |
||
32 | '--database' => 'testing', |
||
33 | '--path' => realpath(__DIR__.'/../../config/database/migrations'), |
||
34 | ]); |
||
35 | |||
36 | $this->artisan('db:seed', ['--class' => 'Backpack\CRUD\Tests\Config\Database\Seeds\UsersRolesTableSeeder']); |
||
37 | $this->artisan('db:seed', ['--class' => 'Backpack\CRUD\Tests\Config\Database\Seeds\UsersTableSeeder']); |
||
38 | $this->artisan('db:seed', ['--class' => 'Backpack\CRUD\Tests\Config\Database\Seeds\ArticlesTableSeeder']); |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * Define environment setup. |
||
43 | * |
||
44 | * @param \Illuminate\Foundation\Application $app |
||
45 | * @return void |
||
46 | */ |
||
47 | protected function getEnvironmentSetUp($app) |
||
48 | { |
||
49 | $app['config']->set('database.default', 'testing'); |
||
50 | DB::connection('testing')->setTablePrefix('test_'); |
||
51 | } |
||
52 | |||
53 | protected function defineDatabaseMigrations() |
||
54 | { |
||
55 | DB::connection('testing')->getSchemaGrammar()->setTablePrefix('test_'); |
||
56 | $this->artisan('migrate', ['--database' => 'testing']); |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * Assert that the attributes of a model entry are equal to the expected array of attributes. |
||
61 | * |
||
62 | * @param array $expected attributes |
||
63 | * @param \Illuminate\Database\Eloquent\Model $actual model |
||
64 | */ |
||
65 | protected function assertEntryEquals($expected, $actual) |
||
66 | { |
||
67 | foreach ($expected as $key => $value) { |
||
68 | if (is_array($value)) { |
||
69 | $this->assertEquals(count($value), $actual->{$key}->count()); |
||
70 | } else { |
||
71 | $this->assertEquals($value, $actual->{$key}); |
||
72 | } |
||
73 | } |
||
74 | |||
75 | $this->assertNotNull($actual->created_at); |
||
76 | $this->assertNotNull($actual->updated_at); |
||
77 | } |
||
78 | } |
||
79 |