Passed
Push — master ( 3ad459...064778 )
by Aleksandr
07:04
created

TestCase::resetDatabase()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace Tests;
4
5
use Illuminate\Database\Schema\Blueprint;
6
7
class TestCase extends \Orchestra\Testbench\TestCase
8
{
9
    const DB_SQLITE = __DIR__.'/db/db.sqlite';
10
11
    /**
12
     *
13
     */
14
    public function setUp()
15
    {
16
        parent::setUp();
17
        $this->setUpDatabase();
18
    }
19
20
    /**
21
     * @param \Illuminate\Foundation\Application $app
22
     */
23
    public function getEnvironmentSetUp($app)
24
    {
25
        $app['config']->set('database.default', 'sqlite');
26
        $app['config']->set('database.connections.sqlite', [
27
            'driver' => 'sqlite',
28
            'database' => self::DB_SQLITE,
29
            'prefix' => '',
30
        ]);
31
        $app['config']->set('app.key', '6rE9Nz372GRbeMATftriyQjrpF7DcOQm');
32
    }
33
34
    /**
35
     *
36
     */
37
    protected function setUpDatabase()
38
    {
39
        $this->resetDatabase();
40
        $this->createTables();
41
    }
42
43
    /**
44
     *
45
     */
46
    protected function resetDatabase()
47
    {
48
        file_put_contents(self::DB_SQLITE, null);
49
    }
50
51
    /**
52
     *
53
     */
54
    protected function createTables()
55
    {
56
        $this->createEventsTable();
57
    }
58
59
    /**
60
     *
61
     */
62
    protected function createEventsTable()
63
    {
64
        $this->app['db']->connection()->getSchemaBuilder()->create('events', function (Blueprint $table) {
65
            $table->increments('id');
66
            $table->string('title');
67
            $table->timestamps();
68
        });
69
    }
70
}