Passed
Pull Request — master (#20362)
by Wilmer
05:37
created

DbFixture   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 18
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A init() 0 4 1
1
<?php
2
/**
3
 * @link https://www.yiiframework.com/
4
 * @copyright Copyright (c) 2008 Yii Software LLC
5
 * @license https://www.yiiframework.com/license/
6
 */
7
8
namespace yii\test;
9
10
use yii\base\BaseObject;
11
use yii\db\Connection;
12
use yii\di\Instance;
13
14
/**
15
 * DbFixture is the base class for DB-related fixtures.
16
 *
17
 * DbFixture provides the [[db]] connection to be used by DB fixtures.
18
 *
19
 * For more details and usage information on DbFixture, see the [guide article on fixtures](guide:test-fixtures).
20
 *
21
 * @author Qiang Xue <[email protected]>
22
 * @since 2.0
23
 */
24
abstract class DbFixture extends Fixture
25
{
26
    /**
27
     * @var Connection|array|string the DB connection object or the application component ID of the DB connection.
28
     * After the DbFixture object is created, if you want to change this property, you should only assign it
29
     * with a DB connection object.
30
     * Starting from version 2.0.2, this can also be a configuration array for creating the object.
31
     */
32
    public $db = 'db';
33
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function init()
39
    {
40
        parent::init();
41
        $this->db = Instance::ensure($this->db, BaseObject::class);
42
    }
43
}
44