Passed
Pull Request — master (#380)
by Wilmer
13:00 queued 10:01
created

TestTrait::getConnection()   A

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
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Tests\Support;
6
7
use Psr\Log\LoggerInterface;
8
use Yiisoft\Cache\CacheInterface;
9
use Yiisoft\Db\Cache\QueryCache;
10
use Yiisoft\Db\Cache\SchemaCache;
11
use Yiisoft\Db\Driver\PDO\ConnectionPDOInterface;
12
use Yiisoft\Db\Query\Query;
13
use Yiisoft\Db\Schema\Quoter;
14
use Yiisoft\Db\Schema\QuoterInterface;
15
use Yiisoft\Profiler\ProfilerInterface;
16
17
trait TestTrait
18
{
19
    protected function getConnection(): ConnectionPDOInterface
20
    {
21
        return Mock::getConnection();
22
    }
23
24
    protected function getConnectionWithData(): ConnectionPDOInterface
25
    {
26
        return  Mock::getConnection(true);
27
    }
28
29
    protected function getConnectionWithDsn(string $dsn): ConnectionPDOInterface
30
    {
31
        return Mock::getConnection(false, $dsn);
32
    }
33
34
    protected function getCache(): CacheInterface
35
    {
36
        return Mock::getCache();
37
    }
38
39
    protected function getQuery(ConnectionPDOInterface $db): Query
40
    {
41
        return new Query($db);
42
    }
43
44
    protected function getQuoter(): QuoterInterface
45
    {
46
        return new Quoter('`', '`', '');
47
    }
48
49
    protected function getLogger(): LoggerInterface
50
    {
51
        return  Mock::getLogger();
52
    }
53
54
    protected function getQueryCache(): QueryCache
55
    {
56
        return  Mock::getQueryCache();
57
    }
58
59
    protected function getSchemaCache(): SchemaCache
60
    {
61
        return  Mock::getSchemaCache();
62
    }
63
64
    protected function getProfiler(): ProfilerInterface
65
    {
66
        return  Mock::getProfiler();
67
    }
68
}
69