Commit a1b01060 authored by Marco Pivetta's avatar Marco Pivetta

CS (alignment, imports, short array syntax, list assignments)

parent 00f13ca3
...@@ -4,6 +4,7 @@ namespace Doctrine\Tests\DBAL\Cache; ...@@ -4,6 +4,7 @@ namespace Doctrine\Tests\DBAL\Cache;
use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\DBAL\Cache\QueryCacheProfile;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use PDO;
class QueryCacheProfileTest extends DbalTestCase class QueryCacheProfileTest extends DbalTestCase
{ {
...@@ -21,44 +22,44 @@ class QueryCacheProfileTest extends DbalTestCase ...@@ -21,44 +22,44 @@ class QueryCacheProfileTest extends DbalTestCase
public function testShouldUseTheGivenCacheKeyIfPresent() public function testShouldUseTheGivenCacheKeyIfPresent()
{ {
$query = 'SELECT * FROM foo WHERE bar = ?'; $query = 'SELECT * FROM foo WHERE bar = ?';
$params = array(666); $params = [666];
$types = array(\PDO::PARAM_INT); $types = [PDO::PARAM_INT];
$connectionParams = array( $connectionParams = array(
'dbname' => 'database_name', 'dbname' => 'database_name',
'user' => 'database_user', 'user' => 'database_user',
'password' => 'database_password', 'password' => 'database_password',
'host' => 'database_host', 'host' => 'database_host',
'driver' => 'database_driver' 'driver' => 'database_driver'
); );
$generatedKeys = $this->queryCacheProfile->generateCacheKeys( list($cacheKey) = $this->queryCacheProfile->generateCacheKeys(
$query, $query,
$params, $params,
$types, $types,
$connectionParams $connectionParams
); );
$this->assertEquals(self::CACHE_KEY, $generatedKeys[0], 'The returned cache key should match the given one'); $this->assertEquals(self::CACHE_KEY, $cacheKey, 'The returned cache key should match the given one');
} }
public function testShouldGenerateAnAutomaticKeyIfNoKeyHasBeenGiven() public function testShouldGenerateAnAutomaticKeyIfNoKeyHasBeenGiven()
{ {
$query = 'SELECT * FROM foo WHERE bar = ?'; $query = 'SELECT * FROM foo WHERE bar = ?';
$params = array(666); $params = [666];
$types = array(\PDO::PARAM_INT); $types = [PDO::PARAM_INT];
$connectionParams = array( $connectionParams = array(
'dbname' => 'database_name', 'dbname' => 'database_name',
'user' => 'database_user', 'user' => 'database_user',
'password' => 'database_password', 'password' => 'database_password',
'host' => 'database_host', 'host' => 'database_host',
'driver' => 'database_driver' 'driver' => 'database_driver'
); );
$this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null); $this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null);
$generatedKeys = $this->queryCacheProfile->generateCacheKeys( list($cacheKey) = $this->queryCacheProfile->generateCacheKeys(
$query, $query,
$params, $params,
$types, $types,
...@@ -67,86 +68,78 @@ class QueryCacheProfileTest extends DbalTestCase ...@@ -67,86 +68,78 @@ class QueryCacheProfileTest extends DbalTestCase
$this->assertNotEquals( $this->assertNotEquals(
self::CACHE_KEY, self::CACHE_KEY,
$generatedKeys[0], $cacheKey,
'The returned cache key should be generated automatically' 'The returned cache key should be generated automatically'
); );
$this->assertNotEmpty($generatedKeys[0], 'The generated cache key should not be empty'); $this->assertNotEmpty($cacheKey, 'The generated cache key should not be empty');
} }
public function testShouldGenerateDifferentKeysForSameQueryAndParamsAndDifferentConnections() public function testShouldGenerateDifferentKeysForSameQueryAndParamsAndDifferentConnections()
{ {
$query = 'SELECT * FROM foo WHERE bar = ?'; $query = 'SELECT * FROM foo WHERE bar = ?';
$params = array(666); $params = [666];
$types = array(\PDO::PARAM_INT); $types = [PDO::PARAM_INT];
$connectionParams = array( $connectionParams = array(
'dbname' => 'database_name', 'dbname' => 'database_name',
'user' => 'database_user', 'user' => 'database_user',
'password' => 'database_password', 'password' => 'database_password',
'host' => 'database_host', 'host' => 'database_host',
'driver' => 'database_driver' 'driver' => 'database_driver'
); );
$this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null); $this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null);
$generatedKeys = $this->queryCacheProfile->generateCacheKeys( list($firstCacheKey) = $this->queryCacheProfile->generateCacheKeys(
$query, $query,
$params, $params,
$types, $types,
$connectionParams $connectionParams
); );
$firstCacheKey = $generatedKeys[0];
$connectionParams['host'] = 'a_different_host'; $connectionParams['host'] = 'a_different_host';
$generatedKeys = $this->queryCacheProfile->generateCacheKeys( list($secondCacheKey) = $this->queryCacheProfile->generateCacheKeys(
$query, $query,
$params, $params,
$types, $types,
$connectionParams $connectionParams
); );
$secondCacheKey = $generatedKeys[0];
$this->assertNotEquals($firstCacheKey, $secondCacheKey, 'Cache keys should be different'); $this->assertNotEquals($firstCacheKey, $secondCacheKey, 'Cache keys should be different');
} }
public function testShouldGenerateSameKeysIfNoneOfTheParamsChanges() public function testShouldGenerateSameKeysIfNoneOfTheParamsChanges()
{ {
$query = 'SELECT * FROM foo WHERE bar = ?'; $query = 'SELECT * FROM foo WHERE bar = ?';
$params = array(666); $params = [666];
$types = array(\PDO::PARAM_INT); $types = [PDO::PARAM_INT];
$connectionParams = array( $connectionParams = array(
'dbname' => 'database_name', 'dbname' => 'database_name',
'user' => 'database_user', 'user' => 'database_user',
'password' => 'database_password', 'password' => 'database_password',
'host' => 'database_host', 'host' => 'database_host',
'driver' => 'database_driver' 'driver' => 'database_driver'
); );
$this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null); $this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null);
$generatedKeys = $this->queryCacheProfile->generateCacheKeys( list($firstCacheKey) = $this->queryCacheProfile->generateCacheKeys(
$query, $query,
$params, $params,
$types, $types,
$connectionParams $connectionParams
); );
$firstCacheKey = $generatedKeys[0]; list($secondCacheKey) = $this->queryCacheProfile->generateCacheKeys(
$generatedKeys = $this->queryCacheProfile->generateCacheKeys(
$query, $query,
$params, $params,
$types, $types,
$connectionParams $connectionParams
); );
$secondCacheKey = $generatedKeys[0];
$this->assertEquals($firstCacheKey, $secondCacheKey, 'Cache keys should be the same'); $this->assertEquals($firstCacheKey, $secondCacheKey, 'Cache keys should be the same');
} }
} }
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