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

DbFixture   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 3
dl 0
loc 20
rs 10
c 0
b 0
f 0
ccs 4
cts 4
cp 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A init() 0 5 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