BaseBlockTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 63
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 8 1
A getPackageProviders() 0 10 1
A getPackageAliases() 0 7 1
A getEnvironmentSetUp() 0 11 1
A resetDatabase() 0 15 1
1
<?php
2
3
namespace Modules\Block\Tests\Integration;
4
5
use Maatwebsite\Sidebar\SidebarServiceProvider;
6
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
7
use Mcamara\LaravelLocalization\LaravelLocalizationServiceProvider;
8
use Modules\Block\Facades\BlockFacade;
9
use Modules\Block\Providers\BlockServiceProvider;
10
use Modules\Block\Repositories\BlockRepository;
11
use Modules\Core\Providers\CoreServiceProvider;
12
use Nwidart\Modules\LaravelModulesServiceProvider;
13
use Orchestra\Testbench\TestCase;
14
15
abstract class BaseBlockTest extends TestCase
16
{
17
    /**
18
     * @var BlockRepository
19
     */
20
    protected $block;
21
22
    public function setUp()
23
    {
24
        parent::setUp();
25
26
        $this->resetDatabase();
27
28
        $this->block = app(BlockRepository::class);
29
    }
30
31
    protected function getPackageProviders($app)
32
    {
33
        return [
34
            LaravelModulesServiceProvider::class,
35
            LaravelLocalizationServiceProvider::class,
36
            CoreServiceProvider::class,
37
            BlockServiceProvider::class,
38
            SidebarServiceProvider::class,
39
        ];
40
    }
41
42
    protected function getPackageAliases($app)
43
    {
44
        return [
45
            'LaravelLocalization' => LaravelLocalization::class,
46
            'Block', BlockFacade::class,
47
        ];
48
    }
49
50
    protected function getEnvironmentSetUp($app)
51
    {
52
        $app['path.base'] = __DIR__ . '/..';
53
        $app['config']->set('database.default', 'sqlite');
54
        $app['config']->set('database.connections.sqlite', array(
55
            'driver' => 'sqlite',
56
            'database' => ':memory:',
57
            'prefix' => '',
58
        ));
59
        $app['config']->set('translatable.locales', ['en', 'fr']);
60
    }
61
62
    private function resetDatabase()
63
    {
64
        // Makes sure the migrations table is created
65
        $this->artisan('migrate', [
66
            '--database' => 'sqlite',
67
        ]);
68
        // We empty all tables
69
        $this->artisan('migrate:reset', [
70
            '--database' => 'sqlite',
71
        ]);
72
        // Migrate
73
        $this->artisan('migrate', [
74
            '--database' => 'sqlite',
75
        ]);
76
    }
77
}
78