DbManagerTest::getDataFile()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
namespace RazonYang\Yii2\Setting\Tests\Unit;
3
4
use Codeception\Test\Unit;
5
use RazonYang\Yii2\Setting\DbManager;
6
use RazonYang\Yii2\Setting\Tests\Fixture\SettingFixture;
7
8
class DbManagerTest extends Unit
9
{
10
    private function getDataFile(): string
11
    {
12
        return codecept_data_dir() . 'setting.php';
13
    }
14
15
    public function _fixtures()
16
    {
17
        return [
18
            'setting' => [
19
                'class' => SettingFixture::className(),
0 ignored issues
show
Deprecated Code introduced by
The function yii\base\BaseObject::className() has been deprecated: since 2.0.14. On PHP >=5.5, use `::class` instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

19
                'class' => /** @scrutinizer ignore-deprecated */ SettingFixture::className(),

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
20
                'dataFile' => $this->getDataFile()
21
            ]
22
        ];
23
    }
24
25
    public function testLoad(): void
26
    {
27
        $data = require $this->getDataFile();
28
        $manager = new DbManager();
29
        $settings = $manager->load();
30
        $this->assertCount(count($data), $settings);
31
        foreach ($data as $id => $fields) {
32
            $this->assertArrayHasKey($id, $settings);
33
            $this->assertSame($fields['value'], $settings[$id]);
34
        }
35
    }
36
}
37