1
0
mirror of synced 2025-02-02 13:31:45 +03:00

Use short-array syntax on "tests" directory

This commit is contained in:
Luís Cobucci 2016-12-07 23:33:41 +01:00
parent 1d5e16e9d9
commit 74c8a08828
No known key found for this signature in database
GPG Key ID: 8042585A7DBC92E1
371 changed files with 4924 additions and 3869 deletions

View File

@ -17,7 +17,7 @@ class CacheMetadataListener
* *
* @var array * @var array
*/ */
protected $enabledItems = array(); protected $enabledItems = [];
/** /**
* @param \Doctrine\Common\Persistence\Event\LoadClassMetadataEventArgs $event * @param \Doctrine\Common\Persistence\Event\LoadClassMetadataEventArgs $event
@ -63,9 +63,9 @@ class CacheMetadataListener
return; // Already handled in the past return; // Already handled in the past
} }
$cache = array( $cache = [
'usage' => ClassMetadata::CACHE_USAGE_NONSTRICT_READ_WRITE 'usage' => ClassMetadata::CACHE_USAGE_NONSTRICT_READ_WRITE
); ];
if ($metadata->isVersioned) { if ($metadata->isVersioned) {
return; return;

View File

@ -13,8 +13,8 @@ use Doctrine\ORM\Cache\Region;
*/ */
class CacheRegionMock implements Region class CacheRegionMock implements Region
{ {
public $calls = array(); public $calls = [];
public $returns = array(); public $returns = [];
public $name; public $name;
/** /**
@ -50,7 +50,7 @@ class CacheRegionMock implements Region
*/ */
public function getName() public function getName()
{ {
$this->calls[__FUNCTION__][] = array(); $this->calls[__FUNCTION__][] = [];
return $this->name; return $this->name;
} }
@ -60,7 +60,7 @@ class CacheRegionMock implements Region
*/ */
public function contains(CacheKey $key) public function contains(CacheKey $key)
{ {
$this->calls[__FUNCTION__][] = array('key' => $key); $this->calls[__FUNCTION__][] = ['key' => $key];
return $this->getReturn(__FUNCTION__, false); return $this->getReturn(__FUNCTION__, false);
} }
@ -70,7 +70,7 @@ class CacheRegionMock implements Region
*/ */
public function evict(CacheKey $key) public function evict(CacheKey $key)
{ {
$this->calls[__FUNCTION__][] = array('key' => $key); $this->calls[__FUNCTION__][] = ['key' => $key];
return $this->getReturn(__FUNCTION__, true); return $this->getReturn(__FUNCTION__, true);
} }
@ -80,7 +80,7 @@ class CacheRegionMock implements Region
*/ */
public function evictAll() public function evictAll()
{ {
$this->calls[__FUNCTION__][] = array(); $this->calls[__FUNCTION__][] = [];
return $this->getReturn(__FUNCTION__, true); return $this->getReturn(__FUNCTION__, true);
} }
@ -90,7 +90,7 @@ class CacheRegionMock implements Region
*/ */
public function get(CacheKey $key) public function get(CacheKey $key)
{ {
$this->calls[__FUNCTION__][] = array('key' => $key); $this->calls[__FUNCTION__][] = ['key' => $key];
return $this->getReturn(__FUNCTION__, null); return $this->getReturn(__FUNCTION__, null);
} }
@ -100,7 +100,7 @@ class CacheRegionMock implements Region
*/ */
public function getMultiple(CollectionCacheEntry $collection) public function getMultiple(CollectionCacheEntry $collection)
{ {
$this->calls[__FUNCTION__][] = array('collection' => $collection); $this->calls[__FUNCTION__][] = ['collection' => $collection];
return $this->getReturn(__FUNCTION__, null); return $this->getReturn(__FUNCTION__, null);
} }
@ -110,7 +110,7 @@ class CacheRegionMock implements Region
*/ */
public function put(CacheKey $key, CacheEntry $entry, Lock $lock = null) public function put(CacheKey $key, CacheEntry $entry, Lock $lock = null)
{ {
$this->calls[__FUNCTION__][] = array('key' => $key, 'entry' => $entry); $this->calls[__FUNCTION__][] = ['key' => $key, 'entry' => $entry];
return $this->getReturn(__FUNCTION__, true); return $this->getReturn(__FUNCTION__, true);
} }
@ -120,7 +120,7 @@ class CacheRegionMock implements Region
*/ */
public function clear() public function clear()
{ {
$this->calls = array(); $this->calls = [];
$this->returns = array(); $this->returns = [];
} }
} }

View File

