Passed
Pull Request — master (#380)
by Wilmer
06:00 queued 02:33
created

ConnectionTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
dl 0
loc 30
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testNestedTransactionNotSupported() 0 14 1
A testGetTableSchema() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Tests\Connection;
6
7
use Yiisoft\Db\Driver\PDO\ConnectionPDOInterface;
8
use Yiisoft\Db\Exception\NotSupportedException;
9
use Yiisoft\Db\Tests\AbstractConnectionTest;
10
use Yiisoft\Db\Tests\Support\TestTrait;
11
12
/**
13
 * @group db
14
 *
15
 * @psalm-suppress PropertyNotSetInConstructor
16
 */
17
final class ConnectionTest extends AbstractConnectionTest
18
{
19
    use TestTrait;
20
21
    public function testGetTableSchema(): void
22
    {
23
        $db = $this->getConnection();
24
25
        $this->expectException(NotSupportedException::class);
26
        $this->expectExceptionMessage(
27
            'Yiisoft\Db\Tests\Support\Stubs\Schema::loadTableSchema() is not supported by core-db.'
28
        );
29
30
        $db->getTableSchema('non_existing_table');
31
    }
32
33
    public function testNestedTransactionNotSupported(): void
34
    {
35
        $db = $this->getConnection();
36
37
        $db->setEnableSavepoint(false);
38
39
        $this->assertFalse($db->isSavepointEnabled());
40
41
        $db->transaction(
42
            function (ConnectionPDOInterface $db) {
43
                $this->assertNotNull($db->getTransaction());
44
                $this->expectException(NotSupportedException::class);
45
46
                $db->beginTransaction();
47
            }
48
        );
49
    }
50
}
51