fix tests

This commit is contained in:
Dennis Eichhorn 2023-09-21 12:51:20 +00:00
parent 6805b24820
commit 0c612c339d
2 changed files with 6 additions and 4 deletions

View File

@ -96,12 +96,15 @@ abstract class NgramParser
for ($i = $this->minLength; $i <= $this->maxLength; ++$i) { for ($i = $this->minLength; $i <= $this->maxLength; ++$i) {
for ($j = 0; ($i + $j - 1) < $l; ++$j, ++$tmp) { for ($j = 0; ($i + $j - 1) < $l; ++$j, ++$tmp) {
$tmp = &$tokens[$i][\mb_substr($word, $j, $i)]; if (!isset($tokens[$i][$char = \mb_substr($word, $j, $i)])) {
$tokens[$i][$char] = 0;
}
$tmp = &$tokens[$i][$char];
} }
} }
} }
/** @phpstan-ignore-next-line */
foreach ($tokens as $i => $token) { foreach ($tokens as $i => $token) {
$sum = \array_sum($token); $sum = \array_sum($token);
@ -110,14 +113,12 @@ abstract class NgramParser
} }
} }
/** @phpstan-ignore-next-line */
if (empty($tokens)) { if (empty($tokens)) {
return []; return [];
} }
$tokens = \array_merge(...$tokens); $tokens = \array_merge(...$tokens);
/** @phpstan-ignore-next-line */
if (isset($tokens['_'])) { if (isset($tokens['_'])) {
unset($tokens['_']); unset($tokens['_']);
} }

View File

@ -35,6 +35,7 @@ final class MysqlGrammarTest extends \PHPUnit\Framework\TestCase
protected function setUp() : void protected function setUp() : void
{ {
$this->con = new MysqlConnection($GLOBALS['CONFIG']['db']['core']['masters']['admin']); $this->con = new MysqlConnection($GLOBALS['CONFIG']['db']['core']['masters']['admin']);
$this->con->connect();
} }
/** /**