Completed
Push — master ( aed851...a3d46d )
by Nicolas
01:45
created

BaseTestCase   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

5 Methods

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