Issues (119)

tests/ConnectionTest.php (1 issue)

1
<?php
2
3
namespace Nip\Database\Tests;
4
5
use Nip\Database\Adapters\MySQLi;
6
use Nip\Database\Connections\Connection;
7
8
/**
9
 * Class ConnectionTest
10
 * @package Nip\Database\Tests
11
 */
12
class ConnectionTest extends AbstractTest
13
{
14
    /**
15
     * @var \UnitTester
16
     */
17
    protected $tester;
18
19
    /**
20
     * @var Connection
21
     */
22
    protected $connection;
23
24
    public function testNewAdapter()
25
    {
26
        static::assertInstanceOf(
27
            \Nip\Database\Adapters\MySQLi::class,
28
            $this->connection->newAdapter('MySQLi')
29
        );
30
    }
31
32
    public function testGetAdapterClass()
33
    {
34
        static::assertEquals(
35
            '\Nip\Database\Adapters\MySQLi',
36
            $this->connection->getAdapterClass('MySQLi')
37
        );
38
    }
39
40
    /**
41
     * @return array
42
     */
43
    public function newQueryProvider()
44
    {
45
        $types = ['select', 'insert', 'delete'];
46
        $return = [];
47
        foreach ($types as $type) {
48
            $return[] = [$type, 'Nip\Database\Query\\' . ucfirst($type)];
49
        }
50
        return $return;
51
    }
52
53
    /**
54
     * @dataProvider newQueryProvider
55
     *
56
     * @param $type
57
     * @param $class
58
     */
59
    public function testNewQuery($type, $class)
60
    {
61
        $query = $this->connection->newQuery($type);
62
        static::assertInstanceOf($class, $query);
63
    }
64
65
    protected function setUp(): void
66
    {
67
        parent::setUp();
68
        $this->connection = new Connection(false);
0 ignored issues
show
false of type false is incompatible with the type Closure|PDO expected by parameter $pdo of Nip\Database\Connections\Connection::__construct(). ( Ignorable by Annotation )

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

68
        $this->connection = new Connection(/** @scrutinizer ignore-type */ false);
Loading history...
69
    }
70
}
71