Completed
Push — refactor-db-tests ( 8ba032...86f17c )
by Carsten
10:02
created

DbFixture::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
ccs 4
cts 4
cp 1
cc 1
eloc 3
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * @link http://www.yiiframework.com/
4
 * @copyright Copyright (c) 2008 Yii Software LLC
5
 * @license http://www.yiiframework.com/license/
6
 */
7
8
namespace yii\test;
9
10
use Yii;
11
use yii\db\Connection;
12
use yii\di\Instance;
13
use yii\base\Object;
14
15
/**
16
 * DbFixture is the base class for DB-related fixtures.
17
 *
18
 * DbFixture provides the [[db]] connection to be used by DB fixtures.
19
 *
20
 * @author Qiang Xue <[email protected]>
21
 * @since 2.0
22
 */
23
abstract class DbFixture extends Fixture
24
{
25
    /**
26
     * @var Connection|array|string the DB connection object or the application component ID of the DB connection.
27
     * After the DbFixture object is created, if you want to change this property, you should only assign it
28
     * with a DB connection object.
29
     * Starting from version 2.0.2, this can also be a configuration array for creating the object.
30
     */
31
    public $db = 'db';
32
33
34
    /**
35
     * @inheritdoc
36
     */
37 6
    public function init()
38
    {
39 6
        parent::init();
40 6
        $this->db = Instance::ensure($this->db, Object::className());
41 6
    }
42
}
43