mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
test fixes
This commit is contained in:
parent
a4f7d2e527
commit
2cbbe69bac
|
|
@ -60,6 +60,10 @@ class MysqlGrammar extends Grammar
|
|||
$expression = '*';
|
||||
}
|
||||
|
||||
return 'SELECT ' . $expression . ' ' . $this->compileFrom($query, $query->from) . ' ' . $this->compileWheres($query, $query->wheres) . ' ORDER BY RAND() ' . $this->compileLimit($query, $query->limit ?? 1);
|
||||
return 'SELECT ' . $expression
|
||||
. ' ' . $this->compileFrom($query, $query->from)
|
||||
. ' ' . $this->compileWheres($query, $query->wheres)
|
||||
. ' ORDER BY RAND() '
|
||||
. $this->compileLimit($query, $query->limit ?? 1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -759,6 +759,20 @@ class Matrix implements \ArrayAccess, \Iterator
|
|||
$result[$i] = $temp;
|
||||
}
|
||||
|
||||
return self::fromArray($result);
|
||||
} elseif (!$isMatrix1 && $isMatrix2) {
|
||||
$result = [];
|
||||
for ($i = 0; $i < $m1; ++$i) { // Row of 1
|
||||
$temp = 0;
|
||||
|
||||
for ($c = 0; $c < $m2; ++$c) { // Row of 2
|
||||
/** @var array $value1 */
|
||||
$temp += $value2[$i][$c] * $value1[$c];
|
||||
}
|
||||
|
||||
$result[$i] = $temp;
|
||||
}
|
||||
|
||||
return self::fromArray($result);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
|
|||
$iE = $con->getGrammar()->systemIdentifierEnd;
|
||||
|
||||
$query = new Builder($con);
|
||||
$sql = 'SELECT [a].[test] FROM [a] as b WHERE [a].[test] = 1 ORDER BY \rand() LIMIT 1;';
|
||||
$sql = 'SELECT [a].[test] FROM [a] as b WHERE [a].[test] = 1 ORDER BY RAND() LIMIT 1;';
|
||||
$sql = \strtr($sql, '[]', $iS . $iE);
|
||||
self::assertEquals($sql, $query->random('a.test')->fromAs('a', 'b')->where('a.test', '=', 1)->toSql());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -495,7 +495,7 @@ final class MatrixTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
public function testDotVectors() : void
|
||||
{
|
||||
$v1 = Vector::fromArray([1, 3, -5]);
|
||||
$v1 = Vector::fromArray([1, 3, -5])->transpose();
|
||||
|
||||
self::assertEquals(
|
||||
3,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user