Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.14.x fix uniqid in test #223

Open
wants to merge 1 commit into
base: 2.19.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions test/unit/Sql/AbstractSqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Laminas\Db\Sql\Predicate;
use Laminas\Db\Sql\Select;
use LaminasTest\Db\TestAsset\TrustingSql92Platform;
use PHPUnit\Exception;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use ReflectionMethod;
Expand Down Expand Up @@ -147,11 +148,39 @@ public function testProcessExpressionWorksWithExpressionObjectWithPercentageSign
public function testProcessExpressionWorksWithNamedParameterPrefix()
{
$parameterContainer = new ParameterContainer();
$namedParameterPrefix = uniqid();
$namedParameterPrefix = 'prefix-' . uniqid();
$expression = new Expression('FROM_UNIXTIME(?)', [10000000]);
$this->invokeProcessExpressionMethod($expression, $parameterContainer, $namedParameterPrefix);

self::assertSame($namedParameterPrefix . '1', key($parameterContainer->getNamedArray()));
$expectedValue = $namedParameterPrefix . '1';
$currentValue = key($parameterContainer->getNamedArray());

self::assertSame($expectedValue, $currentValue);
}

/**
* Numeric prefix give an error.
*
* @see: https://discourse.laminas.dev/t/why-qa-check-of-laminas-db-220-is-fail/2521
* @see: https://github.com/laminas/laminas-db/pull/220
*/
public function testProcessExpressionWorksWithNamedParameterPrefixNumericIsFail()
{
$parameterContainer = new ParameterContainer();
$namedParameterPrefix = 61507378202901;
$expression = new Expression('FROM_UNIXTIME(?)', [10000000]);
$this->invokeProcessExpressionMethod($expression, $parameterContainer, $namedParameterPrefix);

$expectedValue = $namedParameterPrefix . '1';
$currentValue = key($parameterContainer->getNamedArray());
try {
self::assertSame($expectedValue, $currentValue);
} catch (Exception $e) {
$expectedValue = 'Failed asserting that 615073782029011 is identical to \'615073782029011\'.';
$currentValue = $e->getMessage();

self::assertSame($expectedValue, $currentValue);
}
}

public function testProcessExpressionWorksWithNamedParameterPrefixContainingWhitespace()
Expand Down