Passed
Pull Request — master (#408)
by Wilmer
02:37
created

CommonColumnSchemaBuilderTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 25
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testCustomTypes() 0 3 1
A checkBuildString() 0 13 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Tests\Common;
6
7
use PHPUnit\Framework\TestCase;
8
use Yiisoft\Db\Tests\Support\TestTrait;
9
10
use function array_shift;
11
use function call_user_func_array;
12
13
abstract class CommonColumnSchemaBuilderTest extends TestCase
14
{
15
    use TestTrait;
16
17
    /**
18
     * @dataProvider \Yiisoft\Db\Tests\Provider\ColumnSchemaBuilderProvider::types();
19
     */
20
    public function testCustomTypes(string $expected, string $type, int|null $length, array $calls): void
21
    {
22
        $this->checkBuildString($expected, $type, $length, $calls);
23
    }
24
25
    protected function checkBuildString(string $expected, string $type, int|null $length, array $calls): void
26
    {
27
        $db = $this->getConnection();
28
29
        $schema = $db->getSchema();
30
        $builder = $schema->createColumnSchemaBuilder($type, $length);
31
32
        foreach ($calls as $call) {
33
            $method = array_shift($call);
34
            call_user_func_array([$builder, $method], $call);
35
        }
36
37
        $this->assertSame($expected, $builder->__toString());
38
    }
39
}
40