@ -17,9 +17,9 @@ use Doctrine\ORM\Cache\Lock;
*/ */
class ConcurrentRegionMock implements ConcurrentRegion class ConcurrentRegionMock implements ConcurrentRegion
{ {
public $calls = array(); public $calls = [];
public $exceptions = array(); public $exceptions = [];
public $locks = array(); public $locks = [];
/** /**
* @var \Doctrine\ORM\Cache\Region * @var \Doctrine\ORM\Cache\Region
@ -80,7 +80,7 @@ class ConcurrentRegionMock implements ConcurrentRegion
*/ */
public function contains(CacheKey $key) public function contains(CacheKey $key)
{ {
$this->calls[__FUNCTION__][] = array('key' => $key); $this->calls[__FUNCTION__][] = ['key' => $key];
if (isset($this->locks[$key->hash])) { if (isset($this->locks[$key->hash])) {
return false; return false;
@ -96,7 +96,7 @@ class ConcurrentRegionMock implements ConcurrentRegion
*/ */
public function evict(CacheKey $key) public function evict(CacheKey $key)
{ {
$this->calls[__FUNCTION__][] = array('key' => $key); $this->calls[__FUNCTION__][] = ['key' => $key];
$this->throwException(__FUNCTION__); $this->throwException(__FUNCTION__);
@ -108,7 +108,7 @@ class ConcurrentRegionMock implements ConcurrentRegion
*/ */
public function evictAll() public function evictAll()
{ {
$this->calls[__FUNCTION__][] = array(); $this->calls[__FUNCTION__][] = [];
$this->throwException(__FUNCTION__); $this->throwException(__FUNCTION__);
@ -120,7 +120,7 @@ class ConcurrentRegionMock implements ConcurrentRegion
*/ */
public function get(CacheKey $key) public function get(CacheKey $key)
{ {
$this->calls[__FUNCTION__][] = array('key' => $key); $this->calls[__FUNCTION__][] = ['key' => $key];
$this->throwException(__FUNCTION__); $this->throwException(__FUNCTION__);
@ -136,7 +136,7 @@ class ConcurrentRegionMock implements ConcurrentRegion
*/ */
public function getMultiple(CollectionCacheEntry $collection) public function getMultiple(CollectionCacheEntry $collection)
{ {
$this->calls[__FUNCTION__][] = array('collection' => $collection); $this->calls[__FUNCTION__][] = ['collection' => $collection];
$this->throwException(__FUNCTION__); $this->throwException(__FUNCTION__);
@ -148,7 +148,7 @@ class ConcurrentRegionMock implements ConcurrentRegion
*/ */
public function getName() public function getName()
{ {
$this->calls[__FUNCTION__][] = array(); $this->calls[__FUNCTION__][] = [];
$this->throwException(__FUNCTION__); $this->throwException(__FUNCTION__);
@ -160,7 +160,7 @@ class ConcurrentRegionMock implements ConcurrentRegion
*/ */
public function put(CacheKey $key, CacheEntry $entry, Lock $lock = null) public function put(CacheKey $key, CacheEntry $entry, Lock $lock = null)
{ {
$this->calls[__FUNCTION__][] = array('key' => $key, 'entry' => $entry); $this->calls[__FUNCTION__][] = ['key' => $key, 'entry' => $entry];
$this->throwException(__FUNCTION__); $this->throwException(__FUNCTION__);
@ -181,7 +181,7 @@ class ConcurrentRegionMock implements ConcurrentRegion
*/ */
public function lock(CacheKey $key) public function lock(CacheKey $key)
{ {
$this->calls[__FUNCTION__][] = array('key' => $key); $this->calls[__FUNCTION__][] = ['key' => $key];
$this->throwException(__FUNCTION__); $this->throwException(__FUNCTION__);
@ -197,7 +197,7 @@ class ConcurrentRegionMock implements ConcurrentRegion
*/ */
public function unlock(CacheKey $key, Lock $lock) public function unlock(CacheKey $key, Lock $lock)
{ {
$this->calls[__FUNCTION__][] = array('key' => $key, 'lock' => $lock); $this->calls[__FUNCTION__][] = ['key' => $key, 'lock' => $lock];
$this->throwException(__FUNCTION__); $this->throwException(__FUNCTION__);

View File

@ -26,12 +26,12 @@ class ConnectionMock extends Connection
/** /**
* @var array * @var array
*/ */
private $_inserts = array(); private $_inserts = [];
/** /**
* @var array * @var array
*/ */
private $_executeUpdates = array(); private $_executeUpdates = [];
/** /**
* @param array $params * @param array $params
@ -60,7 +60,7 @@ class ConnectionMock extends Connection
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function insert($tableName, array $data, array $types = array()) public function insert($tableName, array $data, array $types = [])
{ {
$this->_inserts[$tableName][] = $data; $this->_inserts[$tableName][] = $data;
} }
@ -68,9 +68,9 @@ class ConnectionMock extends Connection
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function executeUpdate($query, array $params = array(), array $types = array()) public function executeUpdate($query, array $params = [], array $types = [])
{ {
$this->_executeUpdates[] = array('query' => $query, 'params' => $params, 'types' => $types); $this->_executeUpdates[] = ['query' => $query, 'params' => $params, 'types' => $types];
} }
/** /**
@ -84,7 +84,7 @@ class ConnectionMock extends Connection
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function fetchColumn($statement, array $params = array(), $colnum = 0, array $types = array()) public function fetchColumn($statement, array $params = [], $colnum = 0, array $types = [])
{ {
return $this->_fetchOneResult; return $this->_fetchOneResult;
} }
@ -153,7 +153,7 @@ class ConnectionMock extends Connection
*/ */
public function reset() public function reset()
{ {
$this->_inserts = array(); $this->_inserts = [];
$this->_lastInsertId = 0; $this->_lastInsertId = 0;
} }
} }

View File

@ -25,7 +25,7 @@ class DriverMock implements Driver
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function connect(array $params, $username = null, $password = null, array $driverOptions = array()) public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
{ {
return new DriverConnectionMock(); return new DriverConnectionMock();
} }

View File

@ -72,7 +72,7 @@ class EntityManagerMock extends EntityManager
$config = new Configuration(); $config = new Configuration();
$config->setProxyDir(__DIR__ . '/../Proxies'); $config->setProxyDir(__DIR__ . '/../Proxies');
$config->setProxyNamespace('Doctrine\Tests\Proxies'); $config->setProxyNamespace('Doctrine\Tests\Proxies');
$config->setMetadataDriverImpl($config->newDefaultAnnotationDriver(array(), true)); $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver([], true));
} }
if (null === $eventManager) { if (null === $eventManager) {
$eventManager = new EventManager(); $eventManager = new EventManager();

View File

@ -14,17 +14,17 @@ class EntityPersisterMock extends BasicEntityPersister
/** /**
* @var array * @var array
*/ */
private $inserts = array(); private $inserts = [];
/** /**
* @var array * @var array
*/ */
private $updates = array(); private $updates = [];
/** /**
* @var array * @var array
*/ */
private $deletes = array(); private $deletes = [];
/** /**
* @var int * @var int
@ -39,7 +39,7 @@ class EntityPersisterMock extends BasicEntityPersister
/** /**
* @var array * @var array
*/ */
private $postInsertIds = array(); private $postInsertIds = [];
/** /**
* @var bool * @var bool
@ -57,10 +57,10 @@ class EntityPersisterMock extends BasicEntityPersister
if ( ! is_null($this->mockIdGeneratorType) && $this->mockIdGeneratorType == ClassMetadata::GENERATOR_TYPE_IDENTITY if ( ! is_null($this->mockIdGeneratorType) && $this->mockIdGeneratorType == ClassMetadata::GENERATOR_TYPE_IDENTITY
|| $this->class->isIdGeneratorIdentity()) { || $this->class->isIdGeneratorIdentity()) {
$id = $this->identityColumnValueCounter++; $id = $this->identityColumnValueCounter++;
$this->postInsertIds[] = array( $this->postInsertIds[] = [
'generatedId' => $id, 'generatedId' => $id,
'entity' => $entity, 'entity' => $entity,
); ];
return $id; return $id;
} }
return null; return null;
@ -139,9 +139,9 @@ class EntityPersisterMock extends BasicEntityPersister
{ {
$this->existsCalled = false; $this->existsCalled = false;
$this->identityColumnValueCounter = 0; $this->identityColumnValueCounter = 0;
$this->inserts = array(); $this->inserts = [];
$this->updates = array(); $this->updates = [];
$this->deletes = array(); $this->deletes = [];
} }
/** /**

View File

@ -108,7 +108,7 @@ class HydratorMockStatement implements \IteratorAggregate, Statement
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function execute($params = array()) public function execute($params = [])
{ {
} }

View File

@ -30,6 +30,6 @@ class MetadataDriverMock implements MappingDriver
*/ */
public function getAllClassNames() public function getAllClassNames()
{ {
return array(); return [];
} }
} }

View File

@ -17,7 +17,7 @@ class TaskMock extends \Doctrine\Common\Cli\Tasks\AbstractTask
* *
* @var array (TaskMock) * @var array (TaskMock)
*/ */
static public $instances = array(); static public $instances = [];
/** /**
* @var int * @var int

View File

@ -14,6 +14,6 @@ class TimestampRegionMock extends CacheRegionMock implements TimestampRegion
{ {
public function update(CacheKey $key) public function update(CacheKey $key)
{ {
$this->calls[__FUNCTION__][] = array('key' => $key); $this->calls[__FUNCTION__][] = ['key' => $key];
} }
} }

View File

@ -12,7 +12,7 @@ class UnitOfWorkMock extends UnitOfWork
/** /**
* @var array * @var array
*/ */
private $_mockDataChangeSets = array(); private $_mockDataChangeSets = [];
/** /**
* @var array|null * @var array|null

View File

@ -124,91 +124,115 @@ class CmsAddress
public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
{ {
$metadata->setPrimaryTable(array( $metadata->setPrimaryTable(
[
'name' => 'company_person', 'name' => 'company_person',
)); ]
);
$metadata->mapField(array ( $metadata->mapField(
[
'id' => true, 'id' => true,
'fieldName' => 'id', 'fieldName' => 'id',
'type' => 'integer', 'type' => 'integer',
)); ]
);
$metadata->mapField(array ( $metadata->mapField(
[
'fieldName' => 'zip', 'fieldName' => 'zip',
'length' => 50, 'length' => 50,
)); ]
);
$metadata->mapField(array ( $metadata->mapField(
[
'fieldName' => 'city', 'fieldName' => 'city',
'length' => 50, 'length' => 50,
)); ]
);
$metadata->mapOneToOne(array( $metadata->mapOneToOne(
[
'fieldName' => 'user', 'fieldName' => 'user',
'targetEntity' => 'CmsUser', 'targetEntity' => 'CmsUser',
'joinColumns' => array(array('referencedColumnName' => 'id')) 'joinColumns' => [['referencedColumnName' => 'id']]
)); ]
);
$metadata->addNamedNativeQuery(array ( $metadata->addNamedNativeQuery(
[
'name' => 'find-all', 'name' => 'find-all',
'query' => 'SELECT id, country, city FROM cms_addresses', 'query' => 'SELECT id, country, city FROM cms_addresses',
'resultSetMapping' => 'mapping-find-all', 'resultSetMapping' => 'mapping-find-all',
)); ]
);
$metadata->addNamedNativeQuery(array ( $metadata->addNamedNativeQuery(
[
'name' => 'find-by-id', 'name' => 'find-by-id',
'query' => 'SELECT * FROM cms_addresses WHERE id = ?', 'query' => 'SELECT * FROM cms_addresses WHERE id = ?',
'resultClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsAddress', 'resultClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsAddress',
)); ]
);
$metadata->addNamedNativeQuery(array ( $metadata->addNamedNativeQuery(
[
'name' => 'count', 'name' => 'count',
'query' => 'SELECT COUNT(*) AS count FROM cms_addresses', 'query' => 'SELECT COUNT(*) AS count FROM cms_addresses',
'resultSetMapping' => 'mapping-count', 'resultSetMapping' => 'mapping-count',
)); ]
);
$metadata->addSqlResultSetMapping(array ( $metadata->addSqlResultSetMapping(
[
'name' => 'mapping-find-all', 'name' => 'mapping-find-all',
'columns' => array(), 'columns' => [],
'entities' => array ( array ( 'entities' => [
'fields' => array ( [
array ( 'fields' => [
[
'name' => 'id', 'name' => 'id',
'column' => 'id', 'column' => 'id',
), ],
array ( [
'name' => 'city', 'name' => 'city',
'column' => 'city', 'column' => 'city',
), ],
array ( [
'name' => 'country', 'name' => 'country',
'column' => 'country', 'column' => 'country',
), ],
), ],
'entityClass' => 'Doctrine\Tests\Models\CMS\CmsAddress', 'entityClass' => 'Doctrine\Tests\Models\CMS\CmsAddress',
), ],
), ],
)); ]
);
$metadata->addSqlResultSetMapping(array ( $metadata->addSqlResultSetMapping(
[
'name' => 'mapping-without-fields', 'name' => 'mapping-without-fields',
'columns' => array(), 'columns' => [],
'entities' => array(array ( 'entities' => [
[
'entityClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsAddress', 'entityClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsAddress',
'fields' => array() 'fields' => []
) ]
) ]
)); ]
);
$metadata->addSqlResultSetMapping(array ( $metadata->addSqlResultSetMapping(
[
'name' => 'mapping-count', 'name' => 'mapping-count',
'columns' =>array ( 'columns' => [
array ( [
'name' => 'count', 'name' => 'count',
), ],
) ]
)); ]
);
$metadata->addEntityListener(\Doctrine\ORM\Events::postPersist, 'CmsAddressListener', 'postPersist'); $metadata->addEntityListener(\Doctrine\ORM\Events::postPersist, 'CmsAddressListener', 'postPersist');
$metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'CmsAddressListener', 'prePersist'); $metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'CmsAddressListener', 'prePersist');

View File

@ -271,188 +271,214 @@ class CmsUser
public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
{ {
$metadata->setPrimaryTable(array( $metadata->setPrimaryTable(
[
'name' => 'cms_users', 'name' => 'cms_users',
)); ]
);
$metadata->addNamedNativeQuery(array ( $metadata->addNamedNativeQuery(
[
'name' => 'fetchIdAndUsernameWithResultClass', 'name' => 'fetchIdAndUsernameWithResultClass',
'query' => 'SELECT id, username FROM cms_users WHERE username = ?', 'query' => 'SELECT id, username FROM cms_users WHERE username = ?',
'resultClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser', 'resultClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser',
)); ]
);
$metadata->addNamedNativeQuery(array ( $metadata->addNamedNativeQuery(
[
'name' => 'fetchAllColumns', 'name' => 'fetchAllColumns',
'query' => 'SELECT * FROM cms_users WHERE username = ?', 'query' => 'SELECT * FROM cms_users WHERE username = ?',
'resultClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser', 'resultClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser',
)); ]
);
$metadata->addNamedNativeQuery(array ( $metadata->addNamedNativeQuery(
[
'name' => 'fetchJoinedAddress', 'name' => 'fetchJoinedAddress',
'query' => 'SELECT u.id, u.name, u.status, a.id AS a_id, a.country, a.zip, a.city FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ?', 'query' => 'SELECT u.id, u.name, u.status, a.id AS a_id, a.country, a.zip, a.city FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ?',
'resultSetMapping' => 'mappingJoinedAddress', 'resultSetMapping' => 'mappingJoinedAddress',
)); ]
);
$metadata->addNamedNativeQuery(array ( $metadata->addNamedNativeQuery(
[
'name' => 'fetchJoinedPhonenumber', 'name' => 'fetchJoinedPhonenumber',
'query' => 'SELECT id, name, status, phonenumber AS number FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username = ?', 'query' => 'SELECT id, name, status, phonenumber AS number FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username = ?',
'resultSetMapping' => 'mappingJoinedPhonenumber', 'resultSetMapping' => 'mappingJoinedPhonenumber',
)); ]
);
$metadata->addNamedNativeQuery(array ( $metadata->addNamedNativeQuery(
[
'name' => 'fetchUserPhonenumberCount', 'name' => 'fetchUserPhonenumberCount',
'query' => 'SELECT id, name, status, COUNT(phonenumber) AS numphones FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username IN (?) GROUP BY id, name, status, username ORDER BY username', 'query' => 'SELECT id, name, status, COUNT(phonenumber) AS numphones FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username IN (?) GROUP BY id, name, status, username ORDER BY username',
'resultSetMapping' => 'mappingUserPhonenumberCount', 'resultSetMapping' => 'mappingUserPhonenumberCount',
)); ]
);
$metadata->addNamedNativeQuery(array ( $metadata->addNamedNativeQuery(
[
"name" => "fetchMultipleJoinsEntityResults", "name" => "fetchMultipleJoinsEntityResults",
"resultSetMapping" => "mappingMultipleJoinsEntityResults", "resultSetMapping" => "mappingMultipleJoinsEntityResults",
"query" => "SELECT u.id AS u_id, u.name AS u_name, u.status AS u_status, a.id AS a_id, a.zip AS a_zip, a.country AS a_country, COUNT(p.phonenumber) AS numphones FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id INNER JOIN cms_phonenumbers p ON u.id = p.user_id GROUP BY u.id, u.name, u.status, u.username, a.id, a.zip, a.country ORDER BY u.username" "query" => "SELECT u.id AS u_id, u.name AS u_name, u.status AS u_status, a.id AS a_id, a.zip AS a_zip, a.country AS a_country, COUNT(p.phonenumber) AS numphones FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id INNER JOIN cms_phonenumbers p ON u.id = p.user_id GROUP BY u.id, u.name, u.status, u.username, a.id, a.zip, a.country ORDER BY u.username"
)); ]
);
$metadata->addSqlResultSetMapping(array ( $metadata->addSqlResultSetMapping(
[
'name' => 'mappingJoinedAddress', 'name' => 'mappingJoinedAddress',
'columns' => array(), 'columns' => [],
'entities' => array(array ( 'entities' => [
'fields'=> array ( [
array ( 'fields'=> [
[
'name' => 'id', 'name' => 'id',
'column' => 'id', 'column' => 'id',
), ],
array ( [
'name' => 'name', 'name' => 'name',
'column' => 'name', 'column' => 'name',
), ],
array ( [
'name' => 'status', 'name' => 'status',
'column' => 'status', 'column' => 'status',
), ],
array ( [
'name' => 'address.zip', 'name' => 'address.zip',
'column' => 'zip', 'column' => 'zip',
), ],
array ( [
'name' => 'address.city', 'name' => 'address.city',
'column' => 'city', 'column' => 'city',
), ],
array ( [
'name' => 'address.country', 'name' => 'address.country',
'column' => 'country', 'column' => 'country',
), ],
array ( [
'name' => 'address.id', 'name' => 'address.id',
'column' => 'a_id', 'column' => 'a_id',
), ],
), ],
'entityClass' => 'Doctrine\Tests\Models\CMS\CmsUser', 'entityClass' => 'Doctrine\Tests\Models\CMS\CmsUser',
'discriminatorColumn' => null 'discriminatorColumn' => null
), ],
), ],
)); ]
);
$metadata->addSqlResultSetMapping(array ( $metadata->addSqlResultSetMapping(
[
'name' => 'mappingJoinedPhonenumber', 'name' => 'mappingJoinedPhonenumber',
'columns' => array(), 'columns' => [],
'entities' => array(array( 'entities' => [
'fields'=> array ( [
array ( 'fields'=> [
[
'name' => 'id', 'name' => 'id',
'column' => 'id', 'column' => 'id',
), ],
array ( [
'name' => 'name', 'name' => 'name',
'column' => 'name', 'column' => 'name',
), ],
array ( [
'name' => 'status', 'name' => 'status',
'column' => 'status', 'column' => 'status',
), ],
array ( [
'name' => 'phonenumbers.phonenumber', 'name' => 'phonenumbers.phonenumber',
'column' => 'number', 'column' => 'number',
), ],
), ],
'entityClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser', 'entityClass' => 'Doctrine\\Tests\\Models\\CMS\\CmsUser',
'discriminatorColumn' => null 'discriminatorColumn' => null
), ],
), ],
)); ]
);
$metadata->addSqlResultSetMapping(array ( $metadata->addSqlResultSetMapping(
[
'name' => 'mappingUserPhonenumberCount', 'name' => 'mappingUserPhonenumberCount',
'columns' => array(), 'columns' => [],
'entities' => array ( 'entities' => [
array( [
'fields' => array ( 'fields' => [
array ( [
'name' => 'id', 'name' => 'id',
'column' => 'id', 'column' => 'id',
), ],
array ( [
'name' => 'name', 'name' => 'name',
'column' => 'name', 'column' => 'name',
), ],
array ( [
'name' => 'status', 'name' => 'status',
'column' => 'status', 'column' => 'status',
) ]
), ],
'entityClass' => 'Doctrine\Tests\Models\CMS\CmsUser', 'entityClass' => 'Doctrine\Tests\Models\CMS\CmsUser',
'discriminatorColumn' => null 'discriminatorColumn' => null
) ]
), ],
'columns' => array ( 'columns' => [
array ( [
'name' => 'numphones', 'name' => 'numphones',
) ]
) ]
)); ]
);
$metadata->addSqlResultSetMapping(array( $metadata->addSqlResultSetMapping(
[
'name' => 'mappingMultipleJoinsEntityResults', 'name' => 'mappingMultipleJoinsEntityResults',
'entities' => array(array( 'entities' => [
'fields' => array( [
array( 'fields' => [
[
'name' => 'id', 'name' => 'id',
'column' => 'u_id', 'column' => 'u_id',
), ],
array( [
'name' => 'name', 'name' => 'name',
'column' => 'u_name', 'column' => 'u_name',
), ],
array( [
'name' => 'status', 'name' => 'status',
'column' => 'u_status', 'column' => 'u_status',
) ]
), ],
'entityClass' => 'Doctrine\Tests\Models\CMS\CmsUser', 'entityClass' => 'Doctrine\Tests\Models\CMS\CmsUser',
'discriminatorColumn' => null, 'discriminatorColumn' => null,
), ],
array( [
'fields' => array( 'fields' => [
array( [
'name' => 'id', 'name' => 'id',
'column' => 'a_id', 'column' => 'a_id',
), ],
array( [
'name' => 'zip', 'name' => 'zip',
'column' => 'a_zip', 'column' => 'a_zip',
), ],
array( [
'name' => 'country', 'name' => 'country',
'column' => 'a_country', 'column' => 'a_country',
), ],
), ],
'entityClass' => 'Doctrine\Tests\Models\CMS\CmsAddress', 'entityClass' => 'Doctrine\Tests\Models\CMS\CmsAddress',
'discriminatorColumn' => null, 'discriminatorColumn' => null,
), ],
), ],
'columns' => array(array( 'columns' => [
[
'name' => 'numphones', 'name' => 'numphones',
) ]
) ]
)); ]
);
} }
} }

View File

@ -134,28 +134,36 @@ abstract class CompanyContract
{ {
$metadata->setInheritanceType(\Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_JOINED); $metadata->setInheritanceType(\Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_JOINED);
$metadata->setTableName( 'company_contracts'); $metadata->setTableName( 'company_contracts');
$metadata->setDiscriminatorColumn(array( $metadata->setDiscriminatorColumn(
[
'name' => 'discr', 'name' => 'discr',
'type' => 'string', 'type' => 'string',
)); ]
);
$metadata->mapField(array( $metadata->mapField(
[
'id' => true, 'id' => true,
'name' => 'id', 'name' => 'id',
'fieldName' => 'id', 'fieldName' => 'id',
)); ]
);
$metadata->mapField(array( $metadata->mapField(
[
'type' => 'boolean', 'type' => 'boolean',
'name' => 'completed', 'name' => 'completed',
'fieldName' => 'completed', 'fieldName' => 'completed',
)); ]
);
$metadata->setDiscriminatorMap(array( $metadata->setDiscriminatorMap(
[
"fix" => "CompanyFixContract", "fix" => "CompanyFixContract",
"flexible" => "CompanyFlexContract", "flexible" => "CompanyFlexContract",
"flexultra" => "CompanyFlexUltraContract" "flexultra" => "CompanyFlexUltraContract"
)); ]
);
$metadata->addEntityListener(\Doctrine\ORM\Events::postPersist, 'CompanyContractListener', 'postPersistHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::postPersist, 'CompanyContractListener', 'postPersistHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'CompanyContractListener', 'prePersistHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'CompanyContractListener', 'prePersistHandler');

View File

@ -30,10 +30,12 @@ class CompanyFixContract extends CompanyContract
static public function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) static public function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
{ {
$metadata->mapField(array( $metadata->mapField(
[
'type' => 'integer', 'type' => 'integer',
'name' => 'fixPrice', 'name' => 'fixPrice',
'fieldName' => 'fixPrice', 'fieldName' => 'fixPrice',
)); ]
);
} }
} }

View File

@ -110,16 +110,20 @@ class CompanyFlexContract extends CompanyContract
static public function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) static public function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
{ {
$metadata->mapField(array( $metadata->mapField(
[
'type' => 'integer', 'type' => 'integer',
'name' => 'hoursWorked', 'name' => 'hoursWorked',
'fieldName' => 'hoursWorked', 'fieldName' => 'hoursWorked',
)); ]
);
$metadata->mapField(array( $metadata->mapField(
[
'type' => 'integer', 'type' => 'integer',
'name' => 'pricePerHour', 'name' => 'pricePerHour',
'fieldName' => 'pricePerHour', 'fieldName' => 'pricePerHour',
)); ]
);
} }
} }

View File

@ -31,11 +31,13 @@ class CompanyFlexUltraContract extends CompanyFlexContract
static public function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) static public function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
{ {
$metadata->mapField(array( $metadata->mapField(
[
'type' => 'integer', 'type' => 'integer',
'name' => 'maxPrice', 'name' => 'maxPrice',
'fieldName' => 'maxPrice', 'fieldName' => 'maxPrice',
)); ]
);
$metadata->addEntityListener(\Doctrine\ORM\Events::postPersist, 'CompanyContractListener', 'postPersistHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::postPersist, 'CompanyContractListener', 'postPersistHandler');
$metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'CompanyContractListener', 'prePersistHandler'); $metadata->addEntityListener(\Doctrine\ORM\Events::prePersist, 'CompanyContractListener', 'prePersistHandler');

View File

@ -120,41 +120,50 @@ class CompanyPerson
public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
{ {
$metadata->setPrimaryTable(array( $metadata->setPrimaryTable(
[
'name' => 'company_person', 'name' => 'company_person',
)); ]
);
$metadata->addNamedNativeQuery(array ( $metadata->addNamedNativeQuery(
[
'name' => 'fetchAllWithResultClass', 'name' => 'fetchAllWithResultClass',
'query' => 'SELECT id, name, discr FROM company_persons ORDER BY name', 'query' => 'SELECT id, name, discr FROM company_persons ORDER BY name',
'resultClass' => 'Doctrine\\Tests\\Models\\Company\\CompanyPerson', 'resultClass' => 'Doctrine\\Tests\\Models\\Company\\CompanyPerson',
)); ]
);
$metadata->addNamedNativeQuery(array ( $metadata->addNamedNativeQuery(
[
'name' => 'fetchAllWithSqlResultSetMapping', 'name' => 'fetchAllWithSqlResultSetMapping',
'query' => 'SELECT id, name, discr AS discriminator FROM company_persons ORDER BY name', 'query' => 'SELECT id, name, discr AS discriminator FROM company_persons ORDER BY name',
'resultSetMapping' => 'mappingFetchAll', 'resultSetMapping' => 'mappingFetchAll',
)); ]
);
$metadata->addSqlResultSetMapping(array ( $metadata->addSqlResultSetMapping(
[
'name' => 'mappingFetchAll', 'name' => 'mappingFetchAll',
'columns' => array(), 'columns' => [],
'entities' => array ( array ( 'entities' => [
'fields' => array ( [
array ( 'fields' => [
[
'name' => 'id', 'name' => 'id',
'column' => 'id', 'column' => 'id',
), ],
array ( [
'name' => 'name', 'name' => 'name',
'column' => 'name', 'column' => 'name',
), ],
), ],
'entityClass' => 'Doctrine\Tests\Models\Company\CompanyPerson', 'entityClass' => 'Doctrine\Tests\Models\Company\CompanyPerson',
'discriminatorColumn' => 'discriminator', 'discriminatorColumn' => 'discriminator',
), ],
), ],
)); ]
);
} }
} }

View File

@ -44,13 +44,17 @@ class DDC1476EntityWithDefaultFieldType
public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
{ {
$metadata->mapField(array( $metadata->mapField(
[
'id' => true, 'id' => true,
'fieldName' => 'id', 'fieldName' => 'id',
)); ]
$metadata->mapField(array( );
$metadata->mapField(
[
'fieldName' => 'name', 'fieldName' => 'name',
)); ]
);
$metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_NONE); $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_NONE);
} }

View File

@ -24,5 +24,5 @@ class DDC3346Author
/** /**
* @OneToMany(targetEntity="DDC3346Article", mappedBy="user", fetch="EAGER", cascade={"detach"}) * @OneToMany(targetEntity="DDC3346Article", mappedBy="user", fetch="EAGER", cascade={"detach"})
*/ */
public $articles = array(); public $articles = [];
} }

View File

@ -15,8 +15,9 @@ class DDC3579Admin extends DDC3579User
{ {
public static function loadMetadata($metadata) public static function loadMetadata($metadata)
{ {
$metadata->setAssociationOverride('groups', array( $metadata->setAssociationOverride('groups', [
'inversedBy' => 'admins' 'inversedBy' => 'admins'
)); ]
);
} }
} }

View File

@ -81,27 +81,33 @@ class DDC3579User
public static function loadMetadata($metadata) public static function loadMetadata($metadata)
{ {
$metadata->mapField(array( $metadata->mapField(
[
'id' => true, 'id' => true,
'fieldName' => 'id', 'fieldName' => 'id',
'type' => 'integer', 'type' => 'integer',
'columnName' => 'user_id', 'columnName' => 'user_id',
'length' => 150, 'length' => 150,
)); ]
);
$metadata->mapField(array( $metadata->mapField(
[
'fieldName' => 'name', 'fieldName' => 'name',
'type' => 'string', 'type' => 'string',
'columnName'=> 'user_name', 'columnName'=> 'user_name',
'nullable' => true, 'nullable' => true,
'unique' => false, 'unique' => false,
'length' => 250, 'length' => 250,
)); ]
);
$metadata->mapManyToMany(array( $metadata->mapManyToMany(
[
'fieldName' => 'groups', 'fieldName' => 'groups',
'targetEntity' => 'DDC3579Group' 'targetEntity' => 'DDC3579Group'
)); ]
);
$metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_AUTO); $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_AUTO);
} }

View File

@ -13,10 +13,12 @@ class DDC869ChequePayment extends DDC869Payment
public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
{ {
$metadata->mapField(array( $metadata->mapField(
[
'fieldName' => 'serialNumber', 'fieldName' => 'serialNumber',
'type' => 'string', 'type' => 'string',
)); ]
);
} }
} }

View File

@ -13,10 +13,12 @@ class DDC869CreditCardPayment extends DDC869Payment
public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
{ {
$metadata->mapField(array( $metadata->mapField(
[
'fieldName' => 'creditCardNumber', 'fieldName' => 'creditCardNumber',
'type' => 'string', 'type' => 'string',
)); ]
);
} }
} }

View File

@ -21,16 +21,20 @@ class DDC869Payment
public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
{ {
$metadata->mapField(array( $metadata->mapField(
[
'id' => true, 'id' => true,
'fieldName' => 'id', 'fieldName' => 'id',
'type' => 'integer', 'type' => 'integer',
'columnName' => 'id', 'columnName' => 'id',
)); ]
$metadata->mapField(array( );
$metadata->mapField(
[
'fieldName' => 'value', 'fieldName' => 'value',
'type' => 'float', 'type' => 'float',
)); ]
);
$metadata->isMappedSuperclass = true; $metadata->isMappedSuperclass = true;
$metadata->setCustomRepositoryClass("Doctrine\Tests\Models\DDC869\DDC869PaymentRepository"); $metadata->setCustomRepositoryClass("Doctrine\Tests\Models\DDC869\DDC869PaymentRepository");
$metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_AUTO); $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_AUTO);

View File

@ -15,12 +15,14 @@ class DDC889Class extends DDC889SuperClass
public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
{ {
$metadata->mapField(array( $metadata->mapField(
[
'id' => true, 'id' => true,
'fieldName' => 'id', 'fieldName' => 'id',
'type' => 'integer', 'type' => 'integer',
'columnName' => 'id', 'columnName' => 'id',
)); ]
);
$metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_AUTO); $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_AUTO);
} }

View File

@ -13,9 +13,11 @@ class DDC889SuperClass
public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
{ {
$metadata->mapField(array( $metadata->mapField(
[
'fieldName' => 'name', 'fieldName' => 'name',
)); ]
);
$metadata->isMappedSuperclass = true; $metadata->isMappedSuperclass = true;
$metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_NONE); $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_NONE);

View File

@ -23,23 +23,31 @@ class DDC964Admin extends DDC964User
{ {
public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
{ {
$metadata->setAssociationOverride('address',array( $metadata->setAssociationOverride('address',
'joinColumns'=>array(array( [
'joinColumns'=> [
[
'name' => 'adminaddress_id', 'name' => 'adminaddress_id',
'referencedColumnName' => 'id', 'referencedColumnName' => 'id',
)) ]
)); ]
]
);
$metadata->setAssociationOverride('groups',array( $metadata->setAssociationOverride('groups',
'joinTable' => array( [
'joinTable' => [
'name' => 'ddc964_users_admingroups', 'name' => 'ddc964_users_admingroups',
'joinColumns' => array(array( 'joinColumns' => [
[
'name' => 'adminuser_id', 'name' => 'adminuser_id',
)), ]
'inverseJoinColumns' =>array (array ( ],
'inverseJoinColumns' => [[
'name' => 'admingroup_id', 'name' => 'admingroup_id',
)) ]]
) ]
)); ]
);
} }
} }

View File

@ -26,17 +26,20 @@ class DDC964Guest extends DDC964User
{ {
public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
{ {
$metadata->setAttributeOverride('id', array( $metadata->setAttributeOverride('id', [
'columnName' => 'guest_id', 'columnName' => 'guest_id',
'type' => 'integer', 'type' => 'integer',
'length' => 140, 'length' => 140,
)); ]
);
$metadata->setAttributeOverride('name',array( $metadata->setAttributeOverride('name',
[
'columnName' => 'guest_name', 'columnName' => 'guest_name',
'nullable' => false, 'nullable' => false,
'unique' => true, 'unique' => true,
'length' => 240, 'length' => 240,
)); ]
);
} }
} }

View File

@ -109,46 +109,58 @@ class DDC964User
public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
{ {
$metadata->mapField(array( $metadata->mapField(
[
'id' => true, 'id' => true,
'fieldName' => 'id', 'fieldName' => 'id',
'type' => 'integer', 'type' => 'integer',
'columnName' => 'user_id', 'columnName' => 'user_id',
'length' => 150, 'length' => 150,
)); ]
$metadata->mapField(array( );
$metadata->mapField(
[
'fieldName' => 'name', 'fieldName' => 'name',
'type' => 'string', 'type' => 'string',
'columnName'=> 'user_name', 'columnName'=> 'user_name',
'nullable' => true, 'nullable' => true,
'unique' => false, 'unique' => false,
'length' => 250, 'length' => 250,
)); ]
);
$metadata->mapManyToOne(array( $metadata->mapManyToOne(
[
'fieldName' => 'address', 'fieldName' => 'address',
'targetEntity' => 'DDC964Address', 'targetEntity' => 'DDC964Address',
'cascade' => array('persist','merge'), 'cascade' => ['persist','merge'],
'joinColumn' => array('name'=>'address_id', 'referencedColumnMame'=>'id'), 'joinColumn' => ['name'=>'address_id', 'referencedColumnMame'=>'id'],
)); ]
);
$metadata->mapManyToMany(array( $metadata->mapManyToMany(
[
'fieldName' => 'groups', 'fieldName' => 'groups',
'targetEntity' => 'DDC964Group', 'targetEntity' => 'DDC964Group',
'inversedBy' => 'users', 'inversedBy' => 'users',
'cascade' => array('persist','merge','detach'), 'cascade' => ['persist','merge','detach'],
'joinTable' => array( 'joinTable' => [
'name' => 'ddc964_users_groups', 'name' => 'ddc964_users_groups',
'joinColumns' => array(array( 'joinColumns' => [
[
'name'=>'user_id', 'name'=>'user_id',
'referencedColumnName'=>'id', 'referencedColumnName'=>'id',
)), ]
'inverseJoinColumns'=>array(array( ],
'inverseJoinColumns'=> [
[
'name'=>'group_id', 'name'=>'group_id',
'referencedColumnName'=>'id', 'referencedColumnName'=>'id',
)) ]
) ]
)); ]
]
);
$metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_AUTO); $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadataInfo::GENERATOR_TYPE_AUTO);
} }

View File

@ -28,7 +28,7 @@ class Admin1
* @OneToMany(targetEntity="Admin1AlternateName", mappedBy="admin1") * @OneToMany(targetEntity="Admin1AlternateName", mappedBy="admin1")
* @Cache * @Cache
*/ */
public $names = array(); public $names = [];
/** /**
* @Column(type="string", length=255); * @Column(type="string", length=255);

View File

@ -30,7 +30,7 @@ class RoutingRoute
* @OneToMany(targetEntity="RoutingRouteBooking", mappedBy="route") * @OneToMany(targetEntity="RoutingRouteBooking", mappedBy="route")
* @OrderBy({"passengerName" = "ASC"}) * @OrderBy({"passengerName" = "ASC"})
*/ */
public $bookings = array(); public $bookings = [];
public function __construct() public function __construct()
{ {

View File

@ -37,10 +37,10 @@ abstract class AbstractRegionTest extends OrmFunctionalTestCase
static public function dataProviderCacheValues() static public function dataProviderCacheValues()
{ {
return array( return [
array(new CacheKeyMock('key.1'), new CacheEntryMock(array('id'=>1, 'name' => 'bar'))), [new CacheKeyMock('key.1'), new CacheEntryMock(['id'=>1, 'name' => 'bar'])],
array(new CacheKeyMock('key.2'), new CacheEntryMock(array('id'=>2, 'name' => 'foo'))), [new CacheKeyMock('key.2'), new CacheEntryMock(['id'=>2, 'name' => 'foo'])],
); ];
} }
/** /**
@ -71,8 +71,8 @@ abstract class AbstractRegionTest extends OrmFunctionalTestCase
$this->assertFalse($this->region->contains($key1)); $this->assertFalse($this->region->contains($key1));
$this->assertFalse($this->region->contains($key2)); $this->assertFalse($this->region->contains($key2));
$this->region->put($key1, new CacheEntryMock(array('value' => 'foo'))); $this->region->put($key1, new CacheEntryMock(['value' => 'foo']));
$this->region->put($key2, new CacheEntryMock(array('value' => 'bar'))); $this->region->put($key2, new CacheEntryMock(['value' => 'bar']));
$this->assertTrue($this->region->contains($key1)); $this->assertTrue($this->region->contains($key1));
$this->assertTrue($this->region->contains($key2)); $this->assertTrue($this->region->contains($key2));

View File

@ -13,56 +13,56 @@ class CacheKeyTest extends DoctrineTestCase
{ {
public function testEntityCacheKeyIdentifierCollision() public function testEntityCacheKeyIdentifierCollision()
{ {
$key1 = new EntityCacheKey('Foo', array('id'=>1)); $key1 = new EntityCacheKey('Foo', ['id'=>1]);
$key2 = new EntityCacheKey('Bar', array('id'=>1)); $key2 = new EntityCacheKey('Bar', ['id'=>1]);
$this->assertNotEquals($key1->hash, $key2->hash); $this->assertNotEquals($key1->hash, $key2->hash);
} }
public function testEntityCacheKeyIdentifierType() public function testEntityCacheKeyIdentifierType()
{ {
$key1 = new EntityCacheKey('Foo', array('id'=>1)); $key1 = new EntityCacheKey('Foo', ['id'=>1]);
$key2 = new EntityCacheKey('Foo', array('id'=>'1')); $key2 = new EntityCacheKey('Foo', ['id'=>'1']);
$this->assertEquals($key1->hash, $key2->hash); $this->assertEquals($key1->hash, $key2->hash);
} }
public function testEntityCacheKeyIdentifierOrder() public function testEntityCacheKeyIdentifierOrder()
{ {
$key1 = new EntityCacheKey('Foo', array('foo_bar'=>1, 'bar_foo'=> 2)); $key1 = new EntityCacheKey('Foo', ['foo_bar'=>1, 'bar_foo'=> 2]);
$key2 = new EntityCacheKey('Foo', array('bar_foo'=>2, 'foo_bar'=> 1)); $key2 = new EntityCacheKey('Foo', ['bar_foo'=>2, 'foo_bar'=> 1]);
$this->assertEquals($key1->hash, $key2->hash); $this->assertEquals($key1->hash, $key2->hash);
} }
public function testCollectionCacheKeyIdentifierType() public function testCollectionCacheKeyIdentifierType()
{ {
$key1 = new CollectionCacheKey('Foo', 'assoc', array('id'=>1)); $key1 = new CollectionCacheKey('Foo', 'assoc', ['id'=>1]);
$key2 = new CollectionCacheKey('Foo', 'assoc', array('id'=>'1')); $key2 = new CollectionCacheKey('Foo', 'assoc', ['id'=>'1']);
$this->assertEquals($key1->hash, $key2->hash); $this->assertEquals($key1->hash, $key2->hash);
} }
public function testCollectionCacheKeyIdentifierOrder() public function testCollectionCacheKeyIdentifierOrder()
{ {
$key1 = new CollectionCacheKey('Foo', 'assoc', array('foo_bar'=>1, 'bar_foo'=> 2)); $key1 = new CollectionCacheKey('Foo', 'assoc', ['foo_bar'=>1, 'bar_foo'=> 2]);
$key2 = new CollectionCacheKey('Foo', 'assoc', array('bar_foo'=>2, 'foo_bar'=> 1)); $key2 = new CollectionCacheKey('Foo', 'assoc', ['bar_foo'=>2, 'foo_bar'=> 1]);
$this->assertEquals($key1->hash, $key2->hash); $this->assertEquals($key1->hash, $key2->hash);
} }
public function testCollectionCacheKeyIdentifierCollision() public function testCollectionCacheKeyIdentifierCollision()
{ {
$key1 = new CollectionCacheKey('Foo', 'assoc', array('id'=>1)); $key1 = new CollectionCacheKey('Foo', 'assoc', ['id'=>1]);
$key2 = new CollectionCacheKey('Bar', 'assoc', array('id'=>1)); $key2 = new CollectionCacheKey('Bar', 'assoc', ['id'=>1]);
$this->assertNotEquals($key1->hash, $key2->hash); $this->assertNotEquals($key1->hash, $key2->hash);
} }
public function testCollectionCacheKeyAssociationCollision() public function testCollectionCacheKeyAssociationCollision()
{ {
$key1 = new CollectionCacheKey('Foo', 'assoc1', array('id'=>1)); $key1 = new CollectionCacheKey('Foo', 'assoc1', ['id'=>1]);
$key2 = new CollectionCacheKey('Foo', 'assoc2', array('id'=>1)); $key2 = new CollectionCacheKey('Foo', 'assoc2', ['id'=>1]);
$this->assertNotEquals($key1->hash, $key2->hash); $this->assertNotEquals($key1->hash, $key2->hash);
} }

View File

@ -42,13 +42,13 @@ class CacheLoggerChainTest extends DoctrineTestCase
$this->logger->setLogger('mock', $this->mock); $this->logger->setLogger('mock', $this->mock);
$this->assertSame($this->mock, $this->logger->getLogger('mock')); $this->assertSame($this->mock, $this->logger->getLogger('mock'));
$this->assertEquals(array('mock' => $this->mock), $this->logger->getLoggers()); $this->assertEquals(['mock' => $this->mock], $this->logger->getLoggers());
} }
public function testEntityCacheChain() public function testEntityCacheChain()
{ {
$name = 'my_entity_region'; $name = 'my_entity_region';
$key = new EntityCacheKey(State::CLASSNAME, array('id' => 1)); $key = new EntityCacheKey(State::CLASSNAME, ['id' => 1]);
$this->logger->setLogger('mock', $this->mock); $this->logger->setLogger('mock', $this->mock);
@ -72,7 +72,7 @@ class CacheLoggerChainTest extends DoctrineTestCase
public function testCollectionCacheChain() public function testCollectionCacheChain()
{ {
$name = 'my_collection_region'; $name = 'my_collection_region';
$key = new CollectionCacheKey(State::CLASSNAME, 'cities', array('id' => 1)); $key = new CollectionCacheKey(State::CLASSNAME, 'cities', ['id' => 1]);
$this->logger->setLogger('mock', $this->mock); $this->logger->setLogger('mock', $this->mock);

View File

@ -40,9 +40,9 @@ class DefaultCacheFactoryTest extends OrmTestCase
$this->em = $this->_getTestEntityManager(); $this->em = $this->_getTestEntityManager();
$this->regionsConfig = new RegionsConfiguration; $this->regionsConfig = new RegionsConfiguration;
$arguments = array($this->regionsConfig, $this->getSharedSecondLevelCacheDriverImpl()); $arguments = [$this->regionsConfig, $this->getSharedSecondLevelCacheDriverImpl()];
$this->factory = $this->getMockBuilder(DefaultCacheFactory::class) $this->factory = $this->getMockBuilder(DefaultCacheFactory::class)
->setMethods(array('getRegion')) ->setMethods(['getRegion'])
->setConstructorArgs($arguments) ->setConstructorArgs($arguments)
->getMock(); ->getMock();
} }
@ -261,24 +261,30 @@ class DefaultCacheFactoryTest extends OrmTestCase
{ {
$factory = new DefaultCacheFactory($this->regionsConfig, $this->getSharedSecondLevelCacheDriverImpl()); $factory = new DefaultCacheFactory($this->regionsConfig, $this->getSharedSecondLevelCacheDriverImpl());
$factory->getRegion(array( $factory->getRegion(
[
'usage' => ClassMetadata::CACHE_USAGE_READ_WRITE, 'usage' => ClassMetadata::CACHE_USAGE_READ_WRITE,
'region' => 'foo' 'region' => 'foo'
)); ]
);
} }
public function testBuildsNewNamespacedCacheInstancePerRegionInstance() public function testBuildsNewNamespacedCacheInstancePerRegionInstance()
{ {
$factory = new DefaultCacheFactory($this->regionsConfig, $this->getSharedSecondLevelCacheDriverImpl()); $factory = new DefaultCacheFactory($this->regionsConfig, $this->getSharedSecondLevelCacheDriverImpl());
$fooRegion = $factory->getRegion(array( $fooRegion = $factory->getRegion(
[
'region' => 'foo', 'region' => 'foo',
'usage' => ClassMetadata::CACHE_USAGE_READ_ONLY, 'usage' => ClassMetadata::CACHE_USAGE_READ_ONLY,
)); ]
$barRegion = $factory->getRegion(array( );
$barRegion = $factory->getRegion(
[
'region' => 'bar', 'region' => 'bar',
'usage' => ClassMetadata::CACHE_USAGE_READ_ONLY, 'usage' => ClassMetadata::CACHE_USAGE_READ_ONLY,
)); ]
);
$this->assertSame('foo', $fooRegion->getCache()->getNamespace()); $this->assertSame('foo', $fooRegion->getCache()->getNamespace());
$this->assertSame('bar', $barRegion->getCache()->getNamespace()); $this->assertSame('bar', $barRegion->getCache()->getNamespace());
@ -293,10 +299,12 @@ class DefaultCacheFactoryTest extends OrmTestCase
$this->assertInstanceOf( $this->assertInstanceOf(
'Doctrine\ORM\Cache\Region\DefaultRegion', 'Doctrine\ORM\Cache\Region\DefaultRegion',
$factory->getRegion(array( $factory->getRegion(
[
'region' => 'bar', 'region' => 'bar',
'usage' => ClassMetadata::CACHE_USAGE_READ_ONLY, 'usage' => ClassMetadata::CACHE_USAGE_READ_ONLY,
)) ]
)
); );
} }
@ -309,10 +317,12 @@ class DefaultCacheFactoryTest extends OrmTestCase
$this->assertInstanceOf( $this->assertInstanceOf(
'Doctrine\ORM\Cache\Region\DefaultMultiGetRegion', 'Doctrine\ORM\Cache\Region\DefaultMultiGetRegion',
$factory->getRegion(array( $factory->getRegion(
[
'region' => 'bar', 'region' => 'bar',
'usage' => ClassMetadata::CACHE_USAGE_READ_ONLY, 'usage' => ClassMetadata::CACHE_USAGE_READ_ONLY,
)) ]
)
); );
} }

View File

@ -87,9 +87,9 @@ class DefaultCacheTest extends OrmTestCase
public function testContainsEntity() public function testContainsEntity()
{ {
$identifier = array('id'=>1); $identifier = ['id'=>1];
$className = Country::CLASSNAME; $className = Country::CLASSNAME;
$cacheEntry = array_merge($identifier, array('name' => 'Brazil')); $cacheEntry = array_merge($identifier, ['name' => 'Brazil']);
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, 1)); $this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, 1));
@ -101,9 +101,9 @@ class DefaultCacheTest extends OrmTestCase
public function testEvictEntity() public function testEvictEntity()
{ {
$identifier = array('id'=>1); $identifier = ['id'=>1];
$className = Country::CLASSNAME; $className = Country::CLASSNAME;
$cacheEntry = array_merge($identifier, array('name' => 'Brazil')); $cacheEntry = array_merge($identifier, ['name' => 'Brazil']);
$this->putEntityCacheEntry($className, $identifier, $cacheEntry); $this->putEntityCacheEntry($className, $identifier, $cacheEntry);
@ -117,9 +117,9 @@ class DefaultCacheTest extends OrmTestCase
public function testEvictEntityRegion() public function testEvictEntityRegion()
{ {
$identifier = array('id'=>1); $identifier = ['id'=>1];
$className = Country::CLASSNAME; $className = Country::CLASSNAME;
$cacheEntry = array_merge($identifier, array('name' => 'Brazil')); $cacheEntry = array_merge($identifier, ['name' => 'Brazil']);
$this->putEntityCacheEntry($className, $identifier, $cacheEntry); $this->putEntityCacheEntry($className, $identifier, $cacheEntry);
@ -133,9 +133,9 @@ class DefaultCacheTest extends OrmTestCase
public function testEvictEntityRegions() public function testEvictEntityRegions()
{ {
$identifier = array('id'=>1); $identifier = ['id'=>1];
$className = Country::CLASSNAME; $className = Country::CLASSNAME;
$cacheEntry = array_merge($identifier, array('name' => 'Brazil')); $cacheEntry = array_merge($identifier, ['name' => 'Brazil']);
$this->putEntityCacheEntry($className, $identifier, $cacheEntry); $this->putEntityCacheEntry($className, $identifier, $cacheEntry);
@ -148,13 +148,13 @@ class DefaultCacheTest extends OrmTestCase
public function testContainsCollection() public function testContainsCollection()
{ {
$ownerId = array('id'=>1); $ownerId = ['id'=>1];
$className = State::CLASSNAME; $className = State::CLASSNAME;
$association = 'cities'; $association = 'cities';
$cacheEntry = array( $cacheEntry = [
array('id' => 11), ['id' => 11],
array('id' => 12), ['id' => 12],
); ];
$this->assertFalse($this->cache->containsCollection(State::CLASSNAME, $association, 1)); $this->assertFalse($this->cache->containsCollection(State::CLASSNAME, $association, 1));
@ -166,13 +166,13 @@ class DefaultCacheTest extends OrmTestCase
public function testEvictCollection() public function testEvictCollection()
{ {
$ownerId = array('id'=>1); $ownerId = ['id'=>1];
$className = State::CLASSNAME; $className = State::CLASSNAME;
$association = 'cities'; $association = 'cities';
$cacheEntry = array( $cacheEntry = [
array('id' => 11), ['id' => 11],
array('id' => 12), ['id' => 12],
); ];
$this->putCollectionCacheEntry($className, $association, $ownerId, $cacheEntry); $this->putCollectionCacheEntry($className, $association, $ownerId, $cacheEntry);
@ -186,13 +186,13 @@ class DefaultCacheTest extends OrmTestCase
public function testEvictCollectionRegion() public function testEvictCollectionRegion()
{ {
$ownerId = array('id'=>1); $ownerId = ['id'=>1];
$className = State::CLASSNAME; $className = State::CLASSNAME;
$association = 'cities'; $association = 'cities';
$cacheEntry = array( $cacheEntry = [
array('id' => 11), ['id' => 11],
array('id' => 12), ['id' => 12],
); ];
$this->putCollectionCacheEntry($className, $association, $ownerId, $cacheEntry); $this->putCollectionCacheEntry($className, $association, $ownerId, $cacheEntry);
@ -206,13 +206,13 @@ class DefaultCacheTest extends OrmTestCase
public function testEvictCollectionRegions() public function testEvictCollectionRegions()
{ {
$ownerId = array('id'=>1); $ownerId = ['id'=>1];
$className = State::CLASSNAME; $className = State::CLASSNAME;
$association = 'cities'; $association = 'cities';
$cacheEntry = array( $cacheEntry = [
array('id' => 11), ['id' => 11],
array('id' => 12), ['id' => 12],
); ];
$this->putCollectionCacheEntry($className, $association, $ownerId, $cacheEntry); $this->putCollectionCacheEntry($className, $association, $ownerId, $cacheEntry);
@ -257,7 +257,7 @@ class DefaultCacheTest extends OrmTestCase
$method->setAccessible(true); $method->setAccessible(true);
$property->setValue($entity, $identifier); $property->setValue($entity, $identifier);
$this->assertEquals(array('id'=>$identifier), $method->invoke($this->cache, $metadata, $identifier)); $this->assertEquals(['id'=>$identifier], $method->invoke($this->cache, $metadata, $identifier));
} }
} }

View File

@ -41,17 +41,21 @@ class DefaultCollectionHydratorTest extends OrmFunctionalTestCase
public function testLoadCacheCollection() public function testLoadCacheCollection()
{ {
$targetRegion = $this->_em->getCache()->getEntityCacheRegion(City::CLASSNAME); $targetRegion = $this->_em->getCache()->getEntityCacheRegion(City::CLASSNAME);
$entry = new CollectionCacheEntry(array( $entry = new CollectionCacheEntry(
new EntityCacheKey(City::CLASSNAME, array('id'=>31)), [
new EntityCacheKey(City::CLASSNAME, array('id'=>32)), new EntityCacheKey(City::CLASSNAME, ['id'=>31]),
)); new EntityCacheKey(City::CLASSNAME, ['id'=>32]),
]
);
$targetRegion->put(new EntityCacheKey(City::CLASSNAME, array('id'=>31)), new EntityCacheEntry(City::CLASSNAME, array('id'=>31, 'name'=>'Foo'))); $targetRegion->put(new EntityCacheKey(City::CLASSNAME, ['id'=>31]), new EntityCacheEntry(City::CLASSNAME, ['id'=>31, 'name'=>'Foo']
$targetRegion->put(new EntityCacheKey(City::CLASSNAME, array('id'=>32)), new EntityCacheEntry(City::CLASSNAME, array('id'=>32, 'name'=>'Bar'))); ));
$targetRegion->put(new EntityCacheKey(City::CLASSNAME, ['id'=>32]), new EntityCacheEntry(City::CLASSNAME, ['id'=>32, 'name'=>'Bar']
));
$sourceClass = $this->_em->getClassMetadata(State::CLASSNAME); $sourceClass = $this->_em->getClassMetadata(State::CLASSNAME);
$targetClass = $this->_em->getClassMetadata(City::CLASSNAME); $targetClass = $this->_em->getClassMetadata(City::CLASSNAME);
$key = new CollectionCacheKey($sourceClass->name, 'cities', array('id'=>21)); $key = new CollectionCacheKey($sourceClass->name, 'cities', ['id'=>21]);
$collection = new PersistentCollection($this->_em, $targetClass, new ArrayCollection()); $collection = new PersistentCollection($this->_em, $targetClass, new ArrayCollection());
$list = $this->structure->loadCacheEntry($sourceClass, $key, $entry, $collection); $list = $this->structure->loadCacheEntry($sourceClass, $key, $entry, $collection);

View File

@ -43,8 +43,8 @@ class DefaultEntityHydratorTest extends OrmTestCase
public function testCreateEntity() public function testCreateEntity()
{ {
$metadata = $this->em->getClassMetadata(Country::CLASSNAME); $metadata = $this->em->getClassMetadata(Country::CLASSNAME);
$key = new EntityCacheKey($metadata->name, array('id'=>1)); $key = new EntityCacheKey($metadata->name, ['id'=>1]);
$entry = new EntityCacheEntry($metadata->name, array('id'=>1, 'name'=>'Foo')); $entry = new EntityCacheEntry($metadata->name, ['id'=>1, 'name'=>'Foo']);
$entity = $this->structure->loadCacheEntry($metadata, $key, $entry); $entity = $this->structure->loadCacheEntry($metadata, $key, $entry);
$this->assertInstanceOf($metadata->name, $entity); $this->assertInstanceOf($metadata->name, $entity);
@ -57,8 +57,8 @@ class DefaultEntityHydratorTest extends OrmTestCase
public function testLoadProxy() public function testLoadProxy()
{ {
$metadata = $this->em->getClassMetadata(Country::CLASSNAME); $metadata = $this->em->getClassMetadata(Country::CLASSNAME);
$key = new EntityCacheKey($metadata->name, array('id'=>1)); $key = new EntityCacheKey($metadata->name, ['id'=>1]);
$entry = new EntityCacheEntry($metadata->name, array('id'=>1, 'name'=>'Foo')); $entry = new EntityCacheEntry($metadata->name, ['id'=>1, 'name'=>'Foo']);
$proxy = $this->em->getReference($metadata->name, $key->identifier); $proxy = $this->em->getReference($metadata->name, $key->identifier);
$entity = $this->structure->loadCacheEntry($metadata, $key, $entry, $proxy); $entity = $this->structure->loadCacheEntry($metadata, $key, $entry, $proxy);
@ -74,9 +74,9 @@ class DefaultEntityHydratorTest extends OrmTestCase
{ {
$entity = new Country('Foo'); $entity = new Country('Foo');
$uow = $this->em->getUnitOfWork(); $uow = $this->em->getUnitOfWork();
$data = array('id'=>1, 'name'=>'Foo'); $data = ['id'=>1, 'name'=>'Foo'];
$metadata = $this->em->getClassMetadata(Country::CLASSNAME); $metadata = $this->em->getClassMetadata(Country::CLASSNAME);
$key = new EntityCacheKey($metadata->name, array('id'=>1)); $key = new EntityCacheKey($metadata->name, ['id'=>1]);
$entity->setId(1); $entity->setId(1);
$uow->registerManaged($entity, $key->identifier, $data); $uow->registerManaged($entity, $key->identifier, $data);
@ -88,10 +88,11 @@ class DefaultEntityHydratorTest extends OrmTestCase
$this->assertArrayHasKey('id', $cache->data); $this->assertArrayHasKey('id', $cache->data);
$this->assertArrayHasKey('name', $cache->data); $this->assertArrayHasKey('name', $cache->data);
$this->assertEquals(array( $this->assertEquals(
[
'id' => 1, 'id' => 1,
'name' => 'Foo', 'name' => 'Foo',
), $cache->data); ], $cache->data);
} }
public function testBuildCacheEntryAssociation() public function testBuildCacheEntryAssociation()
@ -99,16 +100,16 @@ class DefaultEntityHydratorTest extends OrmTestCase
$country = new Country('Foo'); $country = new Country('Foo');
$state = new State('Bat', $country); $state = new State('Bat', $country);
$uow = $this->em->getUnitOfWork(); $uow = $this->em->getUnitOfWork();
$countryData = array('id'=>11, 'name'=>'Foo'); $countryData = ['id'=>11, 'name'=>'Foo'];
$stateData = array('id'=>12, 'name'=>'Bar', 'country' => $country); $stateData = ['id'=>12, 'name'=>'Bar', 'country' => $country];
$metadata = $this->em->getClassMetadata(State::CLASSNAME); $metadata = $this->em->getClassMetadata(State::CLASSNAME);
$key = new EntityCacheKey($metadata->name, array('id'=>11)); $key = new EntityCacheKey($metadata->name, ['id'=>11]);
$country->setId(11); $country->setId(11);
$state->setId(12); $state->setId(12);
$uow->registerManaged($country, array('id'=>11), $countryData); $uow->registerManaged($country, ['id'=>11], $countryData);
$uow->registerManaged($state, array('id'=>12), $stateData); $uow->registerManaged($state, ['id'=>12], $stateData);
$cache = $this->structure->buildCacheEntry($metadata, $key, $state); $cache = $this->structure->buildCacheEntry($metadata, $key, $state);
@ -118,11 +119,12 @@ class DefaultEntityHydratorTest extends OrmTestCase
$this->assertArrayHasKey('id', $cache->data); $this->assertArrayHasKey('id', $cache->data);
$this->assertArrayHasKey('name', $cache->data); $this->assertArrayHasKey('name', $cache->data);
$this->assertArrayHasKey('country', $cache->data); $this->assertArrayHasKey('country', $cache->data);
$this->assertEquals(array( $this->assertEquals(
[
'id' => 12, 'id' => 12,
'name' => 'Bar', 'name' => 'Bar',
'country' => new AssociationCacheEntry(Country::CLASSNAME, array('id' => 11)), 'country' => new AssociationCacheEntry(Country::CLASSNAME, ['id' => 11]),
), $cache->data); ], $cache->data);
} }
public function testBuildCacheEntryNonInitializedAssocProxy() public function testBuildCacheEntryNonInitializedAssocProxy()
@ -130,13 +132,13 @@ class DefaultEntityHydratorTest extends OrmTestCase
$proxy = $this->em->getReference(Country::CLASSNAME, 11); $proxy = $this->em->getReference(Country::CLASSNAME, 11);
$entity = new State('Bat', $proxy); $entity = new State('Bat', $proxy);
$uow = $this->em->getUnitOfWork(); $uow = $this->em->getUnitOfWork();
$entityData = array('id'=>12, 'name'=>'Bar', 'country' => $proxy); $entityData = ['id'=>12, 'name'=>'Bar', 'country' => $proxy];
$metadata = $this->em->getClassMetadata(State::CLASSNAME); $metadata = $this->em->getClassMetadata(State::CLASSNAME);
$key = new EntityCacheKey($metadata->name, array('id'=>11)); $key = new EntityCacheKey($metadata->name, ['id'=>11]);
$entity->setId(12); $entity->setId(12);
$uow->registerManaged($entity, array('id'=>12), $entityData); $uow->registerManaged($entity, ['id'=>12], $entityData);
$cache = $this->structure->buildCacheEntry($metadata, $key, $entity); $cache = $this->structure->buildCacheEntry($metadata, $key, $entity);
@ -146,11 +148,12 @@ class DefaultEntityHydratorTest extends OrmTestCase
$this->assertArrayHasKey('id', $cache->data); $this->assertArrayHasKey('id', $cache->data);
$this->assertArrayHasKey('name', $cache->data); $this->assertArrayHasKey('name', $cache->data);
$this->assertArrayHasKey('country', $cache->data); $this->assertArrayHasKey('country', $cache->data);
$this->assertEquals(array( $this->assertEquals(
[
'id' => 12, 'id' => 12,
'name' => 'Bar', 'name' => 'Bar',
'country' => new AssociationCacheEntry(Country::CLASSNAME, array('id' => 11)), 'country' => new AssociationCacheEntry(Country::CLASSNAME, ['id' => 11]),
), $cache->data); ], $cache->data);
} }
public function testCacheEntryWithWrongIdentifierType() public function testCacheEntryWithWrongIdentifierType()
@ -158,13 +161,13 @@ class DefaultEntityHydratorTest extends OrmTestCase
$proxy = $this->em->getReference(Country::CLASSNAME, 11); $proxy = $this->em->getReference(Country::CLASSNAME, 11);
$entity = new State('Bat', $proxy); $entity = new State('Bat', $proxy);
$uow = $this->em->getUnitOfWork(); $uow = $this->em->getUnitOfWork();
$entityData = array('id'=> 12, 'name'=>'Bar', 'country' => $proxy); $entityData = ['id'=> 12, 'name'=>'Bar', 'country' => $proxy];
$metadata = $this->em->getClassMetadata(State::CLASSNAME); $metadata = $this->em->getClassMetadata(State::CLASSNAME);
$key = new EntityCacheKey($metadata->name, array('id'=>'12')); $key = new EntityCacheKey($metadata->name, ['id'=>'12']);
$entity->setId(12); $entity->setId(12);
$uow->registerManaged($entity, array('id'=>12), $entityData); $uow->registerManaged($entity, ['id'=>12], $entityData);
$cache = $this->structure->buildCacheEntry($metadata, $key, $entity); $cache = $this->structure->buildCacheEntry($metadata, $key, $entity);
@ -175,11 +178,12 @@ class DefaultEntityHydratorTest extends OrmTestCase
$this->assertArrayHasKey('name', $cache->data); $this->assertArrayHasKey('name', $cache->data);
$this->assertArrayHasKey('country', $cache->data); $this->assertArrayHasKey('country', $cache->data);
$this->assertSame($entity->getId(), $cache->data['id']); $this->assertSame($entity->getId(), $cache->data['id']);
$this->assertEquals(array( $this->assertEquals(
[
'id' => 12, 'id' => 12,
'name' => 'Bar', 'name' => 'Bar',
'country' => new AssociationCacheEntry(Country::CLASSNAME, array('id' => 11)), 'country' => new AssociationCacheEntry(Country::CLASSNAME, ['id' => 11]),
), $cache->data); ], $cache->data);
} }
} }

View File

@ -79,7 +79,7 @@ class DefaultQueryCacheTest extends OrmTestCase
public function testPutBasicQueryResult() public function testPutBasicQueryResult()
{ {
$result = array(); $result = [];
$key = new QueryCacheKey('query.key1', 0); $key = new QueryCacheKey('query.key1', 0);
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
$metadata = $this->em->getClassMetadata(Country::CLASSNAME); $metadata = $this->em->getClassMetadata(Country::CLASSNAME);
@ -92,7 +92,7 @@ class DefaultQueryCacheTest extends OrmTestCase
$result[] = $entity; $result[] = $entity;
$metadata->setFieldValue($entity, 'id', $i); $metadata->setFieldValue($entity, 'id', $i);
$this->em->getUnitOfWork()->registerManaged($entity, array('id' => $i), array('name' => $name)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => $i], ['name' => $name]);
} }
$this->assertTrue($this->queryCache->put($key, $rsm, $result)); $this->assertTrue($this->queryCache->put($key, $rsm, $result));
@ -114,7 +114,7 @@ class DefaultQueryCacheTest extends OrmTestCase
public function testPutToOneAssociationQueryResult() public function testPutToOneAssociationQueryResult()
{ {
$result = array(); $result = [];
$uow = $this->em->getUnitOfWork(); $uow = $this->em->getUnitOfWork();
$key = new QueryCacheKey('query.key1', 0); $key = new QueryCacheKey('query.key1', 0);
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
@ -122,7 +122,8 @@ class DefaultQueryCacheTest extends OrmTestCase
$stateClass = $this->em->getClassMetadata(State::CLASSNAME); $stateClass = $this->em->getClassMetadata(State::CLASSNAME);
$rsm->addRootEntityFromClassMetadata(City::CLASSNAME, 'c'); $rsm->addRootEntityFromClassMetadata(City::CLASSNAME, 'c');
$rsm->addJoinedEntityFromClassMetadata(State::CLASSNAME, 's', 'c', 'state', array('id'=>'state_id', 'name'=>'state_name')); $rsm->addJoinedEntityFromClassMetadata(State::CLASSNAME, 's', 'c', 'state', ['id'=>'state_id', 'name'=>'state_name']
);
for ($i = 0; $i < 4; $i++) { for ($i = 0; $i < 4; $i++) {
$state = new State("State $i"); $state = new State("State $i");
@ -132,8 +133,8 @@ class DefaultQueryCacheTest extends OrmTestCase
$cityClass->setFieldValue($city, 'id', $i); $cityClass->setFieldValue($city, 'id', $i);
$stateClass->setFieldValue($state, 'id', $i*2); $stateClass->setFieldValue($state, 'id', $i*2);
$uow->registerManaged($state, array('id' => $state->getId()), array('name' => $city->getName())); $uow->registerManaged($state, ['id' => $state->getId()], ['name' => $city->getName()]);
$uow->registerManaged($city, array('id' => $city->getId()), array('name' => $city->getName(), 'state' => $state)); $uow->registerManaged($city, ['id' => $city->getId()], ['name' => $city->getName(), 'state' => $state]);
} }
$this->assertTrue($this->queryCache->put($key, $rsm, $result)); $this->assertTrue($this->queryCache->put($key, $rsm, $result));
@ -153,7 +154,7 @@ class DefaultQueryCacheTest extends OrmTestCase
public function testPutToOneAssociation2LevelsQueryResult() public function testPutToOneAssociation2LevelsQueryResult()
{ {
$result = array(); $result = [];
$uow = $this->em->getUnitOfWork(); $uow = $this->em->getUnitOfWork();
$key = new QueryCacheKey('query.key1', 0); $key = new QueryCacheKey('query.key1', 0);
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
@ -162,8 +163,10 @@ class DefaultQueryCacheTest extends OrmTestCase
$countryClass = $this->em->getClassMetadata(Country::CLASSNAME); $countryClass = $this->em->getClassMetadata(Country::CLASSNAME);
$rsm->addRootEntityFromClassMetadata(City::CLASSNAME, 'c'); $rsm->addRootEntityFromClassMetadata(City::CLASSNAME, 'c');
$rsm->addJoinedEntityFromClassMetadata(State::CLASSNAME, 's', 'c', 'state', array('id'=>'state_id', 'name'=>'state_name')); $rsm->addJoinedEntityFromClassMetadata(State::CLASSNAME, 's', 'c', 'state', ['id'=>'state_id', 'name'=>'state_name']
$rsm->addJoinedEntityFromClassMetadata(Country::CLASSNAME, 'co', 's', 'country', array('id'=>'country_id', 'name'=>'country_name')); );
$rsm->addJoinedEntityFromClassMetadata(Country::CLASSNAME, 'co', 's', 'country', ['id'=>'country_id', 'name'=>'country_name']
);
for ($i = 0; $i < 4; $i++) { for ($i = 0; $i < 4; $i++) {
$country = new Country("Country $i"); $country = new Country("Country $i");
@ -176,9 +179,10 @@ class DefaultQueryCacheTest extends OrmTestCase
$stateClass->setFieldValue($state, 'id', $i*2); $stateClass->setFieldValue($state, 'id', $i*2);
$countryClass->setFieldValue($country, 'id', $i*3); $countryClass->setFieldValue($country, 'id', $i*3);
$uow->registerManaged($country, array('id' => $country->getId()), array('name' => $country->getName())); $uow->registerManaged($country, ['id' => $country->getId()], ['name' => $country->getName()]);
$uow->registerManaged($state, array('id' => $state->getId()), array('name' => $state->getName(), 'country' => $country)); $uow->registerManaged($state, ['id' => $state->getId()], ['name' => $state->getName(), 'country' => $country]
$uow->registerManaged($city, array('id' => $city->getId()), array('name' => $city->getName(), 'state' => $state)); );
$uow->registerManaged($city, ['id' => $city->getId()], ['name' => $city->getName(), 'state' => $state]);
} }
$this->assertTrue($this->queryCache->put($key, $rsm, $result)); $this->assertTrue($this->queryCache->put($key, $rsm, $result));
@ -202,14 +206,15 @@ class DefaultQueryCacheTest extends OrmTestCase
public function testPutToOneAssociationNullQueryResult() public function testPutToOneAssociationNullQueryResult()
{ {
$result = array(); $result = [];
$uow = $this->em->getUnitOfWork(); $uow = $this->em->getUnitOfWork();
$key = new QueryCacheKey('query.key1', 0); $key = new QueryCacheKey('query.key1', 0);
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
$cityClass = $this->em->getClassMetadata(City::CLASSNAME); $cityClass = $this->em->getClassMetadata(City::CLASSNAME);
$rsm->addRootEntityFromClassMetadata(City::CLASSNAME, 'c'); $rsm->addRootEntityFromClassMetadata(City::CLASSNAME, 'c');
$rsm->addJoinedEntityFromClassMetadata(State::CLASSNAME, 's', 'c', 'state', array('id'=>'state_id', 'name'=>'state_name')); $rsm->addJoinedEntityFromClassMetadata(State::CLASSNAME, 's', 'c', 'state', ['id'=>'state_id', 'name'=>'state_name']
);
for ($i = 0; $i < 4; $i++) { for ($i = 0; $i < 4; $i++) {
$city = new City("City $i", null); $city = new City("City $i", null);
@ -217,7 +222,7 @@ class DefaultQueryCacheTest extends OrmTestCase
$cityClass->setFieldValue($city, 'id', $i); $cityClass->setFieldValue($city, 'id', $i);
$uow->registerManaged($city, array('id' => $city->getId()), array('name' => $city->getName(), 'state' => null)); $uow->registerManaged($city, ['id' => $city->getId()], ['name' => $city->getName(), 'state' => null]);
} }
$this->assertTrue($this->queryCache->put($key, $rsm, $result)); $this->assertTrue($this->queryCache->put($key, $rsm, $result));
@ -233,7 +238,7 @@ class DefaultQueryCacheTest extends OrmTestCase
public function testPutToManyAssociationQueryResult() public function testPutToManyAssociationQueryResult()
{ {
$result = array(); $result = [];
$uow = $this->em->getUnitOfWork(); $uow = $this->em->getUnitOfWork();
$key = new QueryCacheKey('query.key1', 0); $key = new QueryCacheKey('query.key1', 0);
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
@ -241,7 +246,7 @@ class DefaultQueryCacheTest extends OrmTestCase
$stateClass = $this->em->getClassMetadata(State::CLASSNAME); $stateClass = $this->em->getClassMetadata(State::CLASSNAME);
$rsm->addRootEntityFromClassMetadata(State::CLASSNAME, 's'); $rsm->addRootEntityFromClassMetadata(State::CLASSNAME, 's');
$rsm->addJoinedEntityFromClassMetadata(City::CLASSNAME, 'c', 's', 'cities', array('id'=>'c_id', 'name'=>'c_name')); $rsm->addJoinedEntityFromClassMetadata(City::CLASSNAME, 'c', 's', 'cities', ['id'=>'c_id', 'name'=>'c_name']);
for ($i = 0; $i < 4; $i++) { for ($i = 0; $i < 4; $i++) {
$state = new State("State $i"); $state = new State("State $i");
@ -256,9 +261,12 @@ class DefaultQueryCacheTest extends OrmTestCase
$state->addCity($city1); $state->addCity($city1);
$state->addCity($city2); $state->addCity($city2);
$uow->registerManaged($city1, array('id' => $city1->getId()), array('name' => $city1->getName(), 'state' => $state)); $uow->registerManaged($city1, ['id' => $city1->getId()], ['name' => $city1->getName(), 'state' => $state]
$uow->registerManaged($city2, array('id' => $city2->getId()), array('name' => $city2->getName(), 'state' => $state)); );
$uow->registerManaged($state, array('id' => $state->getId()), array('name' => $state->getName(), 'cities' => $state->getCities())); $uow->registerManaged($city2, ['id' => $city2->getId()], ['name' => $city2->getName(), 'state' => $state]
);
$uow->registerManaged($state, ['id' => $state->getId()], ['name' => $state->getName(), 'cities' => $state->getCities()]
);
} }
$this->assertTrue($this->queryCache->put($key, $rsm, $result)); $this->assertTrue($this->queryCache->put($key, $rsm, $result));
@ -270,16 +278,18 @@ class DefaultQueryCacheTest extends OrmTestCase
{ {
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
$key = new QueryCacheKey('query.key1', 0); $key = new QueryCacheKey('query.key1', 0);
$entry = new QueryCacheEntry(array( $entry = new QueryCacheEntry(
array('identifier' => array('id' => 1)), [
array('identifier' => array('id' => 2)) ['identifier' => ['id' => 1]],
)); ['identifier' => ['id' => 2]]
]
$data = array(
array('id'=>1, 'name' => 'Foo'),
array('id'=>2, 'name' => 'Bar')
); );
$data = [
['id'=>1, 'name' => 'Foo'],
['id'=>2, 'name' => 'Bar']
];
$this->region->addReturn('get', $entry); $this->region->addReturn('get', $entry);
$this->region->addReturn('get', new EntityCacheEntry(Country::CLASSNAME, $data[0])); $this->region->addReturn('get', new EntityCacheEntry(Country::CLASSNAME, $data[0]));
$this->region->addReturn('get', new EntityCacheEntry(Country::CLASSNAME, $data[1])); $this->region->addReturn('get', new EntityCacheEntry(Country::CLASSNAME, $data[1]));
@ -299,7 +309,7 @@ class DefaultQueryCacheTest extends OrmTestCase
public function testCancelPutResultIfEntityPutFails() public function testCancelPutResultIfEntityPutFails()
{ {
$result = array(); $result = [];
$key = new QueryCacheKey('query.key1', 0); $key = new QueryCacheKey('query.key1', 0);
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
$metadata = $this->em->getClassMetadata(Country::CLASSNAME); $metadata = $this->em->getClassMetadata(Country::CLASSNAME);
@ -312,7 +322,7 @@ class DefaultQueryCacheTest extends OrmTestCase
$result[] = $entity; $result[] = $entity;
$metadata->setFieldValue($entity, 'id', $i); $metadata->setFieldValue($entity, 'id', $i);
$this->em->getUnitOfWork()->registerManaged($entity, array('id' => $i), array('name' => $name)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => $i], ['name' => $name]);
} }
$this->region->addReturn('put', false); $this->region->addReturn('put', false);
@ -324,7 +334,7 @@ class DefaultQueryCacheTest extends OrmTestCase
public function testCancelPutResultIfAssociationEntityPutFails() public function testCancelPutResultIfAssociationEntityPutFails()
{ {
$result = array(); $result = [];
$uow = $this->em->getUnitOfWork(); $uow = $this->em->getUnitOfWork();
$key = new QueryCacheKey('query.key1', 0); $key = new QueryCacheKey('query.key1', 0);
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
@ -332,7 +342,8 @@ class DefaultQueryCacheTest extends OrmTestCase
$stateClass = $this->em->getClassMetadata(State::CLASSNAME); $stateClass = $this->em->getClassMetadata(State::CLASSNAME);
$rsm->addRootEntityFromClassMetadata(City::CLASSNAME, 'c'); $rsm->addRootEntityFromClassMetadata(City::CLASSNAME, 'c');
$rsm->addJoinedEntityFromClassMetadata(State::CLASSNAME, 's', 'c', 'state', array('id'=>'state_id', 'name'=>'state_name')); $rsm->addJoinedEntityFromClassMetadata(State::CLASSNAME, 's', 'c', 'state', ['id'=>'state_id', 'name'=>'state_name']
);
$state = new State("State 1"); $state = new State("State 1");
$city = new City("City 2", $state); $city = new City("City 2", $state);
@ -341,8 +352,8 @@ class DefaultQueryCacheTest extends OrmTestCase
$cityClass->setFieldValue($city, 'id', 1); $cityClass->setFieldValue($city, 'id', 1);
$stateClass->setFieldValue($state, 'id', 11); $stateClass->setFieldValue($state, 'id', 11);
$uow->registerManaged($state, array('id' => $state->getId()), array('name' => $city->getName())); $uow->registerManaged($state, ['id' => $state->getId()], ['name' => $city->getName()]);
$uow->registerManaged($city, array('id' => $city->getId()), array('name' => $city->getName(), 'state' => $state)); $uow->registerManaged($city, ['id' => $city->getId()], ['name' => $city->getName(), 'state' => $state]);
$this->region->addReturn('put', true); // put root entity $this->region->addReturn('put', true); // put root entity
$this->region->addReturn('put', false); // association fails $this->region->addReturn('put', false); // association fails
@ -352,7 +363,7 @@ class DefaultQueryCacheTest extends OrmTestCase
public function testCancelPutToManyAssociationQueryResult() public function testCancelPutToManyAssociationQueryResult()
{ {
$result = array(); $result = [];
$uow = $this->em->getUnitOfWork(); $uow = $this->em->getUnitOfWork();
$key = new QueryCacheKey('query.key1', 0); $key = new QueryCacheKey('query.key1', 0);
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
@ -360,7 +371,7 @@ class DefaultQueryCacheTest extends OrmTestCase
$stateClass = $this->em->getClassMetadata(State::CLASSNAME); $stateClass = $this->em->getClassMetadata(State::CLASSNAME);
$rsm->addRootEntityFromClassMetadata(State::CLASSNAME, 's'); $rsm->addRootEntityFromClassMetadata(State::CLASSNAME, 's');
$rsm->addJoinedEntityFromClassMetadata(City::CLASSNAME, 'c', 's', 'cities', array('id'=>'c_id', 'name'=>'c_name')); $rsm->addJoinedEntityFromClassMetadata(City::CLASSNAME, 'c', 's', 'cities', ['id'=>'c_id', 'name'=>'c_name']);
$state = new State("State"); $state = new State("State");
$city1 = new City("City 1", $state); $city1 = new City("City 1", $state);
@ -374,9 +385,10 @@ class DefaultQueryCacheTest extends OrmTestCase
$state->addCity($city1); $state->addCity($city1);
$state->addCity($city2); $state->addCity($city2);
$uow->registerManaged($city1, array('id' => $city1->getId()), array('name' => $city1->getName(), 'state' => $state)); $uow->registerManaged($city1, ['id' => $city1->getId()], ['name' => $city1->getName(), 'state' => $state]);
$uow->registerManaged($city2, array('id' => $city2->getId()), array('name' => $city2->getName(), 'state' => $state)); $uow->registerManaged($city2, ['id' => $city2->getId()], ['name' => $city2->getName(), 'state' => $state]);
$uow->registerManaged($state, array('id' => $state->getId()), array('name' => $state->getName(), 'cities' => $state->getCities())); $uow->registerManaged($state, ['id' => $state->getId()], ['name' => $state->getName(), 'cities' => $state->getCities()]
);
$this->region->addReturn('put', true); // put root entity $this->region->addReturn('put', true); // put root entity
$this->region->addReturn('put', false); // collection association fails $this->region->addReturn('put', false); // collection association fails
@ -390,10 +402,12 @@ class DefaultQueryCacheTest extends OrmTestCase
{ {
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
$key = new QueryCacheKey('query.key1', 0, Cache::MODE_PUT); $key = new QueryCacheKey('query.key1', 0, Cache::MODE_PUT);
$entry = new QueryCacheEntry(array( $entry = new QueryCacheEntry(
array('identifier' => array('id' => 1)), [
array('identifier' => array('id' => 2)) ['identifier' => ['id' => 1]],
)); ['identifier' => ['id' => 2]]
]
);
$rsm->addRootEntityFromClassMetadata(Country::CLASSNAME, 'c'); $rsm->addRootEntityFromClassMetadata(Country::CLASSNAME, 'c');
@ -404,7 +418,7 @@ class DefaultQueryCacheTest extends OrmTestCase
public function testIgnoreCacheNonPutMode() public function testIgnoreCacheNonPutMode()
{ {
$result = array(); $result = [];
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
$metadata = $this->em->getClassMetadata(Country::CLASSNAME); $metadata = $this->em->getClassMetadata(Country::CLASSNAME);
$key = new QueryCacheKey('query.key1', 0, Cache::MODE_GET); $key = new QueryCacheKey('query.key1', 0, Cache::MODE_GET);
@ -417,7 +431,7 @@ class DefaultQueryCacheTest extends OrmTestCase
$result[] = $entity; $result[] = $entity;
$metadata->setFieldValue($entity, 'id', $i); $metadata->setFieldValue($entity, 'id', $i);
$this->em->getUnitOfWork()->registerManaged($entity, array('id' => $i), array('name' => $name)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => $i], ['name' => $name]);
} }
$this->assertFalse($this->queryCache->put($key, $rsm, $result)); $this->assertFalse($this->queryCache->put($key, $rsm, $result));
@ -427,14 +441,16 @@ class DefaultQueryCacheTest extends OrmTestCase
{ {
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
$key = new QueryCacheKey('query.key1', 50); $key = new QueryCacheKey('query.key1', 50);
$entry = new QueryCacheEntry(array( $entry = new QueryCacheEntry(
array('identifier' => array('id' => 1)), [
array('identifier' => array('id' => 2)) ['identifier' => ['id' => 1]],
)); ['identifier' => ['id' => 2]]
$entities = array( ]
array('id'=>1, 'name' => 'Foo'),
array('id'=>2, 'name' => 'Bar')
); );
$entities = [
['id'=>1, 'name' => 'Foo'],
['id'=>2, 'name' => 'Bar']
];
$entry->time = microtime(true) - 100; $entry->time = microtime(true) - 100;
@ -451,16 +467,18 @@ class DefaultQueryCacheTest extends OrmTestCase
{ {
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
$key = new QueryCacheKey('query.key1', 0); $key = new QueryCacheKey('query.key1', 0);
$entry = new \ArrayObject(array( $entry = new \ArrayObject(
array('identifier' => array('id' => 1)), [
array('identifier' => array('id' => 2)) ['identifier' => ['id' => 1]],
)); ['identifier' => ['id' => 2]]
]
$data = array(
array('id'=>1, 'name' => 'Foo'),
array('id'=>2, 'name' => 'Bar')
); );
$data = [
['id'=>1, 'name' => 'Foo'],
['id'=>2, 'name' => 'Bar']
];
$this->region->addReturn('get', $entry); $this->region->addReturn('get', $entry);
$this->region->addReturn('get', new EntityCacheEntry(Country::CLASSNAME, $data[0])); $this->region->addReturn('get', new EntityCacheEntry(Country::CLASSNAME, $data[0]));
$this->region->addReturn('get', new EntityCacheEntry(Country::CLASSNAME, $data[1])); $this->region->addReturn('get', new EntityCacheEntry(Country::CLASSNAME, $data[1]));
@ -474,10 +492,12 @@ class DefaultQueryCacheTest extends OrmTestCase
{ {
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
$key = new QueryCacheKey('query.key1', 0); $key = new QueryCacheKey('query.key1', 0);
$entry = new QueryCacheEntry(array( $entry = new QueryCacheEntry(
array('identifier' => array('id' => 1)), [
array('identifier' => array('id' => 2)) ['identifier' => ['id' => 1]],
)); ['identifier' => ['id' => 2]]
]
);
$this->region->addReturn('get', $entry); $this->region->addReturn('get', $entry);
$this->region->addReturn('get', null); $this->region->addReturn('get', null);
@ -508,14 +528,16 @@ class DefaultQueryCacheTest extends OrmTestCase
$wurzburg->addAttraction(new Restaurant('Fischers Fritz', $wurzburg)); $wurzburg->addAttraction(new Restaurant('Fischers Fritz', $wurzburg));
$rsm->addRootEntityFromClassMetadata(State::CLASSNAME, 's'); $rsm->addRootEntityFromClassMetadata(State::CLASSNAME, 's');
$rsm->addJoinedEntityFromClassMetadata(City::CLASSNAME, 'c', 's', 'cities', array( $rsm->addJoinedEntityFromClassMetadata(City::CLASSNAME, 'c', 's', 'cities', [
'id' => 'c_id', 'id' => 'c_id',
'name' => 'c_name' 'name' => 'c_name'
)); ]
$rsm->addJoinedEntityFromClassMetadata(Restaurant::CLASSNAME, 'a', 'c', 'attractions', array( );
$rsm->addJoinedEntityFromClassMetadata(Restaurant::CLASSNAME, 'a', 'c', 'attractions', [
'id' => 'a_id', 'id' => 'a_id',
'name' => 'a_name' 'name' => 'a_name'
)); ]
);
$cities = $reflection->invoke($this->queryCache, $rsm, 'c', $bavaria); $cities = $reflection->invoke($this->queryCache, $rsm, 'c', $bavaria);
$attractions = $reflection->invoke($this->queryCache, $rsm, 'a', $bavaria); $attractions = $reflection->invoke($this->queryCache, $rsm, 'a', $bavaria);
@ -537,7 +559,7 @@ class DefaultQueryCacheTest extends OrmTestCase
*/ */
public function testScalarResultException() public function testScalarResultException()
{ {
$result = array(); $result = [];
$key = new QueryCacheKey('query.key1', 0); $key = new QueryCacheKey('query.key1', 0);
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
@ -552,7 +574,7 @@ class DefaultQueryCacheTest extends OrmTestCase
*/ */
public function testSupportMultipleRootEntitiesException() public function testSupportMultipleRootEntitiesException()
{ {
$result = array(); $result = [];
$key = new QueryCacheKey('query.key1', 0); $key = new QueryCacheKey('query.key1', 0);
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
@ -568,7 +590,7 @@ class DefaultQueryCacheTest extends OrmTestCase
*/ */
public function testNotCacheableEntityException() public function testNotCacheableEntityException()
{ {
$result = array(); $result = [];
$key = new QueryCacheKey('query.key1', 0); $key = new QueryCacheKey('query.key1', 0);
$rsm = new ResultSetMappingBuilder($this->em); $rsm = new ResultSetMappingBuilder($this->em);
$className = 'Doctrine\Tests\Models\Generic\BooleanModel'; $className = 'Doctrine\Tests\Models\Generic\BooleanModel';
@ -583,7 +605,7 @@ class DefaultQueryCacheTest extends OrmTestCase
$entity->booleanField = $boolean; $entity->booleanField = $boolean;
$result[] = $entity; $result[] = $entity;
$this->em->getUnitOfWork()->registerManaged($entity, array('id' => $i), array('booleanField' => $boolean)); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => $i], ['booleanField' => $boolean]);
} }
$this->assertFalse($this->queryCache->put($key, $rsm, $result)); $this->assertFalse($this->queryCache->put($key, $rsm, $result));

View File

@ -33,7 +33,7 @@ class DefaultRegionTest extends AbstractRegionTest
} }
$key = new CacheKeyMock('key'); $key = new CacheKeyMock('key');
$entry = new CacheEntryMock(array('value' => 'foo')); $entry = new CacheEntryMock(['value' => 'foo']);
$region1 = new DefaultRegion('region1', new ApcCache()); $region1 = new DefaultRegion('region1', new ApcCache());
$region2 = new DefaultRegion('region2', new ApcCache()); $region2 = new DefaultRegion('region2', new ApcCache());
@ -79,10 +79,10 @@ class DefaultRegionTest extends AbstractRegionTest
public function testGetMulti() public function testGetMulti()
{ {
$key1 = new CacheKeyMock('key.1'); $key1 = new CacheKeyMock('key.1');
$value1 = new CacheEntryMock(array('id' => 1, 'name' => 'bar')); $value1 = new CacheEntryMock(['id' => 1, 'name' => 'bar']);
$key2 = new CacheKeyMock('key.2'); $key2 = new CacheKeyMock('key.2');
$value2 = new CacheEntryMock(array('id' => 2, 'name' => 'bar')); $value2 = new CacheEntryMock(['id' => 2, 'name' => 'bar']);
$this->assertFalse($this->region->contains($key1)); $this->assertFalse($this->region->contains($key1));
$this->assertFalse($this->region->contains($key2)); $this->assertFalse($this->region->contains($key2));
@ -93,7 +93,7 @@ class DefaultRegionTest extends AbstractRegionTest
$this->assertTrue($this->region->contains($key1)); $this->assertTrue($this->region->contains($key1));
$this->assertTrue($this->region->contains($key2)); $this->assertTrue($this->region->contains($key2));
$actual = $this->region->getMultiple(new CollectionCacheEntry(array($key1, $key2))); $actual = $this->region->getMultiple(new CollectionCacheEntry([$key1, $key2]));
$this->assertEquals($value1, $actual[0]); $this->assertEquals($value1, $actual[0]);
$this->assertEquals($value2, $actual[1]); $this->assertEquals($value2, $actual[1]);

View File

@ -67,7 +67,7 @@ class FileLockRegionTest extends AbstractRegionTest
public function testLockAndUnlock() public function testLockAndUnlock()
{ {
$key = new CacheKeyMock('key'); $key = new CacheKeyMock('key');
$entry = new CacheEntryMock(array('foo' => 'bar')); $entry = new CacheEntryMock(['foo' => 'bar']);
$file = $this->getFileName($this->region, $key); $file = $this->getFileName($this->region, $key);
$this->assertFalse($this->region->contains($key)); $this->assertFalse($this->region->contains($key));
@ -91,7 +91,7 @@ class FileLockRegionTest extends AbstractRegionTest
public function testLockWithExistingLock() public function testLockWithExistingLock()
{ {
$key = new CacheKeyMock('key'); $key = new CacheKeyMock('key');
$entry = new CacheEntryMock(array('foo' => 'bar')); $entry = new CacheEntryMock(['foo' => 'bar']);
$file = $this->getFileName($this->region, $key); $file = $this->getFileName($this->region, $key);
$this->assertFalse($this->region->contains($key)); $this->assertFalse($this->region->contains($key));
@ -114,7 +114,7 @@ class FileLockRegionTest extends AbstractRegionTest
public function testUnlockWithExistingLock() public function testUnlockWithExistingLock()
{ {
$key = new CacheKeyMock('key'); $key = new CacheKeyMock('key');
$entry = new CacheEntryMock(array('foo' => 'bar')); $entry = new CacheEntryMock(['foo' => 'bar']);
$file = $this->getFileName($this->region, $key); $file = $this->getFileName($this->region, $key);
$this->assertFalse($this->region->contains($key)); $this->assertFalse($this->region->contains($key));
@ -143,7 +143,7 @@ class FileLockRegionTest extends AbstractRegionTest
public function testPutWithExistingLock() public function testPutWithExistingLock()
{ {
$key = new CacheKeyMock('key'); $key = new CacheKeyMock('key');
$entry = new CacheEntryMock(array('foo' => 'bar')); $entry = new CacheEntryMock(['foo' => 'bar']);
$file = $this->getFileName($this->region, $key); $file = $this->getFileName($this->region, $key);
$this->assertFalse($this->region->contains($key)); $this->assertFalse($this->region->contains($key));
@ -166,7 +166,7 @@ class FileLockRegionTest extends AbstractRegionTest
public function testLockedEvict() public function testLockedEvict()
{ {
$key = new CacheKeyMock('key'); $key = new CacheKeyMock('key');
$entry = new CacheEntryMock(array('foo' => 'bar')); $entry = new CacheEntryMock(['foo' => 'bar']);
$file = $this->getFileName($this->region, $key); $file = $this->getFileName($this->region, $key);
$this->assertFalse($this->region->contains($key)); $this->assertFalse($this->region->contains($key));
@ -186,11 +186,11 @@ class FileLockRegionTest extends AbstractRegionTest
public function testLockedEvictAll() public function testLockedEvictAll()
{ {
$key1 = new CacheKeyMock('key1'); $key1 = new CacheKeyMock('key1');
$entry1 = new CacheEntryMock(array('foo1' => 'bar1')); $entry1 = new CacheEntryMock(['foo1' => 'bar1']);
$file1 = $this->getFileName($this->region, $key1); $file1 = $this->getFileName($this->region, $key1);
$key2 = new CacheKeyMock('key2'); $key2 = new CacheKeyMock('key2');
$entry2 = new CacheEntryMock(array('foo2' => 'bar2')); $entry2 = new CacheEntryMock(['foo2' => 'bar2']);
$file2 = $this->getFileName($this->region, $key2); $file2 = $this->getFileName($this->region, $key2);
$this->assertFalse($this->region->contains($key1)); $this->assertFalse($this->region->contains($key1));
@ -222,7 +222,7 @@ class FileLockRegionTest extends AbstractRegionTest
public function testLockLifetime() public function testLockLifetime()
{ {
$key = new CacheKeyMock('key'); $key = new CacheKeyMock('key');
$entry = new CacheEntryMock(array('foo' => 'bar')); $entry = new CacheEntryMock(['foo' => 'bar']);
$file = $this->getFileName($this->region, $key); $file = $this->getFileName($this->region, $key);
$property = new \ReflectionProperty($this->region, 'lockLifetime'); $property = new \ReflectionProperty($this->region, 'lockLifetime');

View File

@ -20,10 +20,10 @@ class MultiGetRegionTest extends AbstractRegionTest
public function testGetMulti() public function testGetMulti()
{ {
$key1 = new CacheKeyMock('key.1'); $key1 = new CacheKeyMock('key.1');
$value1 = new CacheEntryMock(array('id' => 1, 'name' => 'bar')); $value1 = new CacheEntryMock(['id' => 1, 'name' => 'bar']);
$key2 = new CacheKeyMock('key.2'); $key2 = new CacheKeyMock('key.2');
$value2 = new CacheEntryMock(array('id' => 2, 'name' => 'bar')); $value2 = new CacheEntryMock(['id' => 2, 'name' => 'bar']);
$this->assertFalse($this->region->contains($key1)); $this->assertFalse($this->region->contains($key1));
$this->assertFalse($this->region->contains($key2)); $this->assertFalse($this->region->contains($key2));
@ -34,7 +34,7 @@ class MultiGetRegionTest extends AbstractRegionTest
$this->assertTrue($this->region->contains($key1)); $this->assertTrue($this->region->contains($key1));
$this->assertTrue($this->region->contains($key2)); $this->assertTrue($this->region->contains($key2));
$actual = $this->region->getMultiple(new CollectionCacheEntry(array($key1, $key2))); $actual = $this->region->getMultiple(new CollectionCacheEntry([$key1, $key2]));
$this->assertEquals($value1, $actual[0]); $this->assertEquals($value1, $actual[0]);
$this->assertEquals($value2, $actual[1]); $this->assertEquals($value2, $actual[1]);

View File

@ -35,7 +35,7 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase
/** /**
* @var array * @var array
*/ */
protected $regionMockMethods = array( protected $regionMockMethods = [
'getName', 'getName',
'contains', 'contains',
'get', 'get',
@ -43,12 +43,12 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase
'put', 'put',
'evict', 'evict',
'evictAll' 'evictAll'
); ];
/** /**
* @var array * @var array
*/ */
protected $collectionPersisterMockMethods = array( protected $collectionPersisterMockMethods = [
'delete', 'delete',
'update', 'update',
'count', 'count',
@ -60,7 +60,7 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase
'get', 'get',
'getMultiple', 'getMultiple',
'loadCriteria' 'loadCriteria'
); ];
/** /**
* @param \Doctrine\ORM\EntityManager $em * @param \Doctrine\ORM\EntityManager $em
@ -133,7 +133,7 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$collection = $this->createCollection($entity); $collection = $this->createCollection($entity);
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$this->collectionPersister->expects($this->once()) $this->collectionPersister->expects($this->once())
->method('delete') ->method('delete')
@ -150,7 +150,7 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase
$collection->setDirty(true); $collection->setDirty(true);
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$this->collectionPersister->expects($this->once()) $this->collectionPersister->expects($this->once())
->method('update') ->method('update')
@ -165,7 +165,7 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$collection = $this->createCollection($entity); $collection = $this->createCollection($entity);
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$this->collectionPersister->expects($this->once()) $this->collectionPersister->expects($this->once())
->method('count') ->method('count')
@ -182,7 +182,7 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase
$collection = $this->createCollection($entity); $collection = $this->createCollection($entity);
$slice = $this->createCollection($entity); $slice = $this->createCollection($entity);
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$this->collectionPersister->expects($this->once()) $this->collectionPersister->expects($this->once())
->method('slice') ->method('slice')
@ -199,7 +199,7 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$collection = $this->createCollection($entity); $collection = $this->createCollection($entity);
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$this->collectionPersister->expects($this->once()) $this->collectionPersister->expects($this->once())
->method('contains') ->method('contains')
@ -215,7 +215,7 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$collection = $this->createCollection($entity); $collection = $this->createCollection($entity);
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$this->collectionPersister->expects($this->once()) $this->collectionPersister->expects($this->once())
->method('containsKey') ->method('containsKey')
@ -232,7 +232,7 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$collection = $this->createCollection($entity); $collection = $this->createCollection($entity);
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$this->collectionPersister->expects($this->once()) $this->collectionPersister->expects($this->once())
->method('removeElement') ->method('removeElement')
@ -249,7 +249,7 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$collection = $this->createCollection($entity); $collection = $this->createCollection($entity);
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$this->collectionPersister->expects($this->once()) $this->collectionPersister->expects($this->once())
->method('get') ->method('get')

View File

@ -16,7 +16,7 @@ use Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister;
*/ */
class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersisterTest class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersisterTest
{ {
protected $regionMockMethods = array( protected $regionMockMethods = [
'getName', 'getName',
'contains', 'contains',
'get', 'get',
@ -26,7 +26,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
'evictAll', 'evictAll',
'lock', 'lock',
'unlock', 'unlock',
); ];
/** /**
* {@inheritdoc} * {@inheritdoc}
@ -52,14 +52,14 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$lock = Lock::createLockRead(); $lock = Lock::createLockRead();
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$collection = $this->createCollection($entity); $collection = $this->createCollection($entity);
$key = new CollectionCacheKey(State::CLASSNAME, 'cities', array('id'=>1)); $key = new CollectionCacheKey(State::CLASSNAME, 'cities', ['id'=>1]);
$this->region->expects($this->once()) $this->region->expects($this->once())
->method('lock') ->method('lock')
->with($this->equalTo($key)) ->with($this->equalTo($key))
->will($this->returnValue($lock)); ->will($this->returnValue($lock));
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$persister->delete($collection); $persister->delete($collection);
} }
@ -70,14 +70,14 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$lock = Lock::createLockRead(); $lock = Lock::createLockRead();
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$collection = $this->createCollection($entity); $collection = $this->createCollection($entity);
$key = new CollectionCacheKey(State::CLASSNAME, 'cities', array('id'=>1)); $key = new CollectionCacheKey(State::CLASSNAME, 'cities', ['id'=>1]);
$this->region->expects($this->once()) $this->region->expects($this->once())
->method('lock') ->method('lock')
->with($this->equalTo($key)) ->with($this->equalTo($key))
->will($this->returnValue($lock)); ->will($this->returnValue($lock));
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$persister->update($collection); $persister->update($collection);
} }
@ -88,7 +88,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$lock = Lock::createLockRead(); $lock = Lock::createLockRead();
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$collection = $this->createCollection($entity); $collection = $this->createCollection($entity);
$key = new CollectionCacheKey(State::CLASSNAME, 'cities', array('id'=>1)); $key = new CollectionCacheKey(State::CLASSNAME, 'cities', ['id'=>1]);
$this->region->expects($this->once()) $this->region->expects($this->once())
->method('lock') ->method('lock')
@ -100,7 +100,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
->with($this->equalTo($key)) ->with($this->equalTo($key))
->will($this->returnValue($lock)); ->will($this->returnValue($lock));
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$persister->update($collection); $persister->update($collection);
$persister->afterTransactionRolledBack(); $persister->afterTransactionRolledBack();
@ -112,7 +112,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$lock = Lock::createLockRead(); $lock = Lock::createLockRead();
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$collection = $this->createCollection($entity); $collection = $this->createCollection($entity);
$key = new CollectionCacheKey(State::CLASSNAME, 'cities', array('id'=>1)); $key = new CollectionCacheKey(State::CLASSNAME, 'cities', ['id'=>1]);
$this->region->expects($this->once()) $this->region->expects($this->once())
->method('lock') ->method('lock')
@ -123,7 +123,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
->method('evict') ->method('evict')
->with($this->equalTo($key)); ->with($this->equalTo($key));
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$persister->delete($collection); $persister->delete($collection);
$persister->afterTransactionRolledBack(); $persister->afterTransactionRolledBack();
@ -135,7 +135,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$lock = Lock::createLockRead(); $lock = Lock::createLockRead();
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$collection = $this->createCollection($entity); $collection = $this->createCollection($entity);
$key = new CollectionCacheKey(State::CLASSNAME, 'cities', array('id'=>1)); $key = new CollectionCacheKey(State::CLASSNAME, 'cities', ['id'=>1]);
$property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister', 'queuedCache'); $property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister', 'queuedCache');
$property->setAccessible(true); $property->setAccessible(true);
@ -149,7 +149,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
->method('evict') ->method('evict')
->with($this->equalTo($key)); ->with($this->equalTo($key));
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$persister->delete($collection); $persister->delete($collection);
@ -166,7 +166,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$lock = Lock::createLockRead(); $lock = Lock::createLockRead();
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$collection = $this->createCollection($entity); $collection = $this->createCollection($entity);
$key = new CollectionCacheKey(State::CLASSNAME, 'cities', array('id'=>1)); $key = new CollectionCacheKey(State::CLASSNAME, 'cities', ['id'=>1]);
$property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister', 'queuedCache'); $property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister', 'queuedCache');
$property->setAccessible(true); $property->setAccessible(true);
@ -180,7 +180,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
->method('evict') ->method('evict')
->with($this->equalTo($key)); ->with($this->equalTo($key));
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$persister->update($collection); $persister->update($collection);
@ -197,7 +197,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$lock = Lock::createLockRead(); $lock = Lock::createLockRead();
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$collection = $this->createCollection($entity); $collection = $this->createCollection($entity);
$key = new CollectionCacheKey(State::CLASSNAME, 'cities', array('id'=>1)); $key = new CollectionCacheKey(State::CLASSNAME, 'cities', ['id'=>1]);
$property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister', 'queuedCache'); $property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister', 'queuedCache');
$property->setAccessible(true); $property->setAccessible(true);
@ -211,7 +211,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
->method('evict') ->method('evict')
->with($this->equalTo($key)); ->with($this->equalTo($key));
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$persister->delete($collection); $persister->delete($collection);
@ -228,7 +228,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$lock = Lock::createLockRead(); $lock = Lock::createLockRead();
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$collection = $this->createCollection($entity); $collection = $this->createCollection($entity);
$key = new CollectionCacheKey(State::CLASSNAME, 'cities', array('id'=>1)); $key = new CollectionCacheKey(State::CLASSNAME, 'cities', ['id'=>1]);
$property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister', 'queuedCache'); $property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister', 'queuedCache');
$property->setAccessible(true); $property->setAccessible(true);
@ -242,7 +242,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
->method('evict') ->method('evict')
->with($this->equalTo($key)); ->with($this->equalTo($key));
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$persister->update($collection); $persister->update($collection);
@ -258,7 +258,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$entity = new State("Foo"); $entity = new State("Foo");
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$collection = $this->createCollection($entity); $collection = $this->createCollection($entity);
$key = new CollectionCacheKey(State::CLASSNAME, 'cities', array('id'=>1)); $key = new CollectionCacheKey(State::CLASSNAME, 'cities', ['id'=>1]);
$property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister', 'queuedCache'); $property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister', 'queuedCache');
$property->setAccessible(true); $property->setAccessible(true);
@ -272,7 +272,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
->method('delete') ->method('delete')
->with($this->equalTo($collection)); ->with($this->equalTo($collection));
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$persister->delete($collection); $persister->delete($collection);
$this->assertCount(0, $property->getValue($persister)); $this->assertCount(0, $property->getValue($persister));
@ -283,7 +283,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$entity = new State("Foo"); $entity = new State("Foo");
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$collection = $this->createCollection($entity); $collection = $this->createCollection($entity);
$key = new CollectionCacheKey(State::CLASSNAME, 'cities', array('id'=>1)); $key = new CollectionCacheKey(State::CLASSNAME, 'cities', ['id'=>1]);
$property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister', 'queuedCache'); $property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister', 'queuedCache');
$property->setAccessible(true); $property->setAccessible(true);
@ -297,7 +297,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
->method('update') ->method('update')
->with($this->equalTo($collection)); ->with($this->equalTo($collection));
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$persister->update($collection); $persister->update($collection);
$this->assertCount(0, $property->getValue($persister)); $this->assertCount(0, $property->getValue($persister));

View File

@ -38,7 +38,7 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase
/** /**
* @var array * @var array
*/ */
protected $regionMockMethods = array( protected $regionMockMethods = [
'getName', 'getName',
'contains', 'contains',
'get', 'get',
@ -46,12 +46,12 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase
'put', 'put',
'evict', 'evict',
'evictAll' 'evictAll'
); ];
/** /**
* @var array * @var array
*/ */
protected $entityPersisterMockMethods = array( protected $entityPersisterMockMethods = [
'getClassMetadata', 'getClassMetadata',
'getResultSetMapping', 'getResultSetMapping',
'getInserts', 'getInserts',
@ -79,7 +79,7 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase
'lock', 'lock',
'getOneToManyCollection', 'getOneToManyCollection',
'exists' 'exists'
); ];
/** /**
* @param \Doctrine\ORM\EntityManager $em * @param \Doctrine\ORM\EntityManager $em
@ -150,9 +150,9 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase
$this->entityPersister->expects($this->once()) $this->entityPersister->expects($this->once())
->method('getInserts') ->method('getInserts')
->will($this->returnValue(array($entity))); ->will($this->returnValue([$entity]));
$this->assertEquals(array($entity), $persister->getInserts()); $this->assertEquals([$entity], $persister->getInserts());
} }
public function testInvokeGetSelectSQL() public function testInvokeGetSelectSQL()
@ -161,10 +161,14 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase
$this->entityPersister->expects($this->once()) $this->entityPersister->expects($this->once())
->method('getSelectSQL') ->method('getSelectSQL')
->with($this->equalTo(array('name'=>'Foo')), $this->equalTo(array(0)), $this->equalTo(1), $this->equalTo(2), $this->equalTo(3), $this->equalTo(array(4))) ->with($this->equalTo(['name'=>'Foo']), $this->equalTo([0]), $this->equalTo(1), $this->equalTo(2), $this->equalTo(3), $this->equalTo(
[4]
))
->will($this->returnValue('SELECT * FROM foo WERE name = ?')); ->will($this->returnValue('SELECT * FROM foo WERE name = ?'));
$this->assertEquals('SELECT * FROM foo WERE name = ?', $persister->getSelectSQL(array('name'=>'Foo'), array(0), 1, 2, 3, array(4))); $this->assertEquals('SELECT * FROM foo WERE name = ?', $persister->getSelectSQL(
['name'=>'Foo'], [0], 1, 2, 3, [4]
));
} }
public function testInvokeGetInsertSQL() public function testInvokeGetInsertSQL()
@ -184,10 +188,10 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase
$this->entityPersister->expects($this->once()) $this->entityPersister->expects($this->once())
->method('expandParameters') ->method('expandParameters')
->with($this->equalTo(array('name'=>'Foo'))) ->with($this->equalTo(['name'=>'Foo']))
->will($this->returnValue(array('name'=>'Foo'))); ->will($this->returnValue(['name'=>'Foo']));
$this->assertEquals(array('name'=>'Foo'), $persister->expandParameters(array('name'=>'Foo'))); $this->assertEquals(['name'=>'Foo'], $persister->expandParameters(['name'=>'Foo']));
} }
public function testInvokeExpandCriteriaParameters() public function testInvokeExpandCriteriaParameters()
@ -198,9 +202,9 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase
$this->entityPersister->expects($this->once()) $this->entityPersister->expects($this->once())
->method('expandCriteriaParameters') ->method('expandCriteriaParameters')
->with($this->equalTo($criteria)) ->with($this->equalTo($criteria))
->will($this->returnValue(array('name'=>'Foo'))); ->will($this->returnValue(['name'=>'Foo']));
$this->assertEquals(array('name'=>'Foo'), $persister->expandCriteriaParameters($criteria)); $this->assertEquals(['name'=>'Foo'], $persister->expandCriteriaParameters($criteria));
} }
public function testInvokeSelectConditionStatementSQL() public function testInvokeSelectConditionStatementSQL()
@ -209,10 +213,10 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase
$this->entityPersister->expects($this->once()) $this->entityPersister->expects($this->once())
->method('getSelectConditionStatementSQL') ->method('getSelectConditionStatementSQL')
->with($this->equalTo('id'), $this->equalTo(1), $this->equalTo(array()), $this->equalTo('=')) ->with($this->equalTo('id'), $this->equalTo(1), $this->equalTo([]), $this->equalTo('='))
->will($this->returnValue('name = 1')); ->will($this->returnValue('name = 1'));
$this->assertEquals('name = 1', $persister->getSelectConditionStatementSQL('id', 1, array(), '=')); $this->assertEquals('name = 1', $persister->getSelectConditionStatementSQL('id', 1, [], '='));
} }
public function testInvokeExecuteInserts() public function testInvokeExecuteInserts()
@ -221,9 +225,9 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase
$this->entityPersister->expects($this->once()) $this->entityPersister->expects($this->once())
->method('executeInserts') ->method('executeInserts')
->will($this->returnValue(array('id' => 1))); ->will($this->returnValue(['id' => 1]));
$this->assertEquals(array('id' => 1), $persister->executeInserts()); $this->assertEquals(['id' => 1], $persister->executeInserts());
} }
public function testInvokeUpdate() public function testInvokeUpdate()
@ -235,7 +239,7 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase
->method('update') ->method('update')
->with($this->equalTo($entity)); ->with($this->equalTo($entity));
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$this->assertNull($persister->update($entity)); $this->assertNull($persister->update($entity));
} }
@ -249,7 +253,7 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase
->method('delete') ->method('delete')
->with($this->equalTo($entity)); ->with($this->equalTo($entity));
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$this->assertNull($persister->delete($entity)); $this->assertNull($persister->delete($entity));
} }
@ -273,10 +277,14 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase
$this->entityPersister->expects($this->once()) $this->entityPersister->expects($this->once())
->method('load') ->method('load')
->with($this->equalTo(array('id' => 1)), $this->equalTo($entity), $this->equalTo(array(0)), $this->equalTo(array(1)), $this->equalTo(2), $this->equalTo(3), $this->equalTo(array(4))) ->with($this->equalTo(['id' => 1]), $this->equalTo($entity), $this->equalTo([0]), $this->equalTo(
[1]
), $this->equalTo(2), $this->equalTo(3), $this->equalTo(
[4]
))
->will($this->returnValue($entity)); ->will($this->returnValue($entity));
$this->assertEquals($entity, $persister->load(array('id' => 1), $entity, array(0), array(1), 2, 3, array(4))); $this->assertEquals($entity, $persister->load(['id' => 1], $entity, [0], [1], 2, 3, [4]));
} }
public function testInvokeLoadAll() public function testInvokeLoadAll()
@ -287,18 +295,18 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase
$rsm->addEntityResult(Country::CLASSNAME, 'c'); $rsm->addEntityResult(Country::CLASSNAME, 'c');
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$this->entityPersister->expects($this->once()) $this->entityPersister->expects($this->once())
->method('loadAll') ->method('loadAll')
->with($this->equalTo(array('id' => 1)), $this->equalTo(array(0)), $this->equalTo(1), $this->equalTo(2)) ->with($this->equalTo(['id' => 1]), $this->equalTo([0]), $this->equalTo(1), $this->equalTo(2))
->will($this->returnValue(array($entity))); ->will($this->returnValue([$entity]));
$this->entityPersister->expects($this->once()) $this->entityPersister->expects($this->once())
->method('getResultSetMapping') ->method('getResultSetMapping')
->will($this->returnValue($rsm)); ->will($this->returnValue($rsm));
$this->assertEquals(array($entity), $persister->loadAll(array('id' => 1), array(0), 1, 2)); $this->assertEquals([$entity], $persister->loadAll(['id' => 1], [0], 1, 2));
} }
public function testInvokeLoadById() public function testInvokeLoadById()
@ -308,10 +316,10 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase
$this->entityPersister->expects($this->once()) $this->entityPersister->expects($this->once())
->method('loadById') ->method('loadById')
->with($this->equalTo(array('id' => 1)), $this->equalTo($entity)) ->with($this->equalTo(['id' => 1]), $this->equalTo($entity))
->will($this->returnValue($entity)); ->will($this->returnValue($entity));
$this->assertEquals($entity, $persister->loadById(array('id' => 1), $entity)); $this->assertEquals($entity, $persister->loadById(['id' => 1], $entity));
} }
public function testInvokeLoadOneToOneEntity() public function testInvokeLoadOneToOneEntity()
@ -321,10 +329,10 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase
$this->entityPersister->expects($this->once()) $this->entityPersister->expects($this->once())
->method('loadOneToOneEntity') ->method('loadOneToOneEntity')
->with($this->equalTo(array()), $this->equalTo('foo'), $this->equalTo(array('id' => 11))) ->with($this->equalTo([]), $this->equalTo('foo'), $this->equalTo(['id' => 11]))
->will($this->returnValue($entity)); ->will($this->returnValue($entity));
$this->assertEquals($entity, $persister->loadOneToOneEntity(array(), 'foo', array('id' => 11))); $this->assertEquals($entity, $persister->loadOneToOneEntity([], 'foo', ['id' => 11]));
} }
public function testInvokeRefresh() public function testInvokeRefresh()
@ -334,10 +342,10 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase
$this->entityPersister->expects($this->once()) $this->entityPersister->expects($this->once())
->method('refresh') ->method('refresh')
->with($this->equalTo(array('id' => 1)), $this->equalTo($entity), $this->equalTo(0)) ->with($this->equalTo(['id' => 1]), $this->equalTo($entity), $this->equalTo(0))
->will($this->returnValue($entity)); ->will($this->returnValue($entity));
$this->assertNull($persister->refresh(array('id' => 1), $entity), 0); $this->assertNull($persister->refresh(['id' => 1], $entity), 0);
} }
public function testInvokeLoadCriteria() public function testInvokeLoadCriteria()
@ -347,7 +355,7 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase
$entity = new Country("Foo"); $entity = new Country("Foo");
$criteria = new Criteria(); $criteria = new Criteria();
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$rsm->addEntityResult(Country::CLASSNAME, 'c'); $rsm->addEntityResult(Country::CLASSNAME, 'c');
$this->entityPersister->expects($this->once()) $this->entityPersister->expects($this->once())
@ -357,9 +365,9 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase
$this->entityPersister->expects($this->once()) $this->entityPersister->expects($this->once())
->method('loadCriteria') ->method('loadCriteria')
->with($this->equalTo($criteria)) ->with($this->equalTo($criteria))
->will($this->returnValue(array($entity))); ->will($this->returnValue([$entity]));
$this->assertEquals(array($entity), $persister->loadCriteria($criteria)); $this->assertEquals([$entity], $persister->loadCriteria($criteria));
} }
public function testInvokeGetManyToManyCollection() public function testInvokeGetManyToManyCollection()
@ -369,10 +377,10 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase
$this->entityPersister->expects($this->once()) $this->entityPersister->expects($this->once())
->method('getManyToManyCollection') ->method('getManyToManyCollection')
->with($this->equalTo(array()), $this->equalTo('Foo'), $this->equalTo(1), $this->equalTo(2)) ->with($this->equalTo([]), $this->equalTo('Foo'), $this->equalTo(1), $this->equalTo(2))
->will($this->returnValue(array($entity))); ->will($this->returnValue([$entity]));
$this->assertEquals(array($entity), $persister->getManyToManyCollection(array(), 'Foo', 1 ,2)); $this->assertEquals([$entity], $persister->getManyToManyCollection([], 'Foo', 1 ,2));
} }
public function testInvokeGetOneToManyCollection() public function testInvokeGetOneToManyCollection()
@ -382,16 +390,16 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase
$this->entityPersister->expects($this->once()) $this->entityPersister->expects($this->once())
->method('getOneToManyCollection') ->method('getOneToManyCollection')
->with($this->equalTo(array()), $this->equalTo('Foo'), $this->equalTo(1), $this->equalTo(2)) ->with($this->equalTo([]), $this->equalTo('Foo'), $this->equalTo(1), $this->equalTo(2))
->will($this->returnValue(array($entity))); ->will($this->returnValue([$entity]));
$this->assertEquals(array($entity), $persister->getOneToManyCollection(array(), 'Foo', 1 ,2)); $this->assertEquals([$entity], $persister->getOneToManyCollection([], 'Foo', 1 ,2));
} }
public function testInvokeLoadManyToManyCollection() public function testInvokeLoadManyToManyCollection()
{ {
$mapping = $this->em->getClassMetadata('Doctrine\Tests\Models\Cache\Country'); $mapping = $this->em->getClassMetadata('Doctrine\Tests\Models\Cache\Country');
$assoc = array('type' => 1); $assoc = ['type' => 1];
$coll = new PersistentCollection($this->em, $mapping, new ArrayCollection()); $coll = new PersistentCollection($this->em, $mapping, new ArrayCollection());
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$entity = new Country("Foo"); $entity = new Country("Foo");
@ -399,15 +407,15 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase
$this->entityPersister->expects($this->once()) $this->entityPersister->expects($this->once())
->method('loadManyToManyCollection') ->method('loadManyToManyCollection')
->with($this->equalTo($assoc), $this->equalTo('Foo'), $coll) ->with($this->equalTo($assoc), $this->equalTo('Foo'), $coll)
->will($this->returnValue(array($entity))); ->will($this->returnValue([$entity]));
$this->assertEquals(array($entity), $persister->loadManyToManyCollection($assoc, 'Foo', $coll)); $this->assertEquals([$entity], $persister->loadManyToManyCollection($assoc, 'Foo', $coll));
} }
public function testInvokeLoadOneToManyCollection() public function testInvokeLoadOneToManyCollection()
{ {
$mapping = $this->em->getClassMetadata('Doctrine\Tests\Models\Cache\Country'); $mapping = $this->em->getClassMetadata('Doctrine\Tests\Models\Cache\Country');
$assoc = array('type' => 1); $assoc = ['type' => 1];
$coll = new PersistentCollection($this->em, $mapping, new ArrayCollection()); $coll = new PersistentCollection($this->em, $mapping, new ArrayCollection());
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$entity = new Country("Foo"); $entity = new Country("Foo");
@ -415,14 +423,14 @@ abstract class AbstractEntityPersisterTest extends OrmTestCase
$this->entityPersister->expects($this->once()) $this->entityPersister->expects($this->once())
->method('loadOneToManyCollection') ->method('loadOneToManyCollection')
->with($this->equalTo($assoc), $this->equalTo('Foo'), $coll) ->with($this->equalTo($assoc), $this->equalTo('Foo'), $coll)
->will($this->returnValue(array($entity))); ->will($this->returnValue([$entity]));
$this->assertEquals(array($entity), $persister->loadOneToManyCollection($assoc, 'Foo', $coll)); $this->assertEquals([$entity], $persister->loadOneToManyCollection($assoc, 'Foo', $coll));
} }
public function testInvokeLock() public function testInvokeLock()
{ {
$identifier = array('id' => 1); $identifier = ['id' => 1];
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$this->entityPersister->expects($this->once()) $this->entityPersister->expects($this->once())

View File

@ -32,7 +32,7 @@ class NonStrictReadWriteCachedEntityPersisterTest extends AbstractEntityPersiste
$property->setAccessible(true); $property->setAccessible(true);
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$persister->update($entity); $persister->update($entity);
$persister->delete($entity); $persister->delete($entity);
@ -48,8 +48,8 @@ class NonStrictReadWriteCachedEntityPersisterTest extends AbstractEntityPersiste
{ {
$entity = new Country("Foo"); $entity = new Country("Foo");
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$key = new EntityCacheKey(Country::CLASSNAME, array('id'=>1)); $key = new EntityCacheKey(Country::CLASSNAME, ['id'=>1]);
$entry = new EntityCacheEntry(Country::CLASSNAME, array('id'=>1, 'name'=>'Foo')); $entry = new EntityCacheEntry(Country::CLASSNAME, ['id'=>1, 'name'=>'Foo']);
$property = new \ReflectionProperty($persister, 'queuedCache'); $property = new \ReflectionProperty($persister, 'queuedCache');
$property->setAccessible(true); $property->setAccessible(true);
@ -64,12 +64,12 @@ class NonStrictReadWriteCachedEntityPersisterTest extends AbstractEntityPersiste
$this->entityPersister->expects($this->once()) $this->entityPersister->expects($this->once())
->method('getInserts') ->method('getInserts')
->will($this->returnValue(array($entity))); ->will($this->returnValue([$entity]));
$this->entityPersister->expects($this->once()) $this->entityPersister->expects($this->once())
->method('executeInserts'); ->method('executeInserts');
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$persister->addInsert($entity); $persister->addInsert($entity);
$persister->executeInserts(); $persister->executeInserts();
@ -85,8 +85,8 @@ class NonStrictReadWriteCachedEntityPersisterTest extends AbstractEntityPersiste
{ {
$entity = new Country("Foo"); $entity = new Country("Foo");
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$key = new EntityCacheKey(Country::CLASSNAME, array('id'=>1)); $key = new EntityCacheKey(Country::CLASSNAME, ['id'=>1]);
$entry = new EntityCacheEntry(Country::CLASSNAME, array('id'=>1, 'name'=>'Foo')); $entry = new EntityCacheEntry(Country::CLASSNAME, ['id'=>1, 'name'=>'Foo']);
$property = new \ReflectionProperty($persister, 'queuedCache'); $property = new \ReflectionProperty($persister, 'queuedCache');
$property->setAccessible(true); $property->setAccessible(true);
@ -99,7 +99,7 @@ class NonStrictReadWriteCachedEntityPersisterTest extends AbstractEntityPersiste
->method('update') ->method('update')
->with($this->equalTo($entity)); ->with($this->equalTo($entity));
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$persister->update($entity); $persister->update($entity);
@ -114,7 +114,7 @@ class NonStrictReadWriteCachedEntityPersisterTest extends AbstractEntityPersiste
{ {
$entity = new Country("Foo"); $entity = new Country("Foo");
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$key = new EntityCacheKey(Country::CLASSNAME, array('id'=>1)); $key = new EntityCacheKey(Country::CLASSNAME, ['id'=>1]);
$property = new \ReflectionProperty($persister, 'queuedCache'); $property = new \ReflectionProperty($persister, 'queuedCache');
$property->setAccessible(true); $property->setAccessible(true);
@ -127,7 +127,7 @@ class NonStrictReadWriteCachedEntityPersisterTest extends AbstractEntityPersiste
->method('delete') ->method('delete')
->with($this->equalTo($entity)); ->with($this->equalTo($entity));
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$persister->delete($entity); $persister->delete($entity);

View File

@ -17,7 +17,7 @@ use Doctrine\ORM\Cache\Persister\Entity\ReadWriteCachedEntityPersister;
*/ */
class ReadWriteCachedEntityPersisterTest extends AbstractEntityPersisterTest class ReadWriteCachedEntityPersisterTest extends AbstractEntityPersisterTest
{ {
protected $regionMockMethods = array( protected $regionMockMethods = [
'getName', 'getName',
'contains', 'contains',
'get', 'get',
@ -27,7 +27,7 @@ class ReadWriteCachedEntityPersisterTest extends AbstractEntityPersisterTest
'evictAll', 'evictAll',
'lock', 'lock',
'unlock', 'unlock',
); ];
/** /**
* {@inheritdoc} * {@inheritdoc}
@ -52,14 +52,14 @@ class ReadWriteCachedEntityPersisterTest extends AbstractEntityPersisterTest
$entity = new Country("Foo"); $entity = new Country("Foo");
$lock = Lock::createLockRead(); $lock = Lock::createLockRead();
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$key = new EntityCacheKey(Country::CLASSNAME, array('id'=>1)); $key = new EntityCacheKey(Country::CLASSNAME, ['id'=>1]);
$this->region->expects($this->once()) $this->region->expects($this->once())
->method('lock') ->method('lock')
->with($this->equalTo($key)) ->with($this->equalTo($key))
->will($this->returnValue($lock)); ->will($this->returnValue($lock));
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$persister->delete($entity); $persister->delete($entity);
} }
@ -69,14 +69,14 @@ class ReadWriteCachedEntityPersisterTest extends AbstractEntityPersisterTest
$entity = new Country("Foo"); $entity = new Country("Foo");
$lock = Lock::createLockRead(); $lock = Lock::createLockRead();
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$key = new EntityCacheKey(Country::CLASSNAME, array('id'=>1)); $key = new EntityCacheKey(Country::CLASSNAME, ['id'=>1]);
$this->region->expects($this->once()) $this->region->expects($this->once())
->method('lock') ->method('lock')
->with($this->equalTo($key)) ->with($this->equalTo($key))
->will($this->returnValue($lock)); ->will($this->returnValue($lock));
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$persister->update($entity); $persister->update($entity);
} }
@ -86,7 +86,7 @@ class ReadWriteCachedEntityPersisterTest extends AbstractEntityPersisterTest
$entity = new Country("Foo"); $entity = new Country("Foo");
$lock = Lock::createLockRead(); $lock = Lock::createLockRead();
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$key = new EntityCacheKey(Country::CLASSNAME, array('id'=>1)); $key = new EntityCacheKey(Country::CLASSNAME, ['id'=>1]);
$this->region->expects($this->once()) $this->region->expects($this->once())
->method('lock') ->method('lock')
@ -98,7 +98,7 @@ class ReadWriteCachedEntityPersisterTest extends AbstractEntityPersisterTest
->with($this->equalTo($key)) ->with($this->equalTo($key))
->will($this->returnValue($lock)); ->will($this->returnValue($lock));
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$persister->update($entity); $persister->update($entity);
$persister->afterTransactionRolledBack(); $persister->afterTransactionRolledBack();
@ -109,7 +109,7 @@ class ReadWriteCachedEntityPersisterTest extends AbstractEntityPersisterTest
$entity = new Country("Foo"); $entity = new Country("Foo");
$lock = Lock::createLockRead(); $lock = Lock::createLockRead();
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$key = new EntityCacheKey(Country::CLASSNAME, array('id'=>1)); $key = new EntityCacheKey(Country::CLASSNAME, ['id'=>1]);
$this->region->expects($this->once()) $this->region->expects($this->once())
->method('lock') ->method('lock')
@ -120,7 +120,7 @@ class ReadWriteCachedEntityPersisterTest extends AbstractEntityPersisterTest
->method('evict') ->method('evict')
->with($this->equalTo($key)); ->with($this->equalTo($key));
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$persister->delete($entity); $persister->delete($entity);
$persister->afterTransactionRolledBack(); $persister->afterTransactionRolledBack();
@ -131,7 +131,7 @@ class ReadWriteCachedEntityPersisterTest extends AbstractEntityPersisterTest
$entity = new Country("Foo"); $entity = new Country("Foo");
$lock = Lock::createLockRead(); $lock = Lock::createLockRead();
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$key = new EntityCacheKey(Country::CLASSNAME, array('id'=>1)); $key = new EntityCacheKey(Country::CLASSNAME, ['id'=>1]);
$property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Entity\ReadWriteCachedEntityPersister', 'queuedCache'); $property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Entity\ReadWriteCachedEntityPersister', 'queuedCache');
$property->setAccessible(true); $property->setAccessible(true);
@ -145,7 +145,7 @@ class ReadWriteCachedEntityPersisterTest extends AbstractEntityPersisterTest
->method('evict') ->method('evict')
->with($this->equalTo($key)); ->with($this->equalTo($key));
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$persister->update($entity); $persister->update($entity);
$persister->delete($entity); $persister->delete($entity);
@ -162,7 +162,7 @@ class ReadWriteCachedEntityPersisterTest extends AbstractEntityPersisterTest
$entity = new Country("Foo"); $entity = new Country("Foo");
$lock = Lock::createLockRead(); $lock = Lock::createLockRead();
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$key = new EntityCacheKey(Country::CLASSNAME, array('id'=>1)); $key = new EntityCacheKey(Country::CLASSNAME, ['id'=>1]);
$property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Entity\ReadWriteCachedEntityPersister', 'queuedCache'); $property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Entity\ReadWriteCachedEntityPersister', 'queuedCache');
$property->setAccessible(true); $property->setAccessible(true);
@ -176,7 +176,7 @@ class ReadWriteCachedEntityPersisterTest extends AbstractEntityPersisterTest
->method('evict') ->method('evict')
->with($this->equalTo($key)); ->with($this->equalTo($key));
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$persister->update($entity); $persister->update($entity);
$persister->delete($entity); $persister->delete($entity);
@ -192,7 +192,7 @@ class ReadWriteCachedEntityPersisterTest extends AbstractEntityPersisterTest
{ {
$entity = new Country("Foo"); $entity = new Country("Foo");
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$key = new EntityCacheKey(Country::CLASSNAME, array('id'=>1)); $key = new EntityCacheKey(Country::CLASSNAME, ['id'=>1]);
$property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Entity\ReadWriteCachedEntityPersister', 'queuedCache'); $property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Entity\ReadWriteCachedEntityPersister', 'queuedCache');
$property->setAccessible(true); $property->setAccessible(true);
@ -206,7 +206,7 @@ class ReadWriteCachedEntityPersisterTest extends AbstractEntityPersisterTest
->method('delete') ->method('delete')
->with($this->equalTo($entity)); ->with($this->equalTo($entity));
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$persister->delete($entity); $persister->delete($entity);
$this->assertCount(0, $property->getValue($persister)); $this->assertCount(0, $property->getValue($persister));
@ -216,7 +216,7 @@ class ReadWriteCachedEntityPersisterTest extends AbstractEntityPersisterTest
{ {
$entity = new Country("Foo"); $entity = new Country("Foo");
$persister = $this->createPersisterDefault(); $persister = $this->createPersisterDefault();
$key = new EntityCacheKey(Country::CLASSNAME, array('id'=>1)); $key = new EntityCacheKey(Country::CLASSNAME, ['id'=>1]);
$property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Entity\ReadWriteCachedEntityPersister', 'queuedCache'); $property = new \ReflectionProperty('Doctrine\ORM\Cache\Persister\Entity\ReadWriteCachedEntityPersister', 'queuedCache');
$property->setAccessible(true); $property->setAccessible(true);
@ -230,7 +230,7 @@ class ReadWriteCachedEntityPersisterTest extends AbstractEntityPersisterTest
->method('update') ->method('update')
->with($this->equalTo($entity)); ->with($this->equalTo($entity));
$this->em->getUnitOfWork()->registerManaged($entity, array('id'=>1), array('id'=>1, 'name'=>'Foo')); $this->em->getUnitOfWork()->registerManaged($entity, ['id'=>1], ['id'=>1, 'name'=>'Foo']);
$persister->update($entity); $persister->update($entity);
$this->assertCount(0, $property->getValue($persister)); $this->assertCount(0, $property->getValue($persister));

View File

@ -29,7 +29,7 @@ class StatisticsCacheLoggerTest extends DoctrineTestCase
public function testEntityCache() public function testEntityCache()
{ {
$name = 'my_entity_region'; $name = 'my_entity_region';
$key = new EntityCacheKey(State::CLASSNAME, array('id' => 1)); $key = new EntityCacheKey(State::CLASSNAME, ['id' => 1]);
$this->logger->entityCacheHit($name, $key); $this->logger->entityCacheHit($name, $key);
$this->logger->entityCachePut($name, $key); $this->logger->entityCachePut($name, $key);
@ -46,7 +46,7 @@ class StatisticsCacheLoggerTest extends DoctrineTestCase
public function testCollectionCache() public function testCollectionCache()
{ {
$name = 'my_collection_region'; $name = 'my_collection_region';
$key = new CollectionCacheKey(State::CLASSNAME, 'cities', array('id' => 1)); $key = new CollectionCacheKey(State::CLASSNAME, 'cities', ['id' => 1]);
$this->logger->collectionCacheHit($name, $key); $this->logger->collectionCacheHit($name, $key);
$this->logger->collectionCachePut($name, $key); $this->logger->collectionCachePut($name, $key);
@ -83,8 +83,8 @@ class StatisticsCacheLoggerTest extends DoctrineTestCase
$entityRegion = 'my_entity_region'; $entityRegion = 'my_entity_region';
$queryRegion = 'my_query_region'; $queryRegion = 'my_query_region';
$coolKey = new CollectionCacheKey(State::CLASSNAME, 'cities', array('id' => 1)); $coolKey = new CollectionCacheKey(State::CLASSNAME, 'cities', ['id' => 1]);
$entityKey = new EntityCacheKey(State::CLASSNAME, array('id' => 1)); $entityKey = new EntityCacheKey(State::CLASSNAME, ['id' => 1]);
$queryKey = new QueryCacheKey('my_query_hash'); $queryKey = new QueryCacheKey('my_query_hash');
$this->logger->queryCacheHit($queryRegion, $queryKey); $this->logger->queryCacheHit($queryRegion, $queryKey);

View File

@ -44,7 +44,7 @@ class CommitOrderCalculatorTest extends OrmTestCase
$sorted = $this->_calc->sort(); $sorted = $this->_calc->sort();
// There is only 1 valid ordering for this constellation // There is only 1 valid ordering for this constellation
$correctOrder = array($class5, $class1, $class2, $class3, $class4); $correctOrder = [$class5, $class1, $class2, $class3, $class4];
$this->assertSame($correctOrder, $sorted); $this->assertSame($correctOrder, $sorted);
} }
@ -63,7 +63,7 @@ class CommitOrderCalculatorTest extends OrmTestCase
$sorted = $this->_calc->sort(); $sorted = $this->_calc->sort();
// There is only 1 valid ordering for this constellation // There is only 1 valid ordering for this constellation
$correctOrder = array($class2, $class1); $correctOrder = [$class2, $class1];
$this->assertSame($correctOrder, $sorted); $this->assertSame($correctOrder, $sorted);
} }

View File

@ -75,7 +75,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
public function testNewDefaultAnnotationDriver() public function testNewDefaultAnnotationDriver()
{ {
$paths = array(__DIR__); $paths = [__DIR__];
$reflectionClass = new ReflectionClass(__NAMESPACE__ . '\ConfigurationTestAnnotationReaderChecker'); $reflectionClass = new ReflectionClass(__NAMESPACE__ . '\ConfigurationTestAnnotationReaderChecker');
$annotationDriver = $this->configuration->newDefaultAnnotationDriver($paths, false); $annotationDriver = $this->configuration->newDefaultAnnotationDriver($paths, false);
@ -99,7 +99,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
{ {
$this->configuration->addEntityNamespace('TestNamespace', __NAMESPACE__); $this->configuration->addEntityNamespace('TestNamespace', __NAMESPACE__);
$this->assertSame(__NAMESPACE__, $this->configuration->getEntityNamespace('TestNamespace')); $this->assertSame(__NAMESPACE__, $this->configuration->getEntityNamespace('TestNamespace'));
$namespaces = array('OtherNamespace' => __NAMESPACE__); $namespaces = ['OtherNamespace' => __NAMESPACE__];
$this->configuration->setEntityNamespaces($namespaces); $this->configuration->setEntityNamespaces($namespaces);
$this->assertSame($namespaces, $this->configuration->getEntityNamespaces()); $this->assertSame($namespaces, $this->configuration->getEntityNamespaces());
$this->expectException(\Doctrine\ORM\ORMException::class); $this->expectException(\Doctrine\ORM\ORMException::class);
@ -259,7 +259,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
$this->configuration->addCustomStringFunction('FunctionName', __CLASS__); $this->configuration->addCustomStringFunction('FunctionName', __CLASS__);
$this->assertSame(__CLASS__, $this->configuration->getCustomStringFunction('FunctionName')); $this->assertSame(__CLASS__, $this->configuration->getCustomStringFunction('FunctionName'));
$this->assertSame(null, $this->configuration->getCustomStringFunction('NonExistingFunction')); $this->assertSame(null, $this->configuration->getCustomStringFunction('NonExistingFunction'));
$this->configuration->setCustomStringFunctions(array('OtherFunctionName' => __CLASS__)); $this->configuration->setCustomStringFunctions(['OtherFunctionName' => __CLASS__]);
$this->assertSame(__CLASS__, $this->configuration->getCustomStringFunction('OtherFunctionName')); $this->assertSame(__CLASS__, $this->configuration->getCustomStringFunction('OtherFunctionName'));
$this->expectException(\Doctrine\ORM\ORMException::class); $this->expectException(\Doctrine\ORM\ORMException::class);
$this->configuration->addCustomStringFunction('concat', __CLASS__); $this->configuration->addCustomStringFunction('concat', __CLASS__);
@ -270,7 +270,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
$this->configuration->addCustomNumericFunction('FunctionName', __CLASS__); $this->configuration->addCustomNumericFunction('FunctionName', __CLASS__);
$this->assertSame(__CLASS__, $this->configuration->getCustomNumericFunction('FunctionName')); $this->assertSame(__CLASS__, $this->configuration->getCustomNumericFunction('FunctionName'));
$this->assertSame(null, $this->configuration->getCustomNumericFunction('NonExistingFunction')); $this->assertSame(null, $this->configuration->getCustomNumericFunction('NonExistingFunction'));
$this->configuration->setCustomNumericFunctions(array('OtherFunctionName' => __CLASS__)); $this->configuration->setCustomNumericFunctions(['OtherFunctionName' => __CLASS__]);
$this->assertSame(__CLASS__, $this->configuration->getCustomNumericFunction('OtherFunctionName')); $this->assertSame(__CLASS__, $this->configuration->getCustomNumericFunction('OtherFunctionName'));
$this->expectException(\Doctrine\ORM\ORMException::class); $this->expectException(\Doctrine\ORM\ORMException::class);
$this->configuration->addCustomNumericFunction('abs', __CLASS__); $this->configuration->addCustomNumericFunction('abs', __CLASS__);
@ -281,7 +281,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
$this->configuration->addCustomDatetimeFunction('FunctionName', __CLASS__); $this->configuration->addCustomDatetimeFunction('FunctionName', __CLASS__);
$this->assertSame(__CLASS__, $this->configuration->getCustomDatetimeFunction('FunctionName')); $this->assertSame(__CLASS__, $this->configuration->getCustomDatetimeFunction('FunctionName'));
$this->assertSame(null, $this->configuration->getCustomDatetimeFunction('NonExistingFunction')); $this->assertSame(null, $this->configuration->getCustomDatetimeFunction('NonExistingFunction'));
$this->configuration->setCustomDatetimeFunctions(array('OtherFunctionName' => __CLASS__)); $this->configuration->setCustomDatetimeFunctions(['OtherFunctionName' => __CLASS__]);
$this->assertSame(__CLASS__, $this->configuration->getCustomDatetimeFunction('OtherFunctionName')); $this->assertSame(__CLASS__, $this->configuration->getCustomDatetimeFunction('OtherFunctionName'));
$this->expectException(\Doctrine\ORM\ORMException::class); $this->expectException(\Doctrine\ORM\ORMException::class);
$this->configuration->addCustomDatetimeFunction('date_add', __CLASS__); $this->configuration->addCustomDatetimeFunction('date_add', __CLASS__);
@ -300,9 +300,9 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
$this->assertSame(__CLASS__, $this->configuration->getCustomHydrationMode('HydrationModeName')); $this->assertSame(__CLASS__, $this->configuration->getCustomHydrationMode('HydrationModeName'));
$this->configuration->setCustomHydrationModes( $this->configuration->setCustomHydrationModes(
array( [
'AnotherHydrationModeName' => __CLASS__ 'AnotherHydrationModeName' => __CLASS__
) ]
); );
$this->assertNull($this->configuration->getCustomHydrationMode('HydrationModeName')); $this->assertNull($this->configuration->getCustomHydrationMode('HydrationModeName'));

View File

@ -14,7 +14,7 @@ class EntityManagerDecoratorTest extends \PHPUnit_Framework_TestCase
{ {
$this->wrapped = $this->createMock(EntityManagerInterface::class); $this->wrapped = $this->createMock(EntityManagerInterface::class);
$this->decorator = $this->getMockBuilder('Doctrine\ORM\Decorator\EntityManagerDecorator') $this->decorator = $this->getMockBuilder('Doctrine\ORM\Decorator\EntityManagerDecorator')
->setConstructorArgs(array($this->wrapped)) ->setConstructorArgs([$this->wrapped])
->setMethods(null) ->setMethods(null)
->getMock(); ->getMock();
} }
@ -23,7 +23,7 @@ class EntityManagerDecoratorTest extends \PHPUnit_Framework_TestCase
{ {
$class = new \ReflectionClass('Doctrine\ORM\EntityManager'); $class = new \ReflectionClass('Doctrine\ORM\EntityManager');
$methods = array(); $methods = [];
foreach ($class->getMethods() as $method) { foreach ($class->getMethods() as $method) {
if ($method->isConstructor() || $method->isStatic() || !$method->isPublic()) { if ($method->isConstructor() || $method->isStatic() || !$method->isPublic()) {
continue; continue;
@ -31,17 +31,17 @@ class EntityManagerDecoratorTest extends \PHPUnit_Framework_TestCase
/** Special case EntityManager::createNativeQuery() */ /** Special case EntityManager::createNativeQuery() */
if ($method->getName() === 'createNativeQuery') { if ($method->getName() === 'createNativeQuery') {
$methods[] = array($method->getName(), array('name', new ResultSetMapping())); $methods[] = [$method->getName(), ['name', new ResultSetMapping()]];
continue; continue;
} }
if ($method->getNumberOfRequiredParameters() === 0) { if ($method->getNumberOfRequiredParameters() === 0) {
$methods[] = array($method->getName(), array()); $methods[] = [$method->getName(), []];
} elseif ($method->getNumberOfRequiredParameters() > 0) { } elseif ($method->getNumberOfRequiredParameters() > 0) {
$methods[] = array($method->getName(), array_fill(0, $method->getNumberOfRequiredParameters(), 'req') ?: array()); $methods[] = [$method->getName(), array_fill(0, $method->getNumberOfRequiredParameters(), 'req') ?: []];
} }
if ($method->getNumberOfParameters() != $method->getNumberOfRequiredParameters()) { if ($method->getNumberOfParameters() != $method->getNumberOfRequiredParameters()) {
$methods[] = array($method->getName(), array_fill(0, $method->getNumberOfParameters(), 'all') ?: array()); $methods[] = [$method->getName(), array_fill(0, $method->getNumberOfParameters(), 'all') ?: []];
} }
} }
@ -58,8 +58,8 @@ class EntityManagerDecoratorTest extends \PHPUnit_Framework_TestCase
->method($method) ->method($method)
->will($this->returnValue('INNER VALUE FROM ' . $method)); ->will($this->returnValue('INNER VALUE FROM ' . $method));
call_user_func_array(array($stub, 'with'), $parameters); call_user_func_array([$stub, 'with'], $parameters);
$this->assertSame('INNER VALUE FROM ' . $method, call_user_func_array(array($this->decorator, $method), $parameters)); $this->assertSame('INNER VALUE FROM ' . $method, call_user_func_array([$this->decorator, $method], $parameters));
} }
} }

View File

@ -139,13 +139,13 @@ class EntityManagerTest extends OrmTestCase
static public function dataMethodsAffectedByNoObjectArguments() static public function dataMethodsAffectedByNoObjectArguments()
{ {
return array( return [
array('persist'), ['persist'],
array('remove'), ['remove'],
array('merge'), ['merge'],
array('refresh'), ['refresh'],
array('detach') ['detach']
); ];
} }
/** /**
@ -160,13 +160,13 @@ class EntityManagerTest extends OrmTestCase
static public function dataAffectedByErrorIfClosedException() static public function dataAffectedByErrorIfClosedException()
{ {
return array( return [
array('flush'), ['flush'],
array('persist'), ['persist'],
array('remove'), ['remove'],
array('merge'), ['merge'],
array('refresh'), ['refresh'],
); ];
} }
/** /**
@ -196,7 +196,7 @@ class EntityManagerTest extends OrmTestCase
public function testTransactionalAcceptsVariousCallables() public function testTransactionalAcceptsVariousCallables()
{ {
$this->assertSame('callback', $this->_em->transactional(array($this, 'transactionalCallback'))); $this->assertSame('callback', $this->_em->transactional([$this, 'transactionalCallback']));
} }
public function testTransactionalThrowsInvalidArgumentExceptionIfNonCallablePassed() public function testTransactionalThrowsInvalidArgumentExceptionIfNonCallablePassed()

View File

@ -16,7 +16,7 @@ class EntityNotFoundExceptionTest extends PHPUnit_Framework_TestCase
{ {
$exception = EntityNotFoundException::fromClassNameAndIdentifier( $exception = EntityNotFoundException::fromClassNameAndIdentifier(
'foo', 'foo',
array('foo' => 'bar') ['foo' => 'bar']
); );
$this->assertInstanceOf('Doctrine\ORM\EntityNotFoundException', $exception); $this->assertInstanceOf('Doctrine\ORM\EntityNotFoundException', $exception);
@ -24,7 +24,7 @@ class EntityNotFoundExceptionTest extends PHPUnit_Framework_TestCase
$exception = EntityNotFoundException::fromClassNameAndIdentifier( $exception = EntityNotFoundException::fromClassNameAndIdentifier(
'foo', 'foo',
array() []
); );
$this->assertInstanceOf('Doctrine\ORM\EntityNotFoundException', $exception); $this->assertInstanceOf('Doctrine\ORM\EntityNotFoundException', $exception);

View File

@ -31,7 +31,8 @@ class AbstractManyToManyAssociationTestCase extends OrmFunctionalTestCase
FROM {$this->_table} FROM {$this->_table}
WHERE {$this->_firstField} = ? WHERE {$this->_firstField} = ?
AND {$this->_secondField} = ? AND {$this->_secondField} = ?
", array($firstId, $secondId))->fetchAll()); ", [$firstId, $secondId]
)->fetchAll());
} }
public function assertCollectionEquals(Collection $first, Collection $second) public function assertCollectionEquals(Collection $first, Collection $second)

View File

@ -16,13 +16,15 @@ class AdvancedAssociationTest extends OrmFunctionalTestCase
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
try { try {
$this->_schemaTool->createSchema(array( $this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Phrase'), $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Phrase'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\PhraseType'), $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\PhraseType'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Definition'), $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Definition'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Lemma'), $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Lemma'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Type') $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Type')
)); ]
);
} catch (\Exception $e) { } catch (\Exception $e) {
// Swallow all exceptions. We do not test the schema tool here. // Swallow all exceptions. We do not test the schema tool here.
} }

View File

@ -127,7 +127,7 @@ class BasicFunctionalTest extends OrmFunctionalTestCase
// Check that the foreign key has been set // Check that the foreign key has been set
$userId = $this->_em->getConnection()->executeQuery( $userId = $this->_em->getConnection()->executeQuery(
"SELECT user_id FROM cms_addresses WHERE id=?", array($address->id) "SELECT user_id FROM cms_addresses WHERE id=?", [$address->id]
)->fetchColumn(); )->fetchColumn();
$this->assertTrue(is_numeric($userId)); $this->assertTrue(is_numeric($userId));
@ -1075,11 +1075,11 @@ class BasicFunctionalTest extends OrmFunctionalTestCase
$this->_em->persist($userB); $this->_em->persist($userB);
$this->_em->persist($userC); $this->_em->persist($userC);
$this->_em->flush(array($userA, $userB, $userB)); $this->_em->flush([$userA, $userB, $userB]);
$userC->name = 'changed name'; $userC->name = 'changed name';
$this->_em->flush(array($userA, $userB)); $this->_em->flush([$userA, $userB]);
$this->_em->refresh($userC); $this->_em->refresh($userC);
$this->assertTrue($userA->id > 0, 'user a has an id'); $this->assertTrue($userA->id > 0, 'user a has an id');

View File

@ -14,20 +14,24 @@ class CascadeRemoveOrderTest extends OrmFunctionalTestCase
{ {
parent::setUp(); parent::setUp();
$this->_schemaTool->createSchema(array( $this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(__NAMESPACE__ . '\CascadeRemoveOrderEntityO'), $this->_em->getClassMetadata(__NAMESPACE__ . '\CascadeRemoveOrderEntityO'),
$this->_em->getClassMetadata(__NAMESPACE__ . '\CascadeRemoveOrderEntityG'), $this->_em->getClassMetadata(__NAMESPACE__ . '\CascadeRemoveOrderEntityG'),
)); ]
);
} }
protected function tearDown() protected function tearDown()
{ {
parent::tearDown(); parent::tearDown();
$this->_schemaTool->dropSchema(array( $this->_schemaTool->dropSchema(
[
$this->_em->getClassMetadata(__NAMESPACE__ . '\CascadeRemoveOrderEntityO'), $this->_em->getClassMetadata(__NAMESPACE__ . '\CascadeRemoveOrderEntityO'),
$this->_em->getClassMetadata(__NAMESPACE__ . '\CascadeRemoveOrderEntityG'), $this->_em->getClassMetadata(__NAMESPACE__ . '\CascadeRemoveOrderEntityG'),
)); ]
);
} }
public function testSingle() public function testSingle()

View File

@ -72,7 +72,7 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$guilherme = $this->_em->getRepository(get_class($employee))->findOneBy(array('name' => 'Guilherme Blanco')); $guilherme = $this->_em->getRepository(get_class($employee))->findOneBy(['name' => 'Guilherme Blanco']);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $guilherme); $this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $guilherme);
$this->assertEquals('Guilherme Blanco', $guilherme->getName()); $this->assertEquals('Guilherme Blanco', $guilherme->getName());
@ -389,12 +389,12 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyManager'); $repos = $this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyManager');
$pmanager = $repos->findOneBy(array('spouse' => $person->getId())); $pmanager = $repos->findOneBy(['spouse' => $person->getId()]);
$this->assertEquals($manager->getId(), $pmanager->getId()); $this->assertEquals($manager->getId(), $pmanager->getId());
$repos = $this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyPerson'); $repos = $this->_em->getRepository('Doctrine\Tests\Models\Company\CompanyPerson');
$pmanager = $repos->findOneBy(array('spouse' => $person->getId())); $pmanager = $repos->findOneBy(['spouse' => $person->getId()]);
$this->assertEquals($manager->getId(), $pmanager->getId()); $this->assertEquals($manager->getId(), $pmanager->getId());
} }

View File

@ -15,12 +15,14 @@ class ClassTableInheritanceTest2 extends OrmFunctionalTestCase
{ {
parent::setUp(); parent::setUp();
try { try {
$this->_schemaTool->createSchema(array( $this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\CTIParent'), $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\CTIParent'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\CTIChild'), $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\CTIChild'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\CTIRelated'), $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\CTIRelated'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\CTIRelated2') $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\CTIRelated2')
)); ]
);
} catch (\Exception $ignored) { } catch (\Exception $ignored) {
// Swallow all exceptions. We do not test the schema tool here. // Swallow all exceptions. We do not test the schema tool here.
} }

View File

@ -30,7 +30,7 @@ class CompositePrimaryKeyTest extends OrmFunctionalTestCase
public function putTripAroundEurope() public function putTripAroundEurope()
{ {
$poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', array('lat' => 100, 'long' => 200)); $poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', ['lat' => 100, 'long' => 200]);
$tour = new NavTour("Trip around Europe"); $tour = new NavTour("Trip around Europe");
$tour->addPointOfInterest($poi); $tour->addPointOfInterest($poi);
@ -46,7 +46,7 @@ class CompositePrimaryKeyTest extends OrmFunctionalTestCase
{ {
$this->putGermanysBrandenburderTor(); $this->putGermanysBrandenburderTor();
$poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', array('lat' => 100, 'long' => 200)); $poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', ['lat' => 100, 'long' => 200]);
$this->assertInstanceOf('Doctrine\Tests\Models\Navigation\NavPointOfInterest', $poi); $this->assertInstanceOf('Doctrine\Tests\Models\Navigation\NavPointOfInterest', $poi);
$this->assertEquals(100, $poi->getLat()); $this->assertEquals(100, $poi->getLat());
@ -61,7 +61,7 @@ class CompositePrimaryKeyTest extends OrmFunctionalTestCase
{ {
$this->putGermanysBrandenburderTor(); $this->putGermanysBrandenburderTor();
$poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', array('lat' => 100, 'long' => 200)); $poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', ['lat' => 100, 'long' => 200]);
$photo = new NavPhotos($poi, "asdf"); $photo = new NavPhotos($poi, "asdf");
$this->_em->persist($photo); $this->_em->persist($photo);
$this->_em->flush(); $this->_em->flush();
@ -79,7 +79,7 @@ class CompositePrimaryKeyTest extends OrmFunctionalTestCase
{ {
$this->putGermanysBrandenburderTor(); $this->putGermanysBrandenburderTor();
$poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', array('lat' => 100, 'long' => 200)); $poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', ['lat' => 100, 'long' => 200]);
$photo = new NavPhotos($poi, "asdf"); $photo = new NavPhotos($poi, "asdf");
$this->_em->persist($photo); $this->_em->persist($photo);
$this->_em->flush(); $this->_em->flush();
@ -140,7 +140,7 @@ class CompositePrimaryKeyTest extends OrmFunctionalTestCase
$this->expectException(ORMException::class); $this->expectException(ORMException::class);
$this->expectExceptionMessage('The identifier long is missing for a query of Doctrine\Tests\Models\Navigation\NavPointOfInterest'); $this->expectExceptionMessage('The identifier long is missing for a query of Doctrine\Tests\Models\Navigation\NavPointOfInterest');
$poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', array('key1' => 100)); $poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', ['key1' => 100]);
} }
public function testUnrecognizedIdentifierFieldsOnGetReference() public function testUnrecognizedIdentifierFieldsOnGetReference()
@ -148,7 +148,8 @@ class CompositePrimaryKeyTest extends OrmFunctionalTestCase
$this->expectException(ORMException::class); $this->expectException(ORMException::class);
$this->expectExceptionMessage("Unrecognized identifier fields: 'key1'"); $this->expectExceptionMessage("Unrecognized identifier fields: 'key1'");
$poi = $this->_em->getReference('Doctrine\Tests\Models\Navigation\NavPointOfInterest', array('lat' => 10, 'long' => 20, 'key1' => 100)); $poi = $this->_em->getReference('Doctrine\Tests\Models\Navigation\NavPointOfInterest', ['lat' => 10, 'long' => 20, 'key1' => 100]
);
} }
/** /**
@ -158,7 +159,7 @@ class CompositePrimaryKeyTest extends OrmFunctionalTestCase
{ {
$this->putGermanysBrandenburderTor(); $this->putGermanysBrandenburderTor();
$poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', array('lat' => 100, 'long' => 200)); $poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', ['lat' => 100, 'long' => 200]);
$poi->addVisitor(new NavUser("test1")); $poi->addVisitor(new NavUser("test1"));
$poi->addVisitor(new NavUser("test2")); $poi->addVisitor(new NavUser("test2"));
@ -169,7 +170,7 @@ class CompositePrimaryKeyTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', array('lat' => 100, 'long' => 200)); $poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', ['lat' => 100, 'long' => 200]);
$this->assertEquals(0, count($poi->getVisitors())); $this->assertEquals(0, count($poi->getVisitors()));
} }
} }

View File

@ -44,13 +44,13 @@ class CompositePrimaryKeyWithAssociationsTest extends OrmFunctionalTestCase
$admin1Repo = $this->_em->getRepository('Doctrine\Tests\Models\GeoNames\Admin1'); $admin1Repo = $this->_em->getRepository('Doctrine\Tests\Models\GeoNames\Admin1');
$admin1NamesRepo = $this->_em->getRepository('Doctrine\Tests\Models\GeoNames\Admin1AlternateName'); $admin1NamesRepo = $this->_em->getRepository('Doctrine\Tests\Models\GeoNames\Admin1AlternateName');
$admin1Rome = $admin1Repo->findOneBy(array('country' => 'IT', 'id' => 1)); $admin1Rome = $admin1Repo->findOneBy(['country' => 'IT', 'id' => 1]);
$names = $admin1NamesRepo->findBy(array('admin1' => $admin1Rome)); $names = $admin1NamesRepo->findBy(['admin1' => $admin1Rome]);
$this->assertCount(2, $names); $this->assertCount(2, $names);
$name1 = $admin1NamesRepo->findOneBy(array('admin1' => $admin1Rome, 'id' => 1)); $name1 = $admin1NamesRepo->findOneBy(['admin1' => $admin1Rome, 'id' => 1]);
$name2 = $admin1NamesRepo->findOneBy(array('admin1' => $admin1Rome, 'id' => 2)); $name2 = $admin1NamesRepo->findOneBy(['admin1' => $admin1Rome, 'id' => 2]);
$this->assertEquals(1, $name1->id); $this->assertEquals(1, $name1->id);
$this->assertEquals("Roma", $name1->name); $this->assertEquals("Roma", $name1->name);

View File

@ -33,15 +33,15 @@ class DatabaseDriverTest extends DatabaseDriverTestCase
$user = new Table("ddc2059_user"); $user = new Table("ddc2059_user");
$user->addColumn('id', 'integer'); $user->addColumn('id', 'integer');
$user->setPrimaryKey(array('id')); $user->setPrimaryKey(['id']);
$project = new Table("ddc2059_project"); $project = new Table("ddc2059_project");
$project->addColumn('id', 'integer'); $project->addColumn('id', 'integer');
$project->addColumn('user_id', 'integer'); $project->addColumn('user_id', 'integer');
$project->addColumn('user', 'string'); $project->addColumn('user', 'string');
$project->setPrimaryKey(array('id')); $project->setPrimaryKey(['id']);
$project->addForeignKeyConstraint('ddc2059_user', array('user_id'), array('id')); $project->addForeignKeyConstraint('ddc2059_user', ['user_id'], ['id']);
$metadata = $this->convertToClassMetadata(array($project, $user), array()); $metadata = $this->convertToClassMetadata([$project, $user], []);
$this->assertTrue(isset($metadata['Ddc2059Project']->fieldMappings['user'])); $this->assertTrue(isset($metadata['Ddc2059Project']->fieldMappings['user']));
$this->assertTrue(isset($metadata['Ddc2059Project']->associationMappings['user2'])); $this->assertTrue(isset($metadata['Ddc2059Project']->associationMappings['user2']));
@ -55,12 +55,12 @@ class DatabaseDriverTest extends DatabaseDriverTestCase
$table = new Table("dbdriver_foo"); $table = new Table("dbdriver_foo");
$table->addColumn('id', 'integer'); $table->addColumn('id', 'integer');
$table->setPrimaryKey(array('id')); $table->setPrimaryKey(['id']);
$table->addColumn('bar', 'string', array('notnull' => false, 'length' => 200)); $table->addColumn('bar', 'string', ['notnull' => false, 'length' => 200]);
$this->_sm->dropAndCreateTable($table); $this->_sm->dropAndCreateTable($table);
$metadatas = $this->extractClassMetadata(array("DbdriverFoo")); $metadatas = $this->extractClassMetadata(["DbdriverFoo"]);
$this->assertArrayHasKey('DbdriverFoo', $metadatas); $this->assertArrayHasKey('DbdriverFoo', $metadatas);
$metadata = $metadatas['DbdriverFoo']; $metadata = $metadatas['DbdriverFoo'];
@ -86,19 +86,19 @@ class DatabaseDriverTest extends DatabaseDriverTestCase
$tableB = new Table("dbdriver_bar"); $tableB = new Table("dbdriver_bar");
$tableB->addColumn('id', 'integer'); $tableB->addColumn('id', 'integer');
$tableB->setPrimaryKey(array('id')); $tableB->setPrimaryKey(['id']);
$this->_sm->dropAndCreateTable($tableB); $this->_sm->dropAndCreateTable($tableB);
$tableA = new Table("dbdriver_baz"); $tableA = new Table("dbdriver_baz");
$tableA->addColumn('id', 'integer'); $tableA->addColumn('id', 'integer');
$tableA->setPrimaryKey(array('id')); $tableA->setPrimaryKey(['id']);
$tableA->addColumn('bar_id', 'integer'); $tableA->addColumn('bar_id', 'integer');
$tableA->addForeignKeyConstraint('dbdriver_bar', array('bar_id'), array('id')); $tableA->addForeignKeyConstraint('dbdriver_bar', ['bar_id'], ['id']);
$this->_sm->dropAndCreateTable($tableA); $this->_sm->dropAndCreateTable($tableA);
$metadatas = $this->extractClassMetadata(array("DbdriverBar", "DbdriverBaz")); $metadatas = $this->extractClassMetadata(["DbdriverBar", "DbdriverBaz"]);
$this->assertArrayHasKey('DbdriverBaz', $metadatas); $this->assertArrayHasKey('DbdriverBaz', $metadatas);
$bazMetadata = $metadatas['DbdriverBaz']; $bazMetadata = $metadatas['DbdriverBaz'];
@ -118,7 +118,7 @@ class DatabaseDriverTest extends DatabaseDriverTestCase
$this->markTestSkipped('Platform does not support foreign keys.'); $this->markTestSkipped('Platform does not support foreign keys.');
} }
$metadatas = $this->extractClassMetadata(array("CmsUsers", "CmsGroups", "CmsTags")); $metadatas = $this->extractClassMetadata(["CmsUsers", "CmsGroups", "CmsTags"]);
$this->assertArrayHasKey('CmsUsers', $metadatas, 'CmsUsers entity was not detected.'); $this->assertArrayHasKey('CmsUsers', $metadatas, 'CmsUsers entity was not detected.');
$this->assertArrayHasKey('CmsGroups', $metadatas, 'CmsGroups entity was not detected.'); $this->assertArrayHasKey('CmsGroups', $metadatas, 'CmsGroups entity was not detected.');
@ -136,18 +136,18 @@ class DatabaseDriverTest extends DatabaseDriverTestCase
{ {
$tableB = new Table("dbdriver_bar"); $tableB = new Table("dbdriver_bar");
$tableB->addColumn('id', 'integer'); $tableB->addColumn('id', 'integer');
$tableB->setPrimaryKey(array('id')); $tableB->setPrimaryKey(['id']);
$tableA = new Table("dbdriver_baz"); $tableA = new Table("dbdriver_baz");
$tableA->addColumn('id', 'integer'); $tableA->addColumn('id', 'integer');
$tableA->setPrimaryKey(array('id')); $tableA->setPrimaryKey(['id']);
$tableMany = new Table("dbdriver_bar_baz"); $tableMany = new Table("dbdriver_bar_baz");
$tableMany->addColumn('bar_id', 'integer'); $tableMany->addColumn('bar_id', 'integer');
$tableMany->addColumn('baz_id', 'integer'); $tableMany->addColumn('baz_id', 'integer');
$tableMany->addForeignKeyConstraint('dbdriver_bar', array('bar_id'), array('id')); $tableMany->addForeignKeyConstraint('dbdriver_bar', ['bar_id'], ['id']);
$metadatas = $this->convertToClassMetadata(array($tableA, $tableB), array($tableMany)); $metadatas = $this->convertToClassMetadata([$tableA, $tableB], [$tableMany]);
$this->assertEquals(0, count($metadatas['DbdriverBaz']->associationMappings), "no association mappings should be detected."); $this->assertEquals(0, count($metadatas['DbdriverBaz']->associationMappings), "no association mappings should be detected.");
} }
@ -160,24 +160,24 @@ class DatabaseDriverTest extends DatabaseDriverTestCase
$table = new Table("dbdriver_foo"); $table = new Table("dbdriver_foo");
$table->addColumn('id', 'integer', array('unsigned' => true)); $table->addColumn('id', 'integer', ['unsigned' => true]);
$table->setPrimaryKey(array('id')); $table->setPrimaryKey(['id']);
$table->addColumn('column_unsigned', 'integer', array('unsigned' => true)); $table->addColumn('column_unsigned', 'integer', ['unsigned' => true]);
$table->addColumn('column_comment', 'string', array('comment' => 'test_comment')); $table->addColumn('column_comment', 'string', ['comment' => 'test_comment']);
$table->addColumn('column_default', 'string', array('default' => 'test_default')); $table->addColumn('column_default', 'string', ['default' => 'test_default']);
$table->addColumn('column_decimal', 'decimal', array('precision' => 4, 'scale' => 3)); $table->addColumn('column_decimal', 'decimal', ['precision' => 4, 'scale' => 3]);
$table->addColumn('column_index1', 'string'); $table->addColumn('column_index1', 'string');
$table->addColumn('column_index2', 'string'); $table->addColumn('column_index2', 'string');
$table->addIndex(array('column_index1','column_index2'), 'index1'); $table->addIndex(['column_index1','column_index2'], 'index1');
$table->addColumn('column_unique_index1', 'string'); $table->addColumn('column_unique_index1', 'string');
$table->addColumn('column_unique_index2', 'string'); $table->addColumn('column_unique_index2', 'string');
$table->addUniqueIndex(array('column_unique_index1', 'column_unique_index2'), 'unique_index1'); $table->addUniqueIndex(['column_unique_index1', 'column_unique_index2'], 'unique_index1');
$this->_sm->dropAndCreateTable($table); $this->_sm->dropAndCreateTable($table);
$metadatas = $this->extractClassMetadata(array("DbdriverFoo")); $metadatas = $this->extractClassMetadata(["DbdriverFoo"]);
$this->assertArrayHasKey('DbdriverFoo', $metadatas); $this->assertArrayHasKey('DbdriverFoo', $metadatas);
@ -208,13 +208,13 @@ class DatabaseDriverTest extends DatabaseDriverTestCase
$this->assertTrue( ! empty($metadata->table['indexes']['index1']['columns'])); $this->assertTrue( ! empty($metadata->table['indexes']['index1']['columns']));
$this->assertEquals( $this->assertEquals(
array('column_index1','column_index2'), ['column_index1','column_index2'],
$metadata->table['indexes']['index1']['columns'] $metadata->table['indexes']['index1']['columns']
); );
$this->assertTrue( ! empty($metadata->table['uniqueConstraints']['unique_index1']['columns'])); $this->assertTrue( ! empty($metadata->table['uniqueConstraints']['unique_index1']['columns']));
$this->assertEquals( $this->assertEquals(
array('column_unique_index1', 'column_unique_index2'), ['column_unique_index1', 'column_unique_index2'],
$metadata->table['uniqueConstraints']['unique_index1']['columns'] $metadata->table['uniqueConstraints']['unique_index1']['columns']
); );
} }

View File

@ -11,13 +11,13 @@ use Doctrine\ORM\Mapping\ClassMetadataInfo;
*/ */
abstract class DatabaseDriverTestCase extends OrmFunctionalTestCase abstract class DatabaseDriverTestCase extends OrmFunctionalTestCase
{ {
protected function convertToClassMetadata(array $entityTables, array $manyTables = array()) protected function convertToClassMetadata(array $entityTables, array $manyTables = [])
{ {
$sm = $this->_em->getConnection()->getSchemaManager(); $sm = $this->_em->getConnection()->getSchemaManager();
$driver = new DatabaseDriver($sm); $driver = new DatabaseDriver($sm);
$driver->setTables($entityTables, $manyTables); $driver->setTables($entityTables, $manyTables);
$metadatas = array(); $metadatas = [];
foreach ($driver->getAllClassNames() AS $className) { foreach ($driver->getAllClassNames() AS $className) {
$class = new ClassMetadataInfo($className); $class = new ClassMetadataInfo($className);
$driver->loadMetadataForClass($className, $class); $driver->loadMetadataForClass($className, $class);
@ -34,7 +34,7 @@ abstract class DatabaseDriverTestCase extends OrmFunctionalTestCase
protected function extractClassMetadata(array $classNames) protected function extractClassMetadata(array $classNames)
{ {
$classNames = array_map('strtolower', $classNames); $classNames = array_map('strtolower', $classNames);
$metadatas = array(); $metadatas = [];
$sm = $this->_em->getConnection()->getSchemaManager(); $sm = $this->_em->getConnection()->getSchemaManager();
$driver = new DatabaseDriver($sm); $driver = new DatabaseDriver($sm);

View File

@ -14,10 +14,12 @@ class DefaultValuesTest extends OrmFunctionalTestCase
{ {
parent::setUp(); parent::setUp();
try { try {
$this->_schemaTool->createSchema(array( $this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\DefaultValueUser'), $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\DefaultValueUser'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\DefaultValueAddress') $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\DefaultValueAddress')
)); ]
);
} catch (\Exception $e) { } catch (\Exception $e) {
// Swallow all exceptions. We do not test the schema tool here. // Swallow all exceptions. We do not test the schema tool here.
} }

View File

@ -31,7 +31,7 @@ class EntityListenersTest extends OrmFunctionalTestCase
$fix = new CompanyFixContract(); $fix = new CompanyFixContract();
$fix->setFixPrice(2000); $fix->setFixPrice(2000);
$this->listener->preFlushCalls = array(); $this->listener->preFlushCalls = [];
$this->_em->persist($fix); $this->_em->persist($fix);
$this->_em->flush(); $this->_em->flush();
@ -60,7 +60,7 @@ class EntityListenersTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$this->listener->postLoadCalls = array(); $this->listener->postLoadCalls = [];
$dql = "SELECT f FROM Doctrine\Tests\Models\Company\CompanyFixContract f WHERE f.id = ?1"; $dql = "SELECT f FROM Doctrine\Tests\Models\Company\CompanyFixContract f WHERE f.id = ?1";
$fix = $this->_em->createQuery($dql)->setParameter(1, $fix->getId())->getSingleResult(); $fix = $this->_em->createQuery($dql)->setParameter(1, $fix->getId())->getSingleResult();
@ -85,7 +85,7 @@ class EntityListenersTest extends OrmFunctionalTestCase
$fix = new CompanyFixContract(); $fix = new CompanyFixContract();
$fix->setFixPrice(2000); $fix->setFixPrice(2000);
$this->listener->prePersistCalls = array(); $this->listener->prePersistCalls = [];
$this->_em->persist($fix); $this->_em->persist($fix);
$this->_em->flush(); $this->_em->flush();
@ -110,7 +110,7 @@ class EntityListenersTest extends OrmFunctionalTestCase
$fix = new CompanyFixContract(); $fix = new CompanyFixContract();
$fix->setFixPrice(2000); $fix->setFixPrice(2000);
$this->listener->postPersistCalls = array(); $this->listener->postPersistCalls = [];
$this->_em->persist($fix); $this->_em->persist($fix);
$this->_em->flush(); $this->_em->flush();
@ -138,7 +138,7 @@ class EntityListenersTest extends OrmFunctionalTestCase
$this->_em->persist($fix); $this->_em->persist($fix);
$this->_em->flush(); $this->_em->flush();
$this->listener->preUpdateCalls = array(); $this->listener->preUpdateCalls = [];
$fix->setFixPrice(2000); $fix->setFixPrice(2000);
@ -168,7 +168,7 @@ class EntityListenersTest extends OrmFunctionalTestCase
$this->_em->persist($fix); $this->_em->persist($fix);
$this->_em->flush(); $this->_em->flush();
$this->listener->postUpdateCalls = array(); $this->listener->postUpdateCalls = [];
$fix->setFixPrice(2000); $fix->setFixPrice(2000);
@ -198,7 +198,7 @@ class EntityListenersTest extends OrmFunctionalTestCase
$this->_em->persist($fix); $this->_em->persist($fix);
$this->_em->flush(); $this->_em->flush();
$this->listener->preRemoveCalls = array(); $this->listener->preRemoveCalls = [];
$this->_em->remove($fix); $this->_em->remove($fix);
$this->_em->flush(); $this->_em->flush();
@ -226,7 +226,7 @@ class EntityListenersTest extends OrmFunctionalTestCase
$this->_em->persist($fix); $this->_em->persist($fix);
$this->_em->flush(); $this->_em->flush();
$this->listener->postRemoveCalls = array(); $this->listener->postRemoveCalls = [];
$this->_em->remove($fix); $this->_em->remove($fix);
$this->_em->flush(); $this->_em->flush();

View File

@ -23,7 +23,7 @@ class EntityRepositoryCriteriaTest extends OrmFunctionalTestCase
public function tearDown() public function tearDown()
{ {
if ($this->_em) { if ($this->_em) {
$this->_em->getConfiguration()->setEntityNamespaces(array()); $this->_em->getConfiguration()->setEntityNamespaces([]);
} }
parent::tearDown(); parent::tearDown();
} }

View File

@ -28,7 +28,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
public function tearDown() public function tearDown()
{ {
if ($this->_em) { if ($this->_em) {
$this->_em->getConfiguration()->setEntityNamespaces(array()); $this->_em->getConfiguration()->setEntityNamespaces([]);
} }
parent::tearDown(); parent::tearDown();
} }
@ -92,7 +92,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
return array($user->id, $address->id); return [$user->id, $address->id];
} }
public function loadFixtureUserEmail() public function loadFixtureUserEmail()
@ -136,7 +136,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
return array($user1, $user2, $user3); return [$user1, $user2, $user3];
} }
public function buildUser($name, $username, $status, $address) public function buildUser($name, $username, $status, $address)
@ -183,7 +183,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$user1Id = $this->loadFixture(); $user1Id = $this->loadFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$users = $repos->findBy(array('status' => 'dev')); $users = $repos->findBy(['status' => 'dev']);
$this->assertEquals(2, count($users)); $this->assertEquals(2, count($users));
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser',$users[0]); $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser',$users[0]);
$this->assertEquals('Guilherme', $users[0]->name); $this->assertEquals('Guilherme', $users[0]->name);
@ -208,7 +208,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress'); $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress');
$addresses = $repository->findBy(array('user' => array($user1->getId(), $user2->getId()))); $addresses = $repository->findBy(['user' => [$user1->getId(), $user2->getId()]]);
$this->assertEquals(2, count($addresses)); $this->assertEquals(2, count($addresses));
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress',$addresses[0]); $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress',$addresses[0]);
@ -232,7 +232,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->_em->clear(); $this->_em->clear();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress'); $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress');
$addresses = $repository->findBy(array('user' => array($user1, $user2))); $addresses = $repository->findBy(['user' => [$user1, $user2]]);
$this->assertEquals(2, count($addresses)); $this->assertEquals(2, count($addresses));
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress',$addresses[0]); $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress',$addresses[0]);
@ -277,13 +277,13 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->loadFixture(); $this->loadFixture();
$repos = $this->_em->getRepository(CmsUser::class); $repos = $this->_em->getRepository(CmsUser::class);
$userCount = $repos->count(array()); $userCount = $repos->count([]);
$this->assertSame(4, $userCount); $this->assertSame(4, $userCount);
$userCount = $repos->count(array('status' => 'dev')); $userCount = $repos->count(['status' => 'dev']);
$this->assertSame(2, $userCount); $this->assertSame(2, $userCount);
$userCount = $repos->count(array('status' => 'nonexistent')); $userCount = $repos->count(['status' => 'nonexistent']);
$this->assertSame(0, $userCount); $this->assertSame(0, $userCount);
} }
@ -405,7 +405,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->expectException(ORMException::class); $this->expectException(ORMException::class);
$this->expectExceptionMessage("You cannot search for the association field 'Doctrine\Tests\Models\CMS\CmsUser#address', because it is the inverse side of an association. Find methods only work on owning side associations."); $this->expectExceptionMessage("You cannot search for the association field 'Doctrine\Tests\Models\CMS\CmsUser#address', because it is the inverse side of an association. Find methods only work on owning side associations.");
$user = $repos->findBy(array('address' => $addressId)); $user = $repos->findBy(['address' => $addressId]);
} }
/** /**
@ -415,7 +415,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
{ {
list($userId, $addressId) = $this->loadAssociatedFixture(); list($userId, $addressId) = $this->loadAssociatedFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress'); $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress');
$address = $repos->findOneBy(array('user' => $userId)); $address = $repos->findOneBy(['user' => $userId]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $address); $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $address);
$this->assertEquals($addressId, $address->id); $this->assertEquals($addressId, $address->id);
@ -429,8 +429,8 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->loadFixture(); $this->loadFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$userAsc = $repos->findOneBy(array(), array("username" => "ASC")); $userAsc = $repos->findOneBy([], ["username" => "ASC"]);
$userDesc = $repos->findOneBy(array(), array("username" => "DESC")); $userDesc = $repos->findOneBy([], ["username" => "DESC"]);
$this->assertNotSame($userAsc, $userDesc); $this->assertNotSame($userAsc, $userDesc);
} }
@ -442,7 +442,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
{ {
list($userId, $addressId) = $this->loadAssociatedFixture(); list($userId, $addressId) = $this->loadAssociatedFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress'); $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress');
$addresses = $repos->findBy(array('user' => $userId)); $addresses = $repos->findBy(['user' => $userId]);
$this->assertContainsOnly('Doctrine\Tests\Models\CMS\CmsAddress', $addresses); $this->assertContainsOnly('Doctrine\Tests\Models\CMS\CmsAddress', $addresses);
$this->assertEquals(1, count($addresses)); $this->assertEquals(1, count($addresses));
@ -501,11 +501,11 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
public function testIsNullCriteriaDoesNotGenerateAParameter() public function testIsNullCriteriaDoesNotGenerateAParameter()
{ {
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$users = $repos->findBy(array('status' => null, 'username' => 'romanb')); $users = $repos->findBy(['status' => null, 'username' => 'romanb']);
$params = $this->_sqlLoggerStack->queries[$this->_sqlLoggerStack->currentQuery]['params']; $params = $this->_sqlLoggerStack->queries[$this->_sqlLoggerStack->currentQuery]['params'];
$this->assertEquals(1, count($params), "Should only execute with one parameter."); $this->assertEquals(1, count($params), "Should only execute with one parameter.");
$this->assertEquals(array('romanb'), $params); $this->assertEquals(['romanb'], $params);
} }
public function testIsNullCriteria() public function testIsNullCriteria()
@ -514,7 +514,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$users = $repos->findBy(array('status' => null)); $users = $repos->findBy(['status' => null]);
$this->assertEquals(1, count($users)); $this->assertEquals(1, count($users));
} }
@ -527,10 +527,10 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$users1 = $repos->findBy(array(), null, 1, 0); $users1 = $repos->findBy([], null, 1, 0);
$users2 = $repos->findBy(array(), null, 1, 1); $users2 = $repos->findBy([], null, 1, 1);
$this->assertEquals(4, count($repos->findBy(array()))); $this->assertEquals(4, count($repos->findBy([])));
$this->assertEquals(1, count($users1)); $this->assertEquals(1, count($users1));
$this->assertEquals(1, count($users2)); $this->assertEquals(1, count($users2));
$this->assertNotSame($users1[0], $users2[0]); $this->assertNotSame($users1[0], $users2[0]);
@ -544,8 +544,8 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->loadFixture(); $this->loadFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$usersAsc = $repos->findBy(array(), array("username" => "ASC")); $usersAsc = $repos->findBy([], ["username" => "ASC"]);
$usersDesc = $repos->findBy(array(), array("username" => "DESC")); $usersDesc = $repos->findBy([], ["username" => "DESC"]);
$this->assertEquals(4, count($usersAsc), "Pre-condition: only four users in fixture"); $this->assertEquals(4, count($usersAsc), "Pre-condition: only four users in fixture");
$this->assertEquals(4, count($usersDesc), "Pre-condition: only four users in fixture"); $this->assertEquals(4, count($usersDesc), "Pre-condition: only four users in fixture");
@ -561,8 +561,8 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->loadFixtureUserEmail(); $this->loadFixtureUserEmail();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$resultAsc = $repository->findBy(array(), array('email' => 'ASC')); $resultAsc = $repository->findBy([], ['email' => 'ASC']);
$resultDesc = $repository->findBy(array(), array('email' => 'DESC')); $resultDesc = $repository->findBy([], ['email' => 'DESC']);
$this->assertCount(3, $resultAsc); $this->assertCount(3, $resultAsc);
$this->assertCount(3, $resultDesc); $this->assertCount(3, $resultDesc);
@ -579,8 +579,8 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->loadFixture(); $this->loadFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$usersAsc = $repos->findByStatus('dev', array('username' => "ASC")); $usersAsc = $repos->findByStatus('dev', ['username' => "ASC"]);
$usersDesc = $repos->findByStatus('dev', array('username' => "DESC")); $usersDesc = $repos->findByStatus('dev', ['username' => "DESC"]);
$this->assertEquals(2, count($usersAsc)); $this->assertEquals(2, count($usersAsc));
$this->assertEquals(2, count($usersDesc)); $this->assertEquals(2, count($usersDesc));
@ -601,8 +601,8 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->loadFixture(); $this->loadFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$users1 = $repos->findByStatus('dev', array(), 1, 0); $users1 = $repos->findByStatus('dev', [], 1, 0);
$users2 = $repos->findByStatus('dev', array(), 1, 1); $users2 = $repos->findByStatus('dev', [], 1, 1);
$this->assertEquals(1, count($users1)); $this->assertEquals(1, count($users1));
$this->assertEquals(1, count($users2)); $this->assertEquals(1, count($users2));
@ -680,7 +680,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
public function testInvalidOrderByAssociation() public function testInvalidOrderByAssociation()
{ {
$this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser') $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser')
->findBy(array('status' => 'test'), array('address' => 'ASC')); ->findBy(['status' => 'test'], ['address' => 'ASC']);
} }
/** /**
@ -692,7 +692,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->expectExceptionMessage('Invalid order by orientation specified for Doctrine\Tests\Models\CMS\CmsUser#username'); $this->expectExceptionMessage('Invalid order by orientation specified for Doctrine\Tests\Models\CMS\CmsUser#username');
$repo = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repo = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$repo->findBy(array('status' => 'test'), array('username' => 'INVALID')); $repo->findBy(['status' => 'test'], ['username' => 'INVALID']);
} }
/** /**
@ -701,10 +701,10 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
public function testFindByAssociationArray() public function testFindByAssociationArray()
{ {
$repo = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsArticle'); $repo = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsArticle');
$data = $repo->findBy(array('user' => array(1, 2, 3))); $data = $repo->findBy(['user' => [1, 2, 3]]);
$query = array_pop($this->_sqlLoggerStack->queries); $query = array_pop($this->_sqlLoggerStack->queries);
$this->assertEquals(array(1,2,3), $query['params'][0]); $this->assertEquals([1,2,3], $query['params'][0]);
$this->assertEquals(Connection::PARAM_INT_ARRAY, $query['types'][0]); $this->assertEquals(Connection::PARAM_INT_ARRAY, $query['types'][0]);
} }
@ -760,7 +760,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$users = $repository->matching(new Criteria( $users = $repository->matching(new Criteria(
Criteria::expr()->in('username', array('beberlei', 'gblanco')) Criteria::expr()->in('username', ['beberlei', 'gblanco'])
)); ));
$this->assertEquals(2, count($users)); $this->assertEquals(2, count($users));
@ -775,7 +775,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$users = $repository->matching(new Criteria( $users = $repository->matching(new Criteria(
Criteria::expr()->notIn('username', array('beberlei', 'gblanco', 'asm89')) Criteria::expr()->notIn('username', ['beberlei', 'gblanco', 'asm89'])
)); ));
$this->assertEquals(1, count($users)); $this->assertEquals(1, count($users));
@ -874,7 +874,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $userId); $user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $userId);
$criteria = new Criteria( $criteria = new Criteria(
Criteria::expr()->in('user', array($user)) Criteria::expr()->in('user', [$user])
); );
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress'); $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress');
@ -941,7 +941,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$rsm = $repository->createResultSetMappingBuilder('u'); $rsm = $repository->createResultSetMappingBuilder('u');
$this->assertInstanceOf('Doctrine\ORM\Query\ResultSetMappingBuilder', $rsm); $this->assertInstanceOf('Doctrine\ORM\Query\ResultSetMappingBuilder', $rsm);
$this->assertEquals(array('u' => 'Doctrine\Tests\Models\CMS\CmsUser'), $rsm->aliasMap); $this->assertEquals(['u' => 'Doctrine\Tests\Models\CMS\CmsUser'], $rsm->aliasMap);
} }
/** /**
@ -953,7 +953,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->expectExceptionMessage('Unrecognized field: '); $this->expectExceptionMessage('Unrecognized field: ');
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$repository->findBy(array('username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1' => 'test')); $repository->findBy(['username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1' => 'test']);
} }
/** /**
@ -965,7 +965,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->expectExceptionMessage('Unrecognized field: '); $this->expectExceptionMessage('Unrecognized field: ');
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$repository->findOneBy(array('username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1' => 'test')); $repository->findOneBy(['username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1' => 'test']);
} }
/** /**
@ -994,7 +994,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->expectExceptionMessage('Unrecognized identifier fields: '); $this->expectExceptionMessage('Unrecognized identifier fields: ');
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$repository->find(array('username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1' => 'test', 'id' => 1)); $repository->find(['username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1' => 'test', 'id' => 1]);
} }
/** /**
@ -1016,7 +1016,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->_em->persist($user2); $this->_em->persist($user2);
$this->_em->flush(); $this->_em->flush();
$users = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser')->findBy(array('status' => array(null))); $users = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser')->findBy(['status' => [null]]);
$this->assertCount(1, $users); $this->assertCount(1, $users);
$this->assertSame($user1, reset($users)); $this->assertSame($user1, reset($users));
@ -1044,7 +1044,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$users = $this $users = $this
->_em ->_em
->getRepository('Doctrine\Tests\Models\CMS\CmsUser') ->getRepository('Doctrine\Tests\Models\CMS\CmsUser')
->findBy(array('status' => array('foo', null))); ->findBy(['status' => ['foo', null]]);
$this->assertCount(1, $users); $this->assertCount(1, $users);
$this->assertSame($user1, reset($users)); $this->assertSame($user1, reset($users));
@ -1072,12 +1072,12 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$users = $this $users = $this
->_em ->_em
->getRepository('Doctrine\Tests\Models\CMS\CmsUser') ->getRepository('Doctrine\Tests\Models\CMS\CmsUser')
->findBy(array('status' => array('dbal maintainer', null))); ->findBy(['status' => ['dbal maintainer', null]]);
$this->assertCount(2, $users); $this->assertCount(2, $users);
foreach ($users as $user) { foreach ($users as $user) {
$this->assertTrue(in_array($user, array($user1, $user2))); $this->assertTrue(in_array($user, [$user1, $user2]));
} }
} }
} }

View File

@ -1229,7 +1229,7 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
return array($user->id, $tweet->id); return [$user->id, $tweet->id];
} }
/** /**
@ -1250,6 +1250,6 @@ class ExtraLazyCollectionTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
return array($user->id, $userList->id); return [$user->id, $userList->id];
} }
} }

View File

@ -82,7 +82,7 @@ class IdentityMapTest extends OrmFunctionalTestCase
$this->assertSame($user1, $address->user); $this->assertSame($user1, $address->user);
//external update to CmsAddress //external update to CmsAddress
$this->_em->getConnection()->executeUpdate('update cms_addresses set user_id = ?', array($user2->getId())); $this->_em->getConnection()->executeUpdate('update cms_addresses set user_id = ?', [$user2->getId()]);
// But we want to have this external change! // But we want to have this external change!
// Solution 1: refresh(), broken atm! // Solution 1: refresh(), broken atm!
@ -125,7 +125,7 @@ class IdentityMapTest extends OrmFunctionalTestCase
$this->assertSame($user1, $address->user); $this->assertSame($user1, $address->user);
//external update to CmsAddress //external update to CmsAddress
$this->_em->getConnection()->executeUpdate('update cms_addresses set user_id = ?', array($user2->getId())); $this->_em->getConnection()->executeUpdate('update cms_addresses set user_id = ?', [$user2->getId()]);
//select //select
$q = $this->_em->createQuery('select a, u from Doctrine\Tests\Models\CMS\CmsAddress a join a.user u'); $q = $this->_em->createQuery('select a, u from Doctrine\Tests\Models\CMS\CmsAddress a join a.user u');
@ -181,7 +181,8 @@ class IdentityMapTest extends OrmFunctionalTestCase
$this->assertFalse($user->getPhonenumbers()->isDirty()); $this->assertFalse($user->getPhonenumbers()->isDirty());
//external update to CmsAddress //external update to CmsAddress
$this->_em->getConnection()->executeUpdate('insert into cms_phonenumbers (phonenumber, user_id) VALUES (?,?)', array(999, $user->getId())); $this->_em->getConnection()->executeUpdate('insert into cms_phonenumbers (phonenumber, user_id) VALUES (?,?)', [999, $user->getId()]
);
//select //select
$q = $this->_em->createQuery('select u, p from Doctrine\Tests\Models\CMS\CmsUser u join u.phonenumbers p'); $q = $this->_em->createQuery('select u, p from Doctrine\Tests\Models\CMS\CmsUser u join u.phonenumbers p');
@ -232,7 +233,8 @@ class IdentityMapTest extends OrmFunctionalTestCase
$this->assertEquals(3, count($user->getPhonenumbers())); $this->assertEquals(3, count($user->getPhonenumbers()));
//external update to CmsAddress //external update to CmsAddress
$this->_em->getConnection()->executeUpdate('insert into cms_phonenumbers (phonenumber, user_id) VALUES (?,?)', array(999, $user->getId())); $this->_em->getConnection()->executeUpdate('insert into cms_phonenumbers (phonenumber, user_id) VALUES (?,?)', [999, $user->getId()]
);
//select //select
$q = $this->_em->createQuery('select u, p from Doctrine\Tests\Models\CMS\CmsUser u join u.phonenumbers p'); $q = $this->_em->createQuery('select u, p from Doctrine\Tests\Models\CMS\CmsUser u join u.phonenumbers p');

View File

@ -58,7 +58,7 @@ class JoinedTableCompositeKeyTest extends OrmFunctionalTestCase
{ {
return $this->_em->find( return $this->_em->find(
'Doctrine\Tests\Models\CompositeKeyInheritance\JoinedRootClass', 'Doctrine\Tests\Models\CompositeKeyInheritance\JoinedRootClass',
array('keyPart1' => 'part-1', 'keyPart2' => 'part-2') ['keyPart1' => 'part-1', 'keyPart2' => 'part-2']
); );
} }
} }

View File

@ -15,12 +15,14 @@ class LifecycleCallbackTest extends OrmFunctionalTestCase
{ {
parent::setUp(); parent::setUp();
try { try {
$this->_schemaTool->createSchema(array( $this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\LifecycleCallbackEventArgEntity'), $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\LifecycleCallbackEventArgEntity'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\LifecycleCallbackTestEntity'), $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\LifecycleCallbackTestEntity'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\LifecycleCallbackTestUser'), $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\LifecycleCallbackTestUser'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\LifecycleCallbackCascader'), $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\LifecycleCallbackCascader'),
)); ]
);
} catch (\Exception $e) { } catch (\Exception $e) {
// Swallow all exceptions. We do not test the schema tool here. // Swallow all exceptions. We do not test the schema tool here.
} }
@ -270,13 +272,13 @@ DQL;
public function testLifecycleCallbacksGetInherited() public function testLifecycleCallbacksGetInherited()
{ {
$childMeta = $this->_em->getClassMetadata(__NAMESPACE__ . '\LifecycleCallbackChildEntity'); $childMeta = $this->_em->getClassMetadata(__NAMESPACE__ . '\LifecycleCallbackChildEntity');
$this->assertEquals(array('prePersist' => array(0 => 'doStuff')), $childMeta->lifecycleCallbacks); $this->assertEquals(['prePersist' => [0 => 'doStuff']], $childMeta->lifecycleCallbacks);
} }
public function testLifecycleListener_ChangeUpdateChangeSet() public function testLifecycleListener_ChangeUpdateChangeSet()
{ {
$listener = new LifecycleListenerPreUpdate; $listener = new LifecycleListenerPreUpdate;
$this->_em->getEventManager()->addEventListener(array('preUpdate'), $listener); $this->_em->getEventManager()->addEventListener(['preUpdate'], $listener);
$user = new LifecycleCallbackTestUser; $user = new LifecycleCallbackTestUser;
$user->setName('Bob'); $user->setName('Bob');
@ -292,7 +294,7 @@ DQL;
$this->_em->flush(); // preUpdate reverts Alice to Bob $this->_em->flush(); // preUpdate reverts Alice to Bob
$this->_em->clear(); $this->_em->clear();
$this->_em->getEventManager()->removeEventListener(array('preUpdate'), $listener); $this->_em->getEventManager()->removeEventListener(['preUpdate'], $listener);
$bob = $this->_em->createQuery($dql)->getSingleResult(); $bob = $this->_em->createQuery($dql)->getSingleResult();
@ -517,7 +519,7 @@ class LifecycleCallbackEventArgEntity
/** @Column() */ /** @Column() */
public $value; public $value;
public $calls = array(); public $calls = [];
/** /**
* @PostPersist * @PostPersist

View File

@ -23,11 +23,11 @@ class GearmanLockTest extends OrmFunctionalTestCase
$this->useModelSet('cms'); $this->useModelSet('cms');
parent::setUp(); parent::setUp();
$this->tasks = array(); $this->tasks = [];
$this->gearman = new \GearmanClient(); $this->gearman = new \GearmanClient();
$this->gearman->addServer(); $this->gearman->addServer();
$this->gearman->setCompleteCallback(array($this, "gearmanTaskCompleted")); $this->gearman->setCompleteCallback([$this, "gearmanTaskCompleted"]);
$article = new CmsArticle(); $article = new CmsArticle();
$article->text = "my article"; $article->text = "my article";
@ -78,7 +78,7 @@ class GearmanLockTest extends OrmFunctionalTestCase
public function testDqlWithLock() public function testDqlWithLock()
{ {
$this->asyncDqlWithLock('SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a', array(), LockMode::PESSIMISTIC_WRITE); $this->asyncDqlWithLock('SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a', [], LockMode::PESSIMISTIC_WRITE);
$this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE); $this->asyncFindWithLock('Doctrine\Tests\Models\CMS\CmsArticle', $this->articleId, LockMode::PESSIMISTIC_WRITE);
$this->assertLockWorked(); $this->assertLockWorked();
@ -140,37 +140,42 @@ class GearmanLockTest extends OrmFunctionalTestCase
protected function asyncFindWithLock($entityName, $entityId, $lockMode) protected function asyncFindWithLock($entityName, $entityId, $lockMode)
{ {
$this->startJob('findWithLock', array( $this->startJob('findWithLock', [
'entityName' => $entityName, 'entityName' => $entityName,
'entityId' => $entityId, 'entityId' => $entityId,
'lockMode' => $lockMode, 'lockMode' => $lockMode,
)); ]
);
} }
protected function asyncDqlWithLock($dql, $params, $lockMode) protected function asyncDqlWithLock($dql, $params, $lockMode)
{ {
$this->startJob('dqlWithLock', array( $this->startJob('dqlWithLock', [
'dql' => $dql, 'dql' => $dql,
'dqlParams' => $params, 'dqlParams' => $params,
'lockMode' => $lockMode, 'lockMode' => $lockMode,
)); ]
);
} }
protected function asyncLock($entityName, $entityId, $lockMode) protected function asyncLock($entityName, $entityId, $lockMode)
{ {
$this->startJob('lock', array( $this->startJob('lock', [
'entityName' => $entityName, 'entityName' => $entityName,
'entityId' => $entityId, 'entityId' => $entityId,
'lockMode' => $lockMode, 'lockMode' => $lockMode,
)); ]
);
} }
protected function startJob($fn, $fixture) protected function startJob($fn, $fixture)
{ {
$this->gearman->addTask($fn, serialize(array( $this->gearman->addTask($fn, serialize(
[
'conn' => $this->_em->getConnection()->getParams(), 'conn' => $this->_em->getConnection()->getParams(),
'fixture' => $fixture 'fixture' => $fixture
))); ]
));
$this->assertEquals(GEARMAN_SUCCESS, $this->gearman->returnCode()); $this->assertEquals(GEARMAN_SUCCESS, $this->gearman->returnCode());
} }

View File

@ -17,9 +17,9 @@ class LockAgentWorker
$worker = new \GearmanWorker(); $worker = new \GearmanWorker();
$worker->addServer(); $worker->addServer();
$worker->addFunction("findWithLock", array($lockAgent, "findWithLock")); $worker->addFunction("findWithLock", [$lockAgent, "findWithLock"]);
$worker->addFunction("dqlWithLock", array($lockAgent, "dqlWithLock")); $worker->addFunction("dqlWithLock", [$lockAgent, "dqlWithLock"]);
$worker->addFunction('lock', array($lockAgent, 'lock')); $worker->addFunction('lock', [$lockAgent, 'lock']);
while($worker->work()) { while($worker->work()) {
if ($worker->returnCode() != GEARMAN_SUCCESS) { if ($worker->returnCode() != GEARMAN_SUCCESS) {
@ -98,7 +98,7 @@ class LockAgentWorker
$config->setProxyNamespace('MyProject\Proxies'); $config->setProxyNamespace('MyProject\Proxies');
$config->setAutoGenerateProxyClasses(true); $config->setAutoGenerateProxyClasses(true);
$annotDriver = $config->newDefaultAnnotationDriver(array(__DIR__ . '/../../../Models/'), true); $annotDriver = $config->newDefaultAnnotationDriver([__DIR__ . '/../../../Models/'], true);
$config->setMetadataDriverImpl($annotDriver); $config->setMetadataDriverImpl($annotDriver);
$cache = new ArrayCache(); $cache = new ArrayCache();

View File

@ -19,7 +19,7 @@ class LockTest extends OrmFunctionalTestCase
{ {
$this->useModelSet('cms'); $this->useModelSet('cms');
parent::setUp(); parent::setUp();
$this->handles = array(); $this->handles = [];
} }
/** /**

View File

@ -14,12 +14,14 @@ class OptimisticTest extends OrmFunctionalTestCase
parent::setUp(); parent::setUp();
try { try {
$this->_schemaTool->createSchema(array( $this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Locking\OptimisticJoinedParent'), $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Locking\OptimisticJoinedParent'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Locking\OptimisticJoinedChild'), $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Locking\OptimisticJoinedChild'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Locking\OptimisticStandard'), $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Locking\OptimisticStandard'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Locking\OptimisticTimestamp') $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Locking\OptimisticTimestamp')
)); ]
);
} catch (\Exception $e) { } catch (\Exception $e) {
// Swallow all exceptions. We do not test the schema tool here. // Swallow all exceptions. We do not test the schema tool here.
} }
@ -55,7 +57,7 @@ class OptimisticTest extends OrmFunctionalTestCase
// Manually update/increment the version so we can try and save the same // Manually update/increment the version so we can try and save the same
// $test and make sure the exception is thrown saying the record was // $test and make sure the exception is thrown saying the record was
// changed or updated since you read it // changed or updated since you read it
$this->_conn->executeQuery('UPDATE optimistic_joined_parent SET version = ? WHERE id = ?', array(2, $test->id)); $this->_conn->executeQuery('UPDATE optimistic_joined_parent SET version = ? WHERE id = ?', [2, $test->id]);
// Now lets change a property and try and save it again // Now lets change a property and try and save it again
$test->whatever = 'ok'; $test->whatever = 'ok';
@ -95,7 +97,7 @@ class OptimisticTest extends OrmFunctionalTestCase
// Manually update/increment the version so we can try and save the same // Manually update/increment the version so we can try and save the same
// $test and make sure the exception is thrown saying the record was // $test and make sure the exception is thrown saying the record was
// changed or updated since you read it // changed or updated since you read it
$this->_conn->executeQuery('UPDATE optimistic_joined_parent SET version = ? WHERE id = ?', array(2, $test->id)); $this->_conn->executeQuery('UPDATE optimistic_joined_parent SET version = ? WHERE id = ?', [2, $test->id]);
// Now lets change a property and try and save it again // Now lets change a property and try and save it again
$test->name = 'WHATT???'; $test->name = 'WHATT???';
@ -151,7 +153,7 @@ class OptimisticTest extends OrmFunctionalTestCase
// Manually update/increment the version so we can try and save the same // Manually update/increment the version so we can try and save the same
// $test and make sure the exception is thrown saying the record was // $test and make sure the exception is thrown saying the record was
// changed or updated since you read it // changed or updated since you read it
$this->_conn->executeQuery('UPDATE optimistic_standard SET version = ? WHERE id = ?', array(2, $test->id)); $this->_conn->executeQuery('UPDATE optimistic_standard SET version = ? WHERE id = ?', [2, $test->id]);
// Now lets change a property and try and save it again // Now lets change a property and try and save it again
$test->name = 'WHATT???'; $test->name = 'WHATT???';
@ -210,7 +212,8 @@ class OptimisticTest extends OrmFunctionalTestCase
// Manually increment the version datetime column // Manually increment the version datetime column
$format = $this->_em->getConnection()->getDatabasePlatform()->getDateTimeFormatString(); $format = $this->_em->getConnection()->getDatabasePlatform()->getDateTimeFormatString();
$this->_conn->executeQuery('UPDATE optimistic_timestamp SET version = ? WHERE id = ?', array(date($format, strtotime($test->version->format($format)) + 3600), $test->id)); $this->_conn->executeQuery('UPDATE optimistic_timestamp SET version = ? WHERE id = ?', [date($format, strtotime($test->version->format($format)) + 3600), $test->id]
);
// Try and update the record and it should throw an exception // Try and update the record and it should throw an exception
$caughtException = null; $caughtException = null;

View File

@ -330,7 +330,7 @@ class ManyToManyBasicAssociationTest extends OrmFunctionalTestCase
$user = $this->_em->find(get_class($user), $user->id); $user = $this->_em->find(get_class($user), $user->id);
$coll = new ArrayCollection(array($group1, $group2)); $coll = new ArrayCollection([$group1, $group2]);
$user->groups = $coll; $user->groups = $coll;
$this->_em->flush(); $this->_em->flush();
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $user->groups, $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $user->groups,

View File

@ -15,10 +15,12 @@ class MergeCompositeToOneKeyTest extends OrmFunctionalTestCase
{ {
parent::setUp(); parent::setUp();
$this->_schemaTool->createSchema(array( $this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(Country::CLASSNAME), $this->_em->getClassMetadata(Country::CLASSNAME),
$this->_em->getClassMetadata(CompositeToOneKeyState::CLASSNAME), $this->_em->getClassMetadata(CompositeToOneKeyState::CLASSNAME),
)); ]
);
} }
/** /**

View File

@ -239,7 +239,7 @@ class MergeProxiesTest extends OrmFunctionalTestCase
$config->setProxyDir(realpath(__DIR__ . '/../../Proxies')); $config->setProxyDir(realpath(__DIR__ . '/../../Proxies'));
$config->setProxyNamespace('Doctrine\Tests\Proxies'); $config->setProxyNamespace('Doctrine\Tests\Proxies');
$config->setMetadataDriverImpl($config->newDefaultAnnotationDriver( $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver(
array(realpath(__DIR__ . '/../../Models/Cache')), [realpath(__DIR__ . '/../../Models/Cache')],
true true
)); ));
$config->setSQLLogger($logger); $config->setSQLLogger($logger);
@ -248,10 +248,10 @@ class MergeProxiesTest extends OrmFunctionalTestCase
// multi-connection is not relevant for the purpose of checking locking here, but merely // multi-connection is not relevant for the purpose of checking locking here, but merely
// to stub out DB-level access and intercept it // to stub out DB-level access and intercept it
$connection = DriverManager::getConnection( $connection = DriverManager::getConnection(
array( [
'driver' => 'pdo_sqlite', 'driver' => 'pdo_sqlite',
'memory' => true 'memory' => true
), ],
$config $config
); );

View File

@ -15,10 +15,12 @@ class MergeSharedEntitiesTest extends OrmFunctionalTestCase
parent::setUp(); parent::setUp();
try { try {
$this->_schemaTool->createSchema(array( $this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(__NAMESPACE__ . '\MSEFile'), $this->_em->getClassMetadata(__NAMESPACE__ . '\MSEFile'),
$this->_em->getClassMetadata(__NAMESPACE__ . '\MSEPicture'), $this->_em->getClassMetadata(__NAMESPACE__ . '\MSEPicture'),
)); ]
);
} catch (ToolsException $ignored) { } catch (ToolsException $ignored) {
} }
} }

View File

@ -281,7 +281,8 @@ class NativeQueryTest extends OrmFunctionalTestCase
$rsm = new ResultSetMappingBuilder($this->_em); $rsm = new ResultSetMappingBuilder($this->_em);
$rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u'); $rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u');
$rsm->addJoinedEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', 'a', 'u', 'address', array('id' => 'a_id')); $rsm->addJoinedEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', 'a', 'u', 'address', ['id' => 'a_id']
);
$query = $this->_em->createNativeQuery('SELECT u.*, a.*, a.id AS a_id FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ?', $rsm); $query = $this->_em->createNativeQuery('SELECT u.*, a.*, a.id AS a_id FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ?', $rsm);
$query->setParameter(1, 'romanb'); $query->setParameter(1, 'romanb');
@ -349,7 +350,8 @@ class NativeQueryTest extends OrmFunctionalTestCase
{ {
$rsm = new ResultSetMappingBuilder($this->_em); $rsm = new ResultSetMappingBuilder($this->_em);
$rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u'); $rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u');
$rsm->addJoinedEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', 'a', 'un', 'address', array('id' => 'a_id')); $rsm->addJoinedEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', 'a', 'un', 'address', ['id' => 'a_id']
);
$query = $this->_em->createNativeQuery('SELECT u.*, a.*, a.id AS a_id FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ?', $rsm); $query = $this->_em->createNativeQuery('SELECT u.*, a.*, a.id AS a_id FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ?', $rsm);
$query->setParameter(1, 'romanb'); $query->setParameter(1, 'romanb');
@ -558,7 +560,7 @@ class NativeQueryTest extends OrmFunctionalTestCase
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$result = $repository->createNativeNamedQuery('fetchUserPhonenumberCount') $result = $repository->createNativeNamedQuery('fetchUserPhonenumberCount')
->setParameter(1, array('test','FabioBatSilva'))->getResult(); ->setParameter(1, ['test','FabioBatSilva'])->getResult();
$this->assertEquals(2, count($result)); $this->assertEquals(2, count($result));
$this->assertTrue(is_array($result[0])); $this->assertTrue(is_array($result[0]));
@ -746,10 +748,11 @@ class NativeQueryTest extends OrmFunctionalTestCase
public function testGenerateSelectClauseCustomRenames() public function testGenerateSelectClauseCustomRenames()
{ {
$rsm = new ResultSetMappingBuilder($this->_em); $rsm = new ResultSetMappingBuilder($this->_em);
$rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u', array( $rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u', [
'id' => 'id1', 'id' => 'id1',
'username' => 'username2' 'username' => 'username2'
)); ]
);
$selectClause = $rsm->generateSelectClause(); $selectClause = $rsm->generateSelectClause();
@ -764,7 +767,7 @@ class NativeQueryTest extends OrmFunctionalTestCase
$rsm = new ResultSetMappingBuilder($this->_em); $rsm = new ResultSetMappingBuilder($this->_em);
$rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u'); $rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u');
$selectClause = $rsm->generateSelectClause(array('u' => 'u1')); $selectClause = $rsm->generateSelectClause(['u' => 'u1']);
$this->assertSQLEquals('u1.id AS id, u1.status AS status, u1.username AS username, u1.name AS name, u1.email_id AS email_id', $selectClause); $this->assertSQLEquals('u1.id AS id, u1.status AS status, u1.username AS username, u1.name AS name, u1.email_id AS email_id', $selectClause);
} }
@ -804,7 +807,7 @@ class NativeQueryTest extends OrmFunctionalTestCase
$rsm->addFieldResult('u', $this->platform->getSQLResultCasing('id'), 'id'); $rsm->addFieldResult('u', $this->platform->getSQLResultCasing('id'), 'id');
$rsm->setDiscriminatorColumn('c', $this->platform->getSQLResultCasing('discr')); $rsm->setDiscriminatorColumn('c', $this->platform->getSQLResultCasing('discr'));
$selectClause = $rsm->generateSelectClause(array('u' => 'u1', 'c' => 'c1')); $selectClause = $rsm->generateSelectClause(['u' => 'u1', 'c' => 'c1']);
$this->assertSQLEquals('u1.id as id, c1.discr as discr', $selectClause); $this->assertSQLEquals('u1.id as id, c1.discr as discr', $selectClause);
} }

View File

@ -29,10 +29,10 @@ class NewOperatorTest extends OrmFunctionalTestCase
public function provideDataForHydrationMode() public function provideDataForHydrationMode()
{ {
return array( return [
array(Query::HYDRATE_ARRAY), [Query::HYDRATE_ARRAY],
array(Query::HYDRATE_OBJECT), [Query::HYDRATE_OBJECT],
); ];
} }
private function loadFixtures() private function loadFixtures()
@ -93,7 +93,7 @@ class NewOperatorTest extends OrmFunctionalTestCase
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$this->fixtures = array($u1, $u2, $u3); $this->fixtures = [$u1, $u2, $u3];
} }
/** /**

View File

@ -18,10 +18,12 @@ class NotifyPolicyTest extends OrmFunctionalTestCase
{ {
parent::setUp(); parent::setUp();
try { try {
$this->_schemaTool->createSchema(array( $this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\NotifyUser'), $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\NotifyUser'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\NotifyGroup') $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\NotifyGroup')
)); ]
);
} catch (\Exception $e) { } catch (\Exception $e) {
// Swallow all exceptions. We do not test the schema tool here. // Swallow all exceptions. We do not test the schema tool here.
} }
@ -91,7 +93,7 @@ class NotifyPolicyTest extends OrmFunctionalTestCase
} }
class NotifyBaseEntity implements NotifyPropertyChanged { class NotifyBaseEntity implements NotifyPropertyChanged {
public $listeners = array(); public $listeners = [];
public function addPropertyChangedListener(PropertyChangedListener $listener) { public function addPropertyChangedListener(PropertyChangedListener $listener) {
$this->listeners[] = $listener; $this->listeners[] = $listener;

View File

@ -232,7 +232,7 @@ class OneToManyBidirectionalAssociationTest extends OrmFunctionalTestCase
public function assertFeatureForeignKeyIs($value, ECommerceFeature $feature) { public function assertFeatureForeignKeyIs($value, ECommerceFeature $feature) {
$foreignKey = $this->_em->getConnection()->executeQuery( $foreignKey = $this->_em->getConnection()->executeQuery(
'SELECT product_id FROM ecommerce_features WHERE id=?', 'SELECT product_id FROM ecommerce_features WHERE id=?',
array($feature->getId()) [$feature->getId()]
)->fetchColumn(); )->fetchColumn();
$this->assertEquals($value, $foreignKey); $this->assertEquals($value, $foreignKey);
} }

View File

@ -116,7 +116,8 @@ class OneToManySelfReferentialAssociationTest extends OrmFunctionalTestCase
} }
public function assertForeignKeyIs($value, ECommerceCategory $child) { public function assertForeignKeyIs($value, ECommerceCategory $child) {
$foreignKey = $this->_em->getConnection()->executeQuery('SELECT parent_id FROM ecommerce_categories WHERE id=?', array($child->getId()))->fetchColumn(); $foreignKey = $this->_em->getConnection()->executeQuery('SELECT parent_id FROM ecommerce_categories WHERE id=?', [$child->getId()]
)->fetchColumn();
$this->assertEquals($value, $foreignKey); $this->assertEquals($value, $foreignKey);
} }
} }

View File

@ -12,14 +12,14 @@ use Doctrine\Tests\OrmFunctionalTestCase;
*/ */
class OneToManyUnidirectionalAssociationTest extends OrmFunctionalTestCase class OneToManyUnidirectionalAssociationTest extends OrmFunctionalTestCase
{ {
protected $locations = array(); protected $locations = [];
public function setUp() public function setUp()
{ {
$this->useModelSet('routing'); $this->useModelSet('routing');
parent::setUp(); parent::setUp();
$locations = array("Berlin", "Bonn", "Brasilia", "Atlanta"); $locations = ["Berlin", "Bonn", "Brasilia", "Atlanta"];
foreach ($locations AS $locationName) { foreach ($locations AS $locationName) {
$location = new RoutingLocation(); $location = new RoutingLocation();

View File

@ -144,7 +144,8 @@ class OneToOneBidirectionalAssociationTest extends OrmFunctionalTestCase
} }
public function assertCartForeignKeyIs($value) { public function assertCartForeignKeyIs($value) {
$foreignKey = $this->_em->getConnection()->executeQuery('SELECT customer_id FROM ecommerce_carts WHERE id=?', array($this->cart->getId()))->fetchColumn(); $foreignKey = $this->_em->getConnection()->executeQuery('SELECT customer_id FROM ecommerce_carts WHERE id=?', [$this->cart->getId()]
)->fetchColumn();
$this->assertEquals($value, $foreignKey); $this->assertEquals($value, $foreignKey);
} }
} }

View File

@ -15,13 +15,15 @@ class OneToOneEagerLoadingTest extends OrmFunctionalTestCase
parent::setUp(); parent::setUp();
$schemaTool = new SchemaTool($this->_em); $schemaTool = new SchemaTool($this->_em);
try { try {
$schemaTool->createSchema(array( $schemaTool->createSchema(
[
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Train'), $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Train'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\TrainDriver'), $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\TrainDriver'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\TrainOwner'), $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\TrainOwner'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Waggon'), $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Waggon'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\TrainOrder'), $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\TrainOrder'),
)); ]
);
} catch(\Exception $e) {} } catch(\Exception $e) {}
} }

View File

@ -86,9 +86,11 @@ class OneToOneSelfReferentialAssociationTest extends OrmFunctionalTestCase
public function testMultiSelfReference() public function testMultiSelfReference()
{ {
try { try {
$this->_schemaTool->createSchema(array( $this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\MultiSelfReference') $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\MultiSelfReference')
)); ]
);
} catch (\Exception $e) { } catch (\Exception $e) {
// Swallow all exceptions. We do not test the schema tool here. // Swallow all exceptions. We do not test the schema tool here.
} }
@ -118,7 +120,8 @@ class OneToOneSelfReferentialAssociationTest extends OrmFunctionalTestCase
} }
public function assertForeignKeyIs($value) { public function assertForeignKeyIs($value) {
$foreignKey = $this->_em->getConnection()->executeQuery('SELECT mentor_id FROM ecommerce_customers WHERE id=?', array($this->customer->getId()))->fetchColumn(); $foreignKey = $this->_em->getConnection()->executeQuery('SELECT mentor_id FROM ecommerce_customers WHERE id=?', [$this->customer->getId()]
)->fetchColumn();
$this->assertEquals($value, $foreignKey); $this->assertEquals($value, $foreignKey);
} }

View File

@ -101,7 +101,7 @@ class OneToOneUnidirectionalAssociationTest extends OrmFunctionalTestCase
public function assertForeignKeyIs($value) { public function assertForeignKeyIs($value) {
$foreignKey = $this->_em->getConnection()->executeQuery( $foreignKey = $this->_em->getConnection()->executeQuery(
'SELECT shipping_id FROM ecommerce_products WHERE id=?', 'SELECT shipping_id FROM ecommerce_products WHERE id=?',
array($this->product->getId()) [$this->product->getId()]
)->fetchColumn(); )->fetchColumn();
$this->assertEquals($value, $foreignKey); $this->assertEquals($value, $foreignKey);
} }

View File

@ -10,14 +10,14 @@ use Doctrine\Tests\OrmFunctionalTestCase;
class OrderedCollectionTest extends OrmFunctionalTestCase class OrderedCollectionTest extends OrmFunctionalTestCase
{ {
protected $locations = array(); protected $locations = [];
public function setUp() public function setUp()
{ {
$this->useModelSet('routing'); $this->useModelSet('routing');
parent::setUp(); parent::setUp();
$locations = array("Berlin", "Bonn", "Brasilia", "Atlanta"); $locations = ["Berlin", "Bonn", "Brasilia", "Atlanta"];
foreach ($locations AS $locationName) { foreach ($locations AS $locationName) {
$location = new RoutingLocation(); $location = new RoutingLocation();

View File

@ -16,11 +16,13 @@ class OrderedJoinedTableInheritanceCollectionTest extends OrmFunctionalTestCase
{ {
parent::setUp(); parent::setUp();
try { try {
$this->_schemaTool->createSchema(array( $this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\OJTIC_Pet'), $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\OJTIC_Pet'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\OJTIC_Cat'), $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\OJTIC_Cat'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\OJTIC_Dog'), $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\OJTIC_Dog'),
)); ]
);
} catch (\Exception $e) { } catch (\Exception $e) {
// Swallow all exceptions. We do not test the schema tool here. // Swallow all exceptions. We do not test the schema tool here.
} }

View File

@ -633,7 +633,8 @@ class PaginationTest extends OrmFunctionalTestCase
{ {
$dql = 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u'; $dql = 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u';
$query = $this->_em->createQuery($dql); $query = $this->_em->createQuery($dql);
$query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, array('Doctrine\Tests\ORM\Functional\CustomPaginationTestTreeWalker')); $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, ['Doctrine\Tests\ORM\Functional\CustomPaginationTestTreeWalker']
);
$paginator = new Paginator($query, true); $paginator = new Paginator($query, true);
$paginator->setUseOutputWalkers(false); $paginator->setUseOutputWalkers(false);
@ -695,7 +696,7 @@ class PaginationTest extends OrmFunctionalTestCase
public function populate() public function populate()
{ {
$groups = array(); $groups = [];
for ($j = 0; $j < 3; $j++) {; for ($j = 0; $j < 3; $j++) {;
$group = new CmsGroup(); $group = new CmsGroup();
$group->name = "group$j"; $group->name = "group$j";
@ -762,28 +763,28 @@ class PaginationTest extends OrmFunctionalTestCase
public function useOutputWalkers() public function useOutputWalkers()
{ {
return array( return [
array(true), [true],
array(false), [false],
); ];
} }
public function fetchJoinCollection() public function fetchJoinCollection()
{ {
return array( return [
array(true), [true],
array(false), [false],
); ];
} }
public function useOutputWalkersAndFetchJoinCollection() public function useOutputWalkersAndFetchJoinCollection()
{ {
return array( return [
array(true, false), [true, false],
array(true, true), [true, true],
array(false, false), [false, false],
array(false, true), [false, true],
); ];
} }
} }

View File

@ -24,7 +24,7 @@ class PersistentCollectionCriteriaTest extends OrmFunctionalTestCase
public function tearDown() public function tearDown()
{ {
if ($this->_em) { if ($this->_em) {
$this->_em->getConfiguration()->setEntityNamespaces(array()); $this->_em->getConfiguration()->setEntityNamespaces([]);
} }
parent::tearDown(); parent::tearDown();
} }
@ -75,7 +75,7 @@ class PersistentCollectionCriteriaTest extends OrmFunctionalTestCase
$repository = $this->_em->getRepository('Doctrine\Tests\Models\Tweet\User'); $repository = $this->_em->getRepository('Doctrine\Tests\Models\Tweet\User');
$user = $repository->findOneBy(array('name' => 'ngal')); $user = $repository->findOneBy(['name' => 'ngal']);
$tweets = $user->tweets->matching(new Criteria()); $tweets = $user->tweets->matching(new Criteria());
$this->assertInstanceOf('Doctrine\ORM\LazyCriteriaCollection', $tweets); $this->assertInstanceOf('Doctrine\ORM\LazyCriteriaCollection', $tweets);

View File

@ -13,10 +13,12 @@ class PersistentCollectionTest extends OrmFunctionalTestCase
{ {
parent::setUp(); parent::setUp();
try { try {
$this->_schemaTool->createSchema(array( $this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata(__NAMESPACE__ . '\PersistentCollectionHolder'), $this->_em->getClassMetadata(__NAMESPACE__ . '\PersistentCollectionHolder'),
$this->_em->getClassMetadata(__NAMESPACE__ . '\PersistentCollectionContent'), $this->_em->getClassMetadata(__NAMESPACE__ . '\PersistentCollectionContent'),
)); ]
);
} catch (\Exception $e) { } catch (\Exception $e) {
} }

View File

@ -17,9 +17,11 @@ class PersistentObjectTest extends OrmFunctionalTestCase
{ {
parent::setUp(); parent::setUp();
try { try {
$this->_schemaTool->createSchema(array( $this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\PersistentEntity'), $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\PersistentEntity'),
)); ]
);
} catch (\Exception $e) { } catch (\Exception $e) {
} }

View File

@ -46,7 +46,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase
$eventManager = $this->_em->getEventManager(); $eventManager = $this->_em->getEventManager();
$eventManager->addEventListener(array(Events::postLoad), $mockListener); $eventManager->addEventListener([Events::postLoad], $mockListener);
$this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId);
} }
@ -63,7 +63,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase
$eventManager = $this->_em->getEventManager(); $eventManager = $this->_em->getEventManager();
$eventManager->addEventListener(array(Events::postLoad), $mockListener); $eventManager->addEventListener([Events::postLoad], $mockListener);
$query = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :id'); $query = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = :id');
@ -83,7 +83,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase
$eventManager = $this->_em->getEventManager(); $eventManager = $this->_em->getEventManager();
$eventManager->addEventListener(array(Events::postLoad), $mockListener); $eventManager->addEventListener([Events::postLoad], $mockListener);
$query = $this->_em->createQuery('SELECT u, e FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.email e WHERE u.id = :id'); $query = $this->_em->createQuery('SELECT u, e FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.email e WHERE u.id = :id');
@ -103,7 +103,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase
$eventManager = $this->_em->getEventManager(); $eventManager = $this->_em->getEventManager();
$eventManager->addEventListener(array(Events::postLoad), $mockListener); $eventManager->addEventListener([Events::postLoad], $mockListener);
$query = $this->_em->createQuery('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.phonenumbers p WHERE u.id = :id'); $query = $this->_em->createQuery('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.phonenumbers p WHERE u.id = :id');
@ -123,12 +123,12 @@ class PostLoadEventTest extends OrmFunctionalTestCase
->method('postLoad') ->method('postLoad')
->will($this->returnValue(true)); ->will($this->returnValue(true));
$eventManager->addEventListener(array(Events::postLoad), $mockListener); $eventManager->addEventListener([Events::postLoad], $mockListener);
$userProxy = $this->_em->getReference('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $userProxy = $this->_em->getReference('Doctrine\Tests\Models\CMS\CmsUser', $this->userId);
// Now deactivate original listener and attach new one // Now deactivate original listener and attach new one
$eventManager->removeEventListener(array(Events::postLoad), $mockListener); $eventManager->removeEventListener([Events::postLoad], $mockListener);
$mockListener2 = $this->createMock(PostLoadListener::class); $mockListener2 = $this->createMock(PostLoadListener::class);
@ -137,7 +137,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase
->method('postLoad') ->method('postLoad')
->will($this->returnValue(true)); ->will($this->returnValue(true));
$eventManager->addEventListener(array(Events::postLoad), $mockListener2); $eventManager->addEventListener([Events::postLoad], $mockListener2);
$userProxy->getName(); $userProxy->getName();
} }
@ -155,7 +155,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase
->method('postLoad') ->method('postLoad')
->will($this->returnValue(true)); ->will($this->returnValue(true));
$eventManager->addEventListener(array(Events::postLoad), $mockListener); $eventManager->addEventListener([Events::postLoad], $mockListener);
$query = $this->_em->createQuery('SELECT PARTIAL u.{id, name}, p FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.phonenumbers p WHERE u.id = :id'); $query = $this->_em->createQuery('SELECT PARTIAL u.{id, name}, p FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.phonenumbers p WHERE u.id = :id');
@ -177,7 +177,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase
$eventManager = $this->_em->getEventManager(); $eventManager = $this->_em->getEventManager();
$eventManager->addEventListener(array(Events::postLoad), $mockListener); $eventManager->addEventListener([Events::postLoad], $mockListener);
$emailProxy = $user->getEmail(); $emailProxy = $user->getEmail();
@ -198,7 +198,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase
$eventManager = $this->_em->getEventManager(); $eventManager = $this->_em->getEventManager();
$eventManager->addEventListener(array(Events::postLoad), $mockListener); $eventManager->addEventListener([Events::postLoad], $mockListener);
$phonenumbersCol = $user->getPhonenumbers(); $phonenumbersCol = $user->getPhonenumbers();
@ -211,7 +211,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase
public function testAssociationsArePopulatedWhenEventIsFired() public function testAssociationsArePopulatedWhenEventIsFired()
{ {
$checkerListener = new PostLoadListenerCheckAssociationsArePopulated(); $checkerListener = new PostLoadListenerCheckAssociationsArePopulated();
$this->_em->getEventManager()->addEventListener(array(Events::postLoad), $checkerListener); $this->_em->getEventManager()->addEventListener([Events::postLoad], $checkerListener);
$qb = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser')->createQueryBuilder('u'); $qb = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser')->createQueryBuilder('u');
$qb->leftJoin('u.email', 'email'); $qb->leftJoin('u.email', 'email');
@ -229,7 +229,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase
{ {
$eventManager = $this->_em->getEventManager(); $eventManager = $this->_em->getEventManager();
$listener = new PostLoadListenerLoadEntityInEventHandler(); $listener = new PostLoadListenerLoadEntityInEventHandler();
$eventManager->addEventListener(array(Events::postLoad), $listener); $eventManager->addEventListener([Events::postLoad], $listener);
$this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId); $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId);
$this->assertSame(1, $listener->countHandledEvents('Doctrine\Tests\Models\CMS\CmsUser'), 'Doctrine\Tests\Models\CMS\CmsUser should be handled once!'); $this->assertSame(1, $listener->countHandledEvents('Doctrine\Tests\Models\CMS\CmsUser'), 'Doctrine\Tests\Models\CMS\CmsUser should be handled once!');
@ -303,7 +303,7 @@ class PostLoadListenerCheckAssociationsArePopulated
class PostLoadListenerLoadEntityInEventHandler class PostLoadListenerLoadEntityInEventHandler
{ {
private $firedByClasses = array(); private $firedByClasses = [];
public function postLoad(LifecycleEventArgs $event) public function postLoad(LifecycleEventArgs $event)
{ {

View File

@ -24,14 +24,16 @@ class ProxiesLikeEntitiesTest extends OrmFunctionalTestCase
{ {
parent::setUp(); parent::setUp();
try { try {
$this->_schemaTool->createSchema(array( $this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'), $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'),
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber'), $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber'),
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsArticle'), $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsArticle'),
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'), $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'),
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsEmail'), $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsEmail'),
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsGroup'), $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsGroup'),
)); ]
);
} catch (\Exception $e) { } catch (\Exception $e) {
} }
$this->user = new CmsUser(); $this->user = new CmsUser();
@ -48,7 +50,7 @@ class ProxiesLikeEntitiesTest extends OrmFunctionalTestCase
public function testPersistUpdate() public function testPersistUpdate()
{ {
// Considering case (a) // Considering case (a)
$proxy = $this->_em->getProxyFactory()->getProxy('Doctrine\Tests\Models\CMS\CmsUser', array('id' => 123)); $proxy = $this->_em->getProxyFactory()->getProxy('Doctrine\Tests\Models\CMS\CmsUser', ['id' => 123]);
$proxy->__isInitialized__ = true; $proxy->__isInitialized__ = true;
$proxy->id = null; $proxy->id = null;
$proxy->username = 'ocra'; $proxy->username = 'ocra';
@ -87,7 +89,8 @@ class ProxiesLikeEntitiesTest extends OrmFunctionalTestCase
*/ */
public function testProxyAsDqlParameterPersist() public function testProxyAsDqlParameterPersist()
{ {
$proxy = $this->_em->getProxyFactory()->getProxy('Doctrine\Tests\Models\CMS\CmsUser', array('id' => $this->user->getId())); $proxy = $this->_em->getProxyFactory()->getProxy('Doctrine\Tests\Models\CMS\CmsUser', ['id' => $this->user->getId()]
);
$proxy->id = $this->user->getId(); $proxy->id = $this->user->getId();
$result = $this $result = $this
->_em ->_em
@ -117,7 +120,7 @@ class ProxiesLikeEntitiesTest extends OrmFunctionalTestCase
$result = $this $result = $this
->_em ->_em
->getRepository('Doctrine\Tests\Proxies\__CG__\Doctrine\Tests\Models\CMS\CmsUser') ->getRepository('Doctrine\Tests\Proxies\__CG__\Doctrine\Tests\Models\CMS\CmsUser')
->findOneBy(array('username' => $this->user->username)); ->findOneBy(['username' => $this->user->username]);
$this->assertSame($this->user->getId(), $result->getId()); $this->assertSame($this->user->getId(), $result->getId());
$this->_em->clear(); $this->_em->clear();
$result = $this $result = $this

View File

@ -128,7 +128,7 @@ class QueryCacheTest extends OrmFunctionalTestCase
$query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux'); $query = $this->_em->createQuery('select ux from Doctrine\Tests\Models\CMS\CmsUser ux');
$sqlExecMock = $this->getMockBuilder(AbstractSqlExecutor::class) $sqlExecMock = $this->getMockBuilder(AbstractSqlExecutor::class)
->setMethods(array('execute')) ->setMethods(['execute'])
->getMock(); ->getMock();
$sqlExecMock->expects($this->once()) $sqlExecMock->expects($this->once())
@ -136,14 +136,14 @@ class QueryCacheTest extends OrmFunctionalTestCase
->will($this->returnValue( 10 )); ->will($this->returnValue( 10 ));
$parserResultMock = $this->getMockBuilder(ParserResult::class) $parserResultMock = $this->getMockBuilder(ParserResult::class)
->setMethods(array('getSqlExecutor')) ->setMethods(['getSqlExecutor'])
->getMock(); ->getMock();
$parserResultMock->expects($this->once()) $parserResultMock->expects($this->once())
->method('getSqlExecutor') ->method('getSqlExecutor')
->will($this->returnValue($sqlExecMock)); ->will($this->returnValue($sqlExecMock));
$cache = $this->getMockBuilder(CacheProvider::class) $cache = $this->getMockBuilder(CacheProvider::class)
->setMethods(array('doFetch', 'doContains', 'doSave', 'doDelete', 'doFlush', 'doGetStats')) ->setMethods(['doFetch', 'doContains', 'doSave', 'doDelete', 'doFlush', 'doGetStats'])
->getMock(); ->getMock();
$cache->expects($this->at(0))->method('doFetch')->will($this->returnValue(1)); $cache->expects($this->at(0))->method('doFetch')->will($this->returnValue(1));

Some files were not shown because too many files have changed in this diff Show More