Skip to content

Commit

Permalink
zero len test
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Nov 22, 2021
1 parent 8491d14 commit a758990
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions tests/Schema/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,21 @@ public function testCharacterTypeFieldLong(string $type, bool $isBinary, int $le
$lengthBytes = min($lengthBytes, 8190);
}

$str = $this->makePseudoRandomString($isBinary, $lengthBytes - 1);
if (!$isBinary) {
$str = preg_replace('~[\x00-\x1f]~', '-', $str);
if ($lengthBytes === 0) {
$str = '';

// TODO Oracle converts empty string to NULL
// https://stackoverflow.com/questions/13278773/null-vs-empty-string-in-oracle
if ($this->getDatabasePlatform() instanceof OraclePlatform && in_array($type, ['string', 'text'], true)) {
$str = 'x';
}
} else {
$str = $this->makePseudoRandomString($isBinary, $lengthBytes - 1);
if (!$isBinary) {
$str = preg_replace('~[\x00-\x1f]~', '-', $str);
}
$this->assertSame($lengthBytes - 1, strlen($str));
}
$this->assertSame($lengthBytes - 1, strlen($str));

$model = new Model($this->db, ['table' => 'user']);
$model->addField('v', ['type' => $type]);
Expand Down Expand Up @@ -225,6 +235,10 @@ public function testCharacterTypeFieldLong(string $type, bool $isBinary, int $le
public function providerCharacterTypeFieldLongData(): array
{
return [
['string', false, 0],
['binary', true, 0],
['text', false, 0],
['blob', true, 0],
['string', false, 255],
['binary', true, 255],
['text', false, 255],
Expand Down

0 comments on commit a758990

Please sign in to comment.