SimpleConfigTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 4
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
/**
3
 * ActiveRecord for API
4
 *
5
 * @link      https://github.com/hiqdev/yii2-hiart
6
 * @package   yii2-hiart
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\hiart\tests\functional;
12
13
use hiqdev\hiart\curl\Request;
14
use hiqdev\hiart\rest\Connection;
15
use Yii;
16
use yii\console\Application;
17
18
class SimpleConfigTest extends \PHPUnit\Framework\TestCase
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
{
20
    protected $simpleConfig = [
21
        'id' => 'hiart-simple-config',
22
        'basePath' => __DIR__,
23
        'components' => [
24
            'hiart' => [
25
                'class' => Connection::class,
26
                'requestClass' => Request::class,
27
                'baseUri' => 'https://site.com/api/v3/',
28
            ],
29
        ],
30
    ];
31
32
    private $app;
33
    private $container;
34
35
    public function setUp()
36
    {
37
        $this->app = Yii::$app;
38
        $this->container = Yii::$container;
39
        Yii::$app = new Application($this->simpleConfig);
40
        Yii::$container = new yii\di\Container();
41
    }
42
43
    public function tearDown()
44
    {
45
        Yii::$app = $this->app;
46
        Yii::$container = $this->container;
47
    }
48
49
    public function testGetDb()
50
    {
51
        $db = Connection::getDb();
52
        $this->assertInstanceOf(Connection::class, $db);
53
        $this->assertSame(Request::class, $db->requestClass);
54
    }
55
}
56