Passed
Pull Request — master (#380)
by Wilmer
16:46 queued 13:55
created

ConnectionTest::testGetTableSchema()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 10
rs 10
c 0
b 0
f 0
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