Passed
Pull Request — master (#429)
by Wilmer
09:08 queued 06:21
created

QuoterTest::testQuoteValueNotString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 8
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Tests\Schema;
6
7
use Yiisoft\Db\Schema\Quoter;
8
use Yiisoft\Db\Tests\AbstractQuoterTest;
9
use Yiisoft\Db\Tests\Support\TestTrait;
10
11
/**
12
 * @group db
13
 *
14
 * @psalm-suppress PropertyNotSetInConstructor
15
 */
16
final class QuoterTest extends AbstractQuoterTest
17
{
18
    use TestTrait;
19
20
    public function testQuoteSimpleColumnNameWithStartingCharacterEndingCharacterEquals(): void
21
    {
22
        $quoter = new Quoter('`', '`');
23
24
        $this->assertSame('`column`', $quoter->quoteSimpleColumnName('column'));
25
    }
26
27
    public function testQuoteSimpleTableNameWithStartingCharacterEndingCharacterEquals(): void
28
    {
29
        $quoter = new Quoter('`', '`');
30
31
        $this->assertSame('`table`', $quoter->quoteSimpleTableName('table'));
32
    }
33
34
    public function testQuoteTableNameWithSchema(): void
35
    {
36
        $quoter = new Quoter('`', '`');
37
38
        $this->assertSame('`schema`.`table`', $quoter->quoteTableName('schema.table'));
39
    }
40
41
    public function testQuoteValueNotString(): void
42
    {
43
        $quoter = new Quoter('`', '`');
44
45
        $this->assertFalse($quoter->quoteValue(false));
46
        $this->assertTrue($quoter->quoteValue(true));
47
        $this->assertSame(1, $quoter->quoteValue(1));
48
        $this->assertSame([], $quoter->quoteValue([]));
49
    }
50
51
    public function testUnquoteSimpleColumnNameWithStartingCharacterEndingCharacterEquals(): void
52
    {
53
        $quoter = new Quoter('`', '`');
54
55
        $this->assertSame('column', $quoter->unquoteSimpleColumnName('`column`'));
56
    }
57
}
58