Completed
Push — 6.0 ( 8661a3...f9d0f5 )
by yun
06:28
created

DbTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 16
c 3
b 0
f 0
dl 0
loc 29
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A tearDown() 0 3 1
A testMake() 0 22 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace think\tests;
4
5
use Mockery as m;
6
use PHPUnit\Framework\TestCase;
7
use think\Cache;
8
use think\Config;
9
use think\Db;
10
use think\Event;
11
use think\Log;
12
13
class DbTest extends TestCase
14
{
15
    protected function tearDown(): void
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function tearDown()
Loading history...
16
    {
17
        m::close();
18
    }
19
20
    public function testMake()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function testMake()
Loading history...
21
    {
22
        $event  = m::mock(Event::class);
23
        $config = m::mock(Config::class);
24
        $log    = m::mock(Log::class);
25
        $cache  = m::mock(Cache::class);
26
27
        $db = Db::__make($event, $config, $log, $cache);
0 ignored issues
show
Bug introduced by
$config of type Mockery\LegacyMockInterface|Mockery\MockInterface is incompatible with the type think\Config expected by parameter $config of think\Db::__make(). ( Ignorable by Annotation )

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

27
        $db = Db::__make($event, /** @scrutinizer ignore-type */ $config, $log, $cache);
Loading history...
Bug introduced by
$event of type Mockery\LegacyMockInterface|Mockery\MockInterface is incompatible with the type think\Event expected by parameter $event of think\Db::__make(). ( Ignorable by Annotation )

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

27
        $db = Db::__make(/** @scrutinizer ignore-type */ $event, $config, $log, $cache);
Loading history...
Bug introduced by
$log of type Mockery\LegacyMockInterface|Mockery\MockInterface is incompatible with the type think\Log expected by parameter $log of think\Db::__make(). ( Ignorable by Annotation )

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

27
        $db = Db::__make($event, $config, /** @scrutinizer ignore-type */ $log, $cache);
Loading history...
Bug introduced by
$cache of type Mockery\LegacyMockInterface|Mockery\MockInterface is incompatible with the type think\Cache expected by parameter $cache of think\Db::__make(). ( Ignorable by Annotation )

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

27
        $db = Db::__make($event, $config, $log, /** @scrutinizer ignore-type */ $cache);
Loading history...
28
29
        $config->shouldReceive('get')->with('database.foo', null)->andReturn('foo');
30
        $this->assertEquals('foo', $db->getConfig('foo'));
31
32
        $config->shouldReceive('get')->with('database', [])->andReturn([]);
33
        $this->assertEquals([], $db->getConfig());
34
35
        $callback = function () {
36
        };
37
        $event->shouldReceive('listen')->with('db.some', $callback);
38
        $db->event('some', $callback);
39
40
        $event->shouldReceive('trigger')->with('db.some', null, false);
41
        $db->trigger('some');
42
    }
43
44
}
45