Skip to content

Commit

Permalink
Merge pull request #3599 from morozov/unicode
Browse files Browse the repository at this point in the history
Make sure that (VAR)CHAR column length is specified in characters, not bytes
  • Loading branch information
morozov committed Jun 27, 2019
2 parents e21df87 + d59501b commit 7735218
Showing 1 changed file with 37 additions and 6 deletions.
43 changes: 37 additions & 6 deletions tests/Doctrine/Tests/DBAL/Functional/Platform/ColumnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,53 @@ public function testVariableLengthStringNoLength() : void
$this->assertColumn(Types::STRING, [], 'Test', ParameterType::STRING);
}

public function testVariableLengthStringWithLength() : void
/**
* @dataProvider string8Provider
*/
public function testVariableLengthStringWithLength(string $value) : void
{
$this->assertColumn(Types::STRING, ['length' => 8], 'Doctrine', ParameterType::STRING);
$this->assertColumn(Types::STRING, ['length' => 8], $value, ParameterType::STRING);
}

public function testFixedLengthStringNoLength() : void
/**
* @dataProvider string1Provider
*/
public function testFixedLengthStringNoLength(string $value) : void
{
$this->assertColumn(Types::STRING, ['fixed' => true], 'Z', ParameterType::STRING);
$this->assertColumn(Types::STRING, ['fixed' => true], $value, ParameterType::STRING);
}

public function testFixedLengthStringWithLength() : void
/**
* @dataProvider string8Provider
*/
public function testFixedLengthStringWithLength(string $value) : void
{
$this->assertColumn(Types::STRING, [
'fixed' => true,
'length' => 8,
], 'Doctrine', ParameterType::STRING);
], $value, ParameterType::STRING);
}

/**
* @return iterable<string, array<int, mixed>>
*/
public static function string1Provider() : iterable
{
return [
'ansi' => ['Z'],
'unicode' => ['Я'],
];
}

/**
* @return iterable<string, array<int, mixed>>
*/
public static function string8Provider() : iterable
{
return [
'ansi' => ['Doctrine'],
'unicode' => ['Доктрина'],
];
}

public function testVariableLengthBinaryNoLength() : void
Expand Down

0 comments on commit 7735218

Please sign in to comment.