GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

DatabaseTestCase::setUpBeforeClass()   A
last analyzed

Complexity

Conditions 4
Paths 10

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 18
rs 9.2
cc 4
eloc 12
nc 10
nop 0
1
<?php
2
/**
3
 * @link https://github.com/OmgDef/yii2-multilingual-behavior
4
 * @copyright Copyright (c) 2015 Alexander Kochetov
5
 * @license http://opensource.org/licenses/BSD-3-Clause
6
 */
7
namespace tests;
8
9
use Yii;
10
use yii\db\Connection;
11
12
/**
13
 * DatabaseTestCase
14
 */
15
abstract class DatabaseTestCase extends \PHPUnit_Extensions_Database_TestCase
16
{
17
    protected static $migrationFileName = 'sqlite.sql';
18
19
    /**
20
     * @inheritdoc
21
     */
22
    public function getConnection()
23
    {
24
        return $this->createDefaultDBConnection(\Yii::$app->getDb()->pdo);
25
    }
26
27
    /**
28
     * @inheritdoc
29
     */
30
    public function getDataSet()
31
    {
32
        return $this->createFlatXMLDataSet(__DIR__ . '/data/test.xml');
33
    }
34
35
    /**
36
     * @inheritdoc
37
     */
38
    protected function setUp()
39
    {
40
        if (Yii::$app->get('db', false) === null) {
41
            $this->markTestSkipped();
42
        } else {
43
            parent::setUp();
44
        }
45
    }
46
47
    /**
48
     * @inheritdoc
49
     */
50
    public static function setUpBeforeClass()
51
    {
52
        try {
53
            Yii::$app->set('db', [
54
                'class' => Connection::className(),
55
                'dsn' => 'sqlite::memory:',
56
            ]);
57
            Yii::$app->getDb()->open();
58
            $lines = explode(';', file_get_contents(__DIR__ . '/migrations/' . static::$migrationFileName));
59
            foreach ($lines as $line) {
60
                if (trim($line) !== '') {
61
                    Yii::$app->getDb()->pdo->exec($line);
62
                }
63
            }
64
        } catch (\Exception $e) {
65
            Yii::$app->clear('db');
66
        }
67
    }
68
}