Unverified Commit 9d1edb72 authored by Kim Hemsø Rasmussen's avatar Kim Hemsø Rasmussen Committed by Marco Pivetta

Added failure test where platform from params is passed to QueryCacheProfile::generateCacheKeys()

parent 324f3ac2
......@@ -9,6 +9,7 @@ use Doctrine\DBAL\Configuration;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Events;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\Tests\Mocks\DriverConnectionMock;
use Doctrine\Tests\Mocks\DriverMock;
use Doctrine\DBAL\Cache\ArrayStatement;
......@@ -777,6 +778,49 @@ class ConnectionTest extends \Doctrine\Tests\DbalTestCase
);
}
public function testShouldNotPassPlatformInParamsToTheQueryCacheProfileInExecuteCacheQuery()
{
$resultCacheDriverMock = $this->createMock(Cache::class);
$resultCacheDriverMock
->expects($this->atLeastOnce())
->method('fetch')
->with('cacheKey')
->will($this->returnValue(['realKey' => []]));
$query = 'SELECT * FROM foo WHERE bar = ?';
$params = [666];
$types = [\PDO::PARAM_INT];
/* @var $queryCacheProfileMock QueryCacheProfile|\PHPUnit_Framework_MockObject_MockObject */
$queryCacheProfileMock = $this->createMock(QueryCacheProfile::class);
$queryCacheProfileMock
->expects($this->any())
->method('getResultCacheDriver')
->will($this->returnValue($resultCacheDriverMock));
$connectionParams = $this->params;
$expectedParams = $connectionParams;
$connectionParams["platform"] = $this->createMock(AbstractPlatform::class);
// This is our main expectation
$queryCacheProfileMock
->expects($this->once())
->method('generateCacheKeys')
->with($query, $params, $types, $expectedParams)
->will($this->returnValue(['cacheKey', 'realKey']));
/* @var $driver Driver */
$driver = $this->createMock(Driver::class);
$this->assertInstanceOf(
ArrayStatement::class,
(new Connection($connectionParams, $driver))->executeCacheQuery($query, $params, $types, $queryCacheProfileMock)
);
}
/**
* @group DBAL-990
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment