/
InlineParameterFormatterTest.php
74 lines (59 loc) · 2.05 KB
/
InlineParameterFormatterTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
declare(strict_types=1);
namespace Doctrine\Migrations\Tests;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\InlineParameterFormatter;
use PHPUnit\Framework\TestCase;
class InlineParameterFormatterTest extends TestCase
{
private Connection $connection;
private AbstractPlatform $platform;
private InlineParameterFormatter $parameterFormatter;
public function testFormatParameters(): void
{
$params = [
0 => 'string value',
1 => 1,
2 => 1.5,
3 => [1, true, false, 'string value'],
4 => true,
5 => false,
6 => 'string value',
7 => 1,
8 => 1.5,
9 => true,
10 => false,
11 => [1, true, false, 'string value'],
'named' => 'string value',
];
$types = [
Types::STRING,
Types::INTEGER,
Types::FLOAT,
Types::SIMPLE_ARRAY,
Types::BOOLEAN,
Types::BOOLEAN,
'unknown',
'unknown',
'unknown',
'unknown',
'unknown',
'unknown',
'unknown',
];
$result = $this->parameterFormatter->formatParameters($params, $types);
$expected = 'with parameters ([string value], [1], [1.5], [1,1,,string value], [], [], [string value], [1], [1.5], [true], [false], [1, true, false, string value], :named => [string value])';
self::assertSame($expected, $result);
}
protected function setUp(): void
{
$this->connection = $this->createMock(Connection::class);
$this->platform = $this->createMock(AbstractPlatform::class);
$this->connection->expects(self::any())
->method('getDatabasePlatform')
->willReturn($this->platform);
$this->parameterFormatter = new InlineParameterFormatter($this->connection);
}
}