These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * @link https://github.com/paulzi/yii2-nested-intervals |
||
4 | * @copyright Copyright (c) 2015 PaulZi <[email protected]> |
||
5 | * @license MIT (https://github.com/paulzi/yii2-nested-intervals/blob/master/LICENSE) |
||
6 | */ |
||
7 | |||
8 | namespace paulzi\nestedintervals\tests; |
||
9 | |||
10 | use paulzi\nestedintervals\tests\migrations\TestMigration; |
||
11 | use Yii; |
||
12 | use yii\db\Connection; |
||
13 | |||
14 | /** |
||
15 | * @author PaulZi <[email protected]> |
||
16 | */ |
||
17 | class BaseTestCase extends \PHPUnit_Extensions_Database_TestCase |
||
18 | { |
||
19 | protected static $driverName = 'sqlite'; |
||
20 | |||
21 | |||
22 | /** |
||
23 | * @inheritdoc |
||
24 | */ |
||
25 | public function getConnection() |
||
26 | { |
||
27 | return $this->createDefaultDBConnection(Yii::$app->getDb()->pdo); |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * @inheritdoc |
||
32 | */ |
||
33 | public function getDataSet() |
||
34 | { |
||
35 | return new \PHPUnit_Extensions_Database_DataSet_ArrayDataSet(require(__DIR__ . '/data/data.php')); |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * @inheritdoc |
||
40 | */ |
||
41 | protected function setUp() |
||
42 | { |
||
43 | if (Yii::$app->get('db', false) === null) { |
||
44 | $this->markTestSkipped(); |
||
45 | } else { |
||
46 | (new TestMigration())->up(); |
||
47 | if (Yii::$app->db->driverName === 'pgsql') { |
||
48 | Yii::$app->db->createCommand("SELECT setval(pg_get_serial_sequence('tree', 'id'), 25)")->execute(); |
||
49 | Yii::$app->db->createCommand("SELECT setval(pg_get_serial_sequence('multiple_tree', 'id'), 39)")->execute(); |
||
50 | Yii::$app->db->createCommand("SELECT setval(pg_get_serial_sequence('multiple_tree_64', 'id'), 39)")->execute(); |
||
51 | } |
||
52 | parent::setUp(); |
||
53 | } |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * @inheritdoc |
||
58 | */ |
||
59 | public static function setUpBeforeClass() |
||
60 | { |
||
61 | $config = require(__DIR__ . '/data/config.php'); |
||
62 | $config = $config[static::$driverName]; |
||
63 | $config['class'] = Connection::className(); |
||
0 ignored issues
–
show
|
|||
64 | try { |
||
65 | Yii::$app->set('db', $config); |
||
66 | Yii::$app->getDb()->open(); |
||
67 | } catch (\Exception $e) { |
||
68 | Yii::$app->clear('db'); |
||
69 | } |
||
70 | } |
||
71 | } |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.