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

View File

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

View File

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

View File

@ -26,12 +26,12 @@ class ConnectionMock extends Connection
/**
* @var array
*/
private $_inserts = array();
private $_inserts = [];
/**
* @var array
*/
private $_executeUpdates = array();
private $_executeUpdates = [];
/**
* @param array $params
@ -60,7 +60,7 @@ class ConnectionMock extends Connection
/**
* {@inheritdoc}
*/
public function insert($tableName, array $data, array $types = array())
public function insert($tableName, array $data, array $types = [])
{
$this->_inserts[$tableName][] = $data;
}
@ -68,9 +68,9 @@ class ConnectionMock extends Connection
/**
* {@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}
*/
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;
}
@ -153,7 +153,7 @@ class ConnectionMock extends Connection
*/
public function reset()
{
$this->_inserts = array();
$this->_inserts = [];
$this->_lastInsertId = 0;
}
}

View File

@ -25,7 +25,7 @@ class DriverMock implements Driver
/**
* {@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();
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -14,6 +14,6 @@ class TimestampRegionMock extends CacheRegionMock implements TimestampRegion
{
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
*/
private $_mockDataChangeSets = array();
private $_mockDataChangeSets = [];
/**
* @var array|null

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -44,13 +44,17 @@ class DDC1476EntityWithDefaultFieldType
public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
{
$metadata->mapField(array(
$metadata->mapField(
[
'id' => true,
'fieldName' => 'id',
));
$metadata->mapField(array(
]
);
$metadata->mapField(
[
'fieldName' => 'name',
));
]
);
$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"})
*/
public $articles = array();
public $articles = [];
}

View File

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

View File

@ -81,27 +81,33 @@ class DDC3579User
public static function loadMetadata($metadata)
{
$metadata->mapField(array(
$metadata->mapField(
[
'id' => true,
'fieldName' => 'id',
'type' => 'integer',
'columnName' => 'user_id',
'length' => 150,
));
]
);
$metadata->mapField(array(
$metadata->mapField(
[
'fieldName' => 'name',
'type' => 'string',
'columnName'=> 'user_name',
'nullable' => true,
'unique' => false,
'length' => 250,
));
]
);
$metadata->mapManyToMany(array(
$metadata->mapManyToMany(
[
'fieldName' => 'groups',
'targetEntity' => 'DDC3579Group'
));
]
);
$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)
{
$metadata->mapField(array(
$metadata->mapField(
[
'fieldName' => 'serialNumber',
'type' => 'string',
));
]
);
}
}

View File

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

View File

@ -21,16 +21,20 @@ class DDC869Payment
public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata)
{
$metadata->mapField(array(
$metadata->mapField(
[
'id' => true,
'fieldName' => 'id',
'type' => 'integer',
'columnName' => 'id',
));
$metadata->mapField(array(
]
);
$metadata->mapField(
[
'fieldName' => 'value',
'type' => 'float',
));
]
);
$metadata->isMappedSuperclass = true;
$metadata->setCustomRepositoryClass("Doctrine\Tests\Models\DDC869\DDC869PaymentRepository");
$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)
{
$metadata->mapField(array(
$metadata->mapField(
[
'id' => true,
'fieldName' => 'id',
'type' => 'integer',
'columnName' => 'id',
));
]
);
$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)
{
$metadata->mapField(array(
$metadata->mapField(
[
'fieldName' => 'name',
));
]
);
$metadata->isMappedSuperclass = true;
$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)
{
$metadata->setAssociationOverride('address',array(
'joinColumns'=>array(array(
$metadata->setAssociationOverride('address',
[
'joinColumns'=> [
[
'name' => 'adminaddress_id',
'referencedColumnName' => 'id',
))
));
]
]
]
);
$metadata->setAssociationOverride('groups',array(
'joinTable' => array(
$metadata->setAssociationOverride('groups',
[
'joinTable' => [
'name' => 'ddc964_users_admingroups',
'joinColumns' => array(array(
'joinColumns' => [
[
'name' => 'adminuser_id',
)),
'inverseJoinColumns' =>array (array (
]
],
'inverseJoinColumns' => [[
'name' => 'admingroup_id',
))
)
));
]]
]
]
);
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -42,13 +42,13 @@ class CacheLoggerChainTest extends DoctrineTestCase
$this->logger->setLogger('mock', $this->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()
{
$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);
@ -72,7 +72,7 @@ class CacheLoggerChainTest extends DoctrineTestCase
public function testCollectionCacheChain()
{
$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);
@ -116,4 +116,4 @@ class CacheLoggerChainTest extends DoctrineTestCase
$this->logger->queryCachePut($name, $key);
$this->logger->queryCacheMiss($name, $key);
}
}
}

View File

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

View File

@ -72,7 +72,7 @@ class DefaultCacheTest extends OrmTestCase
{
$this->assertInstanceOf('Doctrine\ORM\Cache', $this->cache);
}
public function testGetEntityCacheRegionAccess()
{
$this->assertInstanceOf('Doctrine\ORM\Cache\Region', $this->cache->getEntityCacheRegion(State::CLASSNAME));
@ -87,9 +87,9 @@ class DefaultCacheTest extends OrmTestCase
public function testContainsEntity()
{
$identifier = array('id'=>1);
$identifier = ['id'=>1];
$className = Country::CLASSNAME;
$cacheEntry = array_merge($identifier, array('name' => 'Brazil'));
$cacheEntry = array_merge($identifier, ['name' => 'Brazil']);
$this->assertFalse($this->cache->containsEntity(Country::CLASSNAME, 1));
@ -101,9 +101,9 @@ class DefaultCacheTest extends OrmTestCase
public function testEvictEntity()
{
$identifier = array('id'=>1);
$identifier = ['id'=>1];
$className = Country::CLASSNAME;
$cacheEntry = array_merge($identifier, array('name' => 'Brazil'));
$cacheEntry = array_merge($identifier, ['name' => 'Brazil']);
$this->putEntityCacheEntry($className, $identifier, $cacheEntry);
@ -117,9 +117,9 @@ class DefaultCacheTest extends OrmTestCase
public function testEvictEntityRegion()
{
$identifier = array('id'=>1);
$identifier = ['id'=>1];
$className = Country::CLASSNAME;
$cacheEntry = array_merge($identifier, array('name' => 'Brazil'));
$cacheEntry = array_merge($identifier, ['name' => 'Brazil']);
$this->putEntityCacheEntry($className, $identifier, $cacheEntry);
@ -133,9 +133,9 @@ class DefaultCacheTest extends OrmTestCase
public function testEvictEntityRegions()
{
$identifier = array('id'=>1);
$identifier = ['id'=>1];
$className = Country::CLASSNAME;
$cacheEntry = array_merge($identifier, array('name' => 'Brazil'));
$cacheEntry = array_merge($identifier, ['name' => 'Brazil']);
$this->putEntityCacheEntry($className, $identifier, $cacheEntry);
@ -148,13 +148,13 @@ class DefaultCacheTest extends OrmTestCase
public function testContainsCollection()
{
$ownerId = array('id'=>1);
$ownerId = ['id'=>1];
$className = State::CLASSNAME;
$association = 'cities';
$cacheEntry = array(
array('id' => 11),
array('id' => 12),
);
$cacheEntry = [
['id' => 11],
['id' => 12],
];
$this->assertFalse($this->cache->containsCollection(State::CLASSNAME, $association, 1));
@ -166,13 +166,13 @@ class DefaultCacheTest extends OrmTestCase
public function testEvictCollection()
{
$ownerId = array('id'=>1);
$ownerId = ['id'=>1];
$className = State::CLASSNAME;
$association = 'cities';
$cacheEntry = array(
array('id' => 11),
array('id' => 12),
);
$cacheEntry = [
['id' => 11],
['id' => 12],
];
$this->putCollectionCacheEntry($className, $association, $ownerId, $cacheEntry);
@ -186,13 +186,13 @@ class DefaultCacheTest extends OrmTestCase
public function testEvictCollectionRegion()
{
$ownerId = array('id'=>1);
$ownerId = ['id'=>1];
$className = State::CLASSNAME;
$association = 'cities';
$cacheEntry = array(
array('id' => 11),
array('id' => 12),
);
$cacheEntry = [
['id' => 11],
['id' => 12],
];
$this->putCollectionCacheEntry($className, $association, $ownerId, $cacheEntry);
@ -206,13 +206,13 @@ class DefaultCacheTest extends OrmTestCase
public function testEvictCollectionRegions()
{
$ownerId = array('id'=>1);
$ownerId = ['id'=>1];
$className = State::CLASSNAME;
$association = 'cities';
$cacheEntry = array(
array('id' => 11),
array('id' => 12),
);
$cacheEntry = [
['id' => 11],
['id' => 12],
];
$this->putCollectionCacheEntry($className, $association, $ownerId, $cacheEntry);
@ -257,7 +257,7 @@ class DefaultCacheTest extends OrmTestCase
$method->setAccessible(true);
$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()
{
$targetRegion = $this->_em->getCache()->getEntityCacheRegion(City::CLASSNAME);
$entry = new CollectionCacheEntry(array(
new EntityCacheKey(City::CLASSNAME, array('id'=>31)),
new EntityCacheKey(City::CLASSNAME, array('id'=>32)),
));
$entry = new CollectionCacheEntry(
[
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, array('id'=>32)), new EntityCacheEntry(City::CLASSNAME, array('id'=>32, 'name'=>'Bar')));
$targetRegion->put(new EntityCacheKey(City::CLASSNAME, ['id'=>31]), new EntityCacheEntry(City::CLASSNAME, ['id'=>31, 'name'=>'Foo']
));
$targetRegion->put(new EntityCacheKey(City::CLASSNAME, ['id'=>32]), new EntityCacheEntry(City::CLASSNAME, ['id'=>32, 'name'=>'Bar']
));
$sourceClass = $this->_em->getClassMetadata(State::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());
$list = $this->structure->loadCacheEntry($sourceClass, $key, $entry, $collection);
@ -75,4 +79,4 @@ class DefaultCollectionHydratorTest extends OrmFunctionalTestCase
$this->assertEquals(UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($collection[1]));
}
}
}

View File

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

View File

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

View File

@ -33,7 +33,7 @@ class DefaultRegionTest extends AbstractRegionTest
}
$key = new CacheKeyMock('key');
$entry = new CacheEntryMock(array('value' => 'foo'));
$entry = new CacheEntryMock(['value' => 'foo']);
$region1 = new DefaultRegion('region1', new ApcCache());
$region2 = new DefaultRegion('region2', new ApcCache());
@ -79,10 +79,10 @@ class DefaultRegionTest extends AbstractRegionTest
public function testGetMulti()
{
$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');
$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($key2));
@ -93,9 +93,9 @@ class DefaultRegionTest extends AbstractRegionTest
$this->assertTrue($this->region->contains($key1));
$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($value2, $actual[1]);
}
}
}

View File

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

View File

@ -20,10 +20,10 @@ class MultiGetRegionTest extends AbstractRegionTest
public function testGetMulti()
{
$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');
$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($key2));
@ -34,7 +34,7 @@ class MultiGetRegionTest extends AbstractRegionTest
$this->assertTrue($this->region->contains($key1));
$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($value2, $actual[1]);

View File

@ -35,7 +35,7 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase
/**
* @var array
*/
protected $regionMockMethods = array(
protected $regionMockMethods = [
'getName',
'contains',
'get',
@ -43,12 +43,12 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase
'put',
'evict',
'evictAll'
);
];
/**
* @var array
*/
protected $collectionPersisterMockMethods = array(
protected $collectionPersisterMockMethods = [
'delete',
'update',
'count',
@ -60,7 +60,7 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase
'get',
'getMultiple',
'loadCriteria'
);
];
/**
* @param \Doctrine\ORM\EntityManager $em
@ -133,7 +133,7 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase
$persister = $this->createPersisterDefault();
$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())
->method('delete')
@ -150,7 +150,7 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase
$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())
->method('update')
@ -165,7 +165,7 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase
$persister = $this->createPersisterDefault();
$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())
->method('count')
@ -182,7 +182,7 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase
$collection = $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())
->method('slice')
@ -199,7 +199,7 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase
$persister = $this->createPersisterDefault();
$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())
->method('contains')
@ -215,7 +215,7 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase
$persister = $this->createPersisterDefault();
$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())
->method('containsKey')
@ -232,7 +232,7 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase
$persister = $this->createPersisterDefault();
$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())
->method('removeElement')
@ -249,7 +249,7 @@ abstract class AbstractCollectionPersisterTest extends OrmTestCase
$persister = $this->createPersisterDefault();
$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())
->method('get')

View File

@ -16,7 +16,7 @@ use Doctrine\ORM\Cache\Persister\Collection\ReadWriteCachedCollectionPersister;
*/
class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersisterTest
{
protected $regionMockMethods = array(
protected $regionMockMethods = [
'getName',
'contains',
'get',
@ -26,7 +26,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
'evictAll',
'lock',
'unlock',
);
];
/**
* {@inheritdoc}
@ -52,14 +52,14 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$lock = Lock::createLockRead();
$persister = $this->createPersisterDefault();
$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())
->method('lock')
->with($this->equalTo($key))
->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);
}
@ -70,14 +70,14 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$lock = Lock::createLockRead();
$persister = $this->createPersisterDefault();
$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())
->method('lock')
->with($this->equalTo($key))
->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);
}
@ -88,7 +88,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$lock = Lock::createLockRead();
$persister = $this->createPersisterDefault();
$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())
->method('lock')
@ -100,7 +100,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
->with($this->equalTo($key))
->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->afterTransactionRolledBack();
@ -112,7 +112,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$lock = Lock::createLockRead();
$persister = $this->createPersisterDefault();
$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())
->method('lock')
@ -123,7 +123,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
->method('evict')
->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->afterTransactionRolledBack();
@ -135,7 +135,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$lock = Lock::createLockRead();
$persister = $this->createPersisterDefault();
$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->setAccessible(true);
@ -149,7 +149,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
->method('evict')
->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);
@ -166,7 +166,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$lock = Lock::createLockRead();
$persister = $this->createPersisterDefault();
$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->setAccessible(true);
@ -180,7 +180,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
->method('evict')
->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);
@ -197,7 +197,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$lock = Lock::createLockRead();
$persister = $this->createPersisterDefault();
$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->setAccessible(true);
@ -211,7 +211,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
->method('evict')
->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);
@ -228,7 +228,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$lock = Lock::createLockRead();
$persister = $this->createPersisterDefault();
$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->setAccessible(true);
@ -242,7 +242,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
->method('evict')
->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);
@ -258,7 +258,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$entity = new State("Foo");
$persister = $this->createPersisterDefault();
$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->setAccessible(true);
@ -272,7 +272,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
->method('delete')
->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);
$this->assertCount(0, $property->getValue($persister));
@ -283,7 +283,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
$entity = new State("Foo");
$persister = $this->createPersisterDefault();
$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->setAccessible(true);
@ -297,7 +297,7 @@ class ReadWriteCachedCollectionPersisterTest extends AbstractCollectionPersister
->method('update')
->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);
$this->assertCount(0, $property->getValue($persister));

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -75,7 +75,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
public function testNewDefaultAnnotationDriver()
{
$paths = array(__DIR__);
$paths = [__DIR__];
$reflectionClass = new ReflectionClass(__NAMESPACE__ . '\ConfigurationTestAnnotationReaderChecker');
$annotationDriver = $this->configuration->newDefaultAnnotationDriver($paths, false);
@ -99,7 +99,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
{
$this->configuration->addEntityNamespace('TestNamespace', __NAMESPACE__);
$this->assertSame(__NAMESPACE__, $this->configuration->getEntityNamespace('TestNamespace'));
$namespaces = array('OtherNamespace' => __NAMESPACE__);
$namespaces = ['OtherNamespace' => __NAMESPACE__];
$this->configuration->setEntityNamespaces($namespaces);
$this->assertSame($namespaces, $this->configuration->getEntityNamespaces());
$this->expectException(\Doctrine\ORM\ORMException::class);
@ -259,7 +259,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
$this->configuration->addCustomStringFunction('FunctionName', __CLASS__);
$this->assertSame(__CLASS__, $this->configuration->getCustomStringFunction('FunctionName'));
$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->expectException(\Doctrine\ORM\ORMException::class);
$this->configuration->addCustomStringFunction('concat', __CLASS__);
@ -270,7 +270,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
$this->configuration->addCustomNumericFunction('FunctionName', __CLASS__);
$this->assertSame(__CLASS__, $this->configuration->getCustomNumericFunction('FunctionName'));
$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->expectException(\Doctrine\ORM\ORMException::class);
$this->configuration->addCustomNumericFunction('abs', __CLASS__);
@ -281,7 +281,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
$this->configuration->addCustomDatetimeFunction('FunctionName', __CLASS__);
$this->assertSame(__CLASS__, $this->configuration->getCustomDatetimeFunction('FunctionName'));
$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->expectException(\Doctrine\ORM\ORMException::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->configuration->setCustomHydrationModes(
array(
[
'AnotherHydrationModeName' => __CLASS__
)
]
);
$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->decorator = $this->getMockBuilder('Doctrine\ORM\Decorator\EntityManagerDecorator')
->setConstructorArgs(array($this->wrapped))
->setConstructorArgs([$this->wrapped])
->setMethods(null)
->getMock();
}
@ -23,7 +23,7 @@ class EntityManagerDecoratorTest extends \PHPUnit_Framework_TestCase
{
$class = new \ReflectionClass('Doctrine\ORM\EntityManager');
$methods = array();
$methods = [];
foreach ($class->getMethods() as $method) {
if ($method->isConstructor() || $method->isStatic() || !$method->isPublic()) {
continue;
@ -31,17 +31,17 @@ class EntityManagerDecoratorTest extends \PHPUnit_Framework_TestCase
/** Special case EntityManager::createNativeQuery() */
if ($method->getName() === 'createNativeQuery') {
$methods[] = array($method->getName(), array('name', new ResultSetMapping()));
$methods[] = [$method->getName(), ['name', new ResultSetMapping()]];
continue;
}
if ($method->getNumberOfRequiredParameters() === 0) {
$methods[] = array($method->getName(), array());
$methods[] = [$method->getName(), []];
} 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()) {
$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)
->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()
{
return array(
array('persist'),
array('remove'),
array('merge'),
array('refresh'),
array('detach')
);
return [
['persist'],
['remove'],
['merge'],
['refresh'],
['detach']
];
}
/**
@ -160,13 +160,13 @@ class EntityManagerTest extends OrmTestCase
static public function dataAffectedByErrorIfClosedException()
{
return array(
array('flush'),
array('persist'),
array('remove'),
array('merge'),
array('refresh'),
);
return [
['flush'],
['persist'],
['remove'],
['merge'],
['refresh'],
];
}
/**
@ -196,7 +196,7 @@ class EntityManagerTest extends OrmTestCase
public function testTransactionalAcceptsVariousCallables()
{
$this->assertSame('callback', $this->_em->transactional(array($this, 'transactionalCallback')));
$this->assertSame('callback', $this->_em->transactional([$this, 'transactionalCallback']));
}
public function testTransactionalThrowsInvalidArgumentExceptionIfNonCallablePassed()

View File

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

View File

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

View File

@ -16,13 +16,15 @@ class AdvancedAssociationTest extends OrmFunctionalTestCase
protected function setUp() {
parent::setUp();
try {
$this->_schemaTool->createSchema(array(
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Phrase'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\PhraseType'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Definition'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Lemma'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Type')
));
]
);
} catch (\Exception $e) {
// 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
$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();
$this->assertTrue(is_numeric($userId));
@ -1075,11 +1075,11 @@ class BasicFunctionalTest extends OrmFunctionalTestCase
$this->_em->persist($userB);
$this->_em->persist($userC);
$this->_em->flush(array($userA, $userB, $userB));
$this->_em->flush([$userA, $userB, $userB]);
$userC->name = 'changed name';
$this->_em->flush(array($userA, $userB));
$this->_em->flush([$userA, $userB]);
$this->_em->refresh($userC);
$this->assertTrue($userA->id > 0, 'user a has an id');

View File

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

View File

@ -72,7 +72,7 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
$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->assertEquals('Guilherme Blanco', $guilherme->getName());
@ -389,12 +389,12 @@ class ClassTableInheritanceTest extends OrmFunctionalTestCase
$this->_em->clear();
$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());
$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());
}

View File

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

View File

@ -30,7 +30,7 @@ class CompositePrimaryKeyTest extends OrmFunctionalTestCase
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->addPointOfInterest($poi);
@ -46,7 +46,7 @@ class CompositePrimaryKeyTest extends OrmFunctionalTestCase
{
$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->assertEquals(100, $poi->getLat());
@ -61,7 +61,7 @@ class CompositePrimaryKeyTest extends OrmFunctionalTestCase
{
$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");
$this->_em->persist($photo);
$this->_em->flush();
@ -79,7 +79,7 @@ class CompositePrimaryKeyTest extends OrmFunctionalTestCase
{
$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");
$this->_em->persist($photo);
$this->_em->flush();
@ -140,7 +140,7 @@ class CompositePrimaryKeyTest extends OrmFunctionalTestCase
$this->expectException(ORMException::class);
$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()
@ -148,7 +148,8 @@ class CompositePrimaryKeyTest extends OrmFunctionalTestCase
$this->expectException(ORMException::class);
$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();
$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("test2"));
@ -169,7 +170,7 @@ class CompositePrimaryKeyTest extends OrmFunctionalTestCase
$this->_em->flush();
$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()));
}
}

View File

@ -44,13 +44,13 @@ class CompositePrimaryKeyWithAssociationsTest extends OrmFunctionalTestCase
$admin1Repo = $this->_em->getRepository('Doctrine\Tests\Models\GeoNames\Admin1');
$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);
$name1 = $admin1NamesRepo->findOneBy(array('admin1' => $admin1Rome, 'id' => 1));
$name2 = $admin1NamesRepo->findOneBy(array('admin1' => $admin1Rome, 'id' => 2));
$name1 = $admin1NamesRepo->findOneBy(['admin1' => $admin1Rome, 'id' => 1]);
$name2 = $admin1NamesRepo->findOneBy(['admin1' => $admin1Rome, 'id' => 2]);
$this->assertEquals(1, $name1->id);
$this->assertEquals("Roma", $name1->name);

View File

@ -33,15 +33,15 @@ class DatabaseDriverTest extends DatabaseDriverTestCase
$user = new Table("ddc2059_user");
$user->addColumn('id', 'integer');
$user->setPrimaryKey(array('id'));
$user->setPrimaryKey(['id']);
$project = new Table("ddc2059_project");
$project->addColumn('id', 'integer');
$project->addColumn('user_id', 'integer');
$project->addColumn('user', 'string');
$project->setPrimaryKey(array('id'));
$project->addForeignKeyConstraint('ddc2059_user', array('user_id'), array('id'));
$project->setPrimaryKey(['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']->associationMappings['user2']));
@ -55,12 +55,12 @@ class DatabaseDriverTest extends DatabaseDriverTestCase
$table = new Table("dbdriver_foo");
$table->addColumn('id', 'integer');
$table->setPrimaryKey(array('id'));
$table->addColumn('bar', 'string', array('notnull' => false, 'length' => 200));
$table->setPrimaryKey(['id']);
$table->addColumn('bar', 'string', ['notnull' => false, 'length' => 200]);
$this->_sm->dropAndCreateTable($table);
$metadatas = $this->extractClassMetadata(array("DbdriverFoo"));
$metadatas = $this->extractClassMetadata(["DbdriverFoo"]);
$this->assertArrayHasKey('DbdriverFoo', $metadatas);
$metadata = $metadatas['DbdriverFoo'];
@ -86,19 +86,19 @@ class DatabaseDriverTest extends DatabaseDriverTestCase
$tableB = new Table("dbdriver_bar");
$tableB->addColumn('id', 'integer');
$tableB->setPrimaryKey(array('id'));
$tableB->setPrimaryKey(['id']);
$this->_sm->dropAndCreateTable($tableB);
$tableA = new Table("dbdriver_baz");
$tableA->addColumn('id', 'integer');
$tableA->setPrimaryKey(array('id'));
$tableA->setPrimaryKey(['id']);
$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);
$metadatas = $this->extractClassMetadata(array("DbdriverBar", "DbdriverBaz"));
$metadatas = $this->extractClassMetadata(["DbdriverBar", "DbdriverBaz"]);
$this->assertArrayHasKey('DbdriverBaz', $metadatas);
$bazMetadata = $metadatas['DbdriverBaz'];
@ -118,7 +118,7 @@ class DatabaseDriverTest extends DatabaseDriverTestCase
$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('CmsGroups', $metadatas, 'CmsGroups entity was not detected.');
@ -136,18 +136,18 @@ class DatabaseDriverTest extends DatabaseDriverTestCase
{
$tableB = new Table("dbdriver_bar");
$tableB->addColumn('id', 'integer');
$tableB->setPrimaryKey(array('id'));
$tableB->setPrimaryKey(['id']);
$tableA = new Table("dbdriver_baz");
$tableA->addColumn('id', 'integer');
$tableA->setPrimaryKey(array('id'));
$tableA->setPrimaryKey(['id']);
$tableMany = new Table("dbdriver_bar_baz");
$tableMany->addColumn('bar_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.");
}
@ -160,24 +160,24 @@ class DatabaseDriverTest extends DatabaseDriverTestCase
$table = new Table("dbdriver_foo");
$table->addColumn('id', 'integer', array('unsigned' => true));
$table->setPrimaryKey(array('id'));
$table->addColumn('column_unsigned', 'integer', array('unsigned' => true));
$table->addColumn('column_comment', 'string', array('comment' => 'test_comment'));
$table->addColumn('column_default', 'string', array('default' => 'test_default'));
$table->addColumn('column_decimal', 'decimal', array('precision' => 4, 'scale' => 3));
$table->addColumn('id', 'integer', ['unsigned' => true]);
$table->setPrimaryKey(['id']);
$table->addColumn('column_unsigned', 'integer', ['unsigned' => true]);
$table->addColumn('column_comment', 'string', ['comment' => 'test_comment']);
$table->addColumn('column_default', 'string', ['default' => 'test_default']);
$table->addColumn('column_decimal', 'decimal', ['precision' => 4, 'scale' => 3]);
$table->addColumn('column_index1', '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_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);
$metadatas = $this->extractClassMetadata(array("DbdriverFoo"));
$metadatas = $this->extractClassMetadata(["DbdriverFoo"]);
$this->assertArrayHasKey('DbdriverFoo', $metadatas);
@ -208,13 +208,13 @@ class DatabaseDriverTest extends DatabaseDriverTestCase
$this->assertTrue( ! empty($metadata->table['indexes']['index1']['columns']));
$this->assertEquals(
array('column_index1','column_index2'),
['column_index1','column_index2'],
$metadata->table['indexes']['index1']['columns']
);
$this->assertTrue( ! empty($metadata->table['uniqueConstraints']['unique_index1']['columns']));
$this->assertEquals(
array('column_unique_index1', 'column_unique_index2'),
['column_unique_index1', 'column_unique_index2'],
$metadata->table['uniqueConstraints']['unique_index1']['columns']
);
}

View File

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

View File

@ -14,10 +14,12 @@ class DefaultValuesTest extends OrmFunctionalTestCase
{
parent::setUp();
try {
$this->_schemaTool->createSchema(array(
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\DefaultValueUser'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\DefaultValueAddress')
));
]
);
} catch (\Exception $e) {
// 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->setFixPrice(2000);
$this->listener->preFlushCalls = array();
$this->listener->preFlushCalls = [];
$this->_em->persist($fix);
$this->_em->flush();
@ -55,12 +55,12 @@ class EntityListenersTest extends OrmFunctionalTestCase
{
$fix = new CompanyFixContract();
$fix->setFixPrice(2000);
$this->_em->persist($fix);
$this->_em->flush();
$this->_em->clear();
$this->listener->postLoadCalls = array();
$this->listener->postLoadCalls = [];
$dql = "SELECT f FROM Doctrine\Tests\Models\Company\CompanyFixContract f WHERE f.id = ?1";
$fix = $this->_em->createQuery($dql)->setParameter(1, $fix->getId())->getSingleResult();
@ -85,7 +85,7 @@ class EntityListenersTest extends OrmFunctionalTestCase
$fix = new CompanyFixContract();
$fix->setFixPrice(2000);
$this->listener->prePersistCalls = array();
$this->listener->prePersistCalls = [];
$this->_em->persist($fix);
$this->_em->flush();
@ -110,7 +110,7 @@ class EntityListenersTest extends OrmFunctionalTestCase
$fix = new CompanyFixContract();
$fix->setFixPrice(2000);
$this->listener->postPersistCalls = array();
$this->listener->postPersistCalls = [];
$this->_em->persist($fix);
$this->_em->flush();
@ -138,8 +138,8 @@ class EntityListenersTest extends OrmFunctionalTestCase
$this->_em->persist($fix);
$this->_em->flush();
$this->listener->preUpdateCalls = array();
$this->listener->preUpdateCalls = [];
$fix->setFixPrice(2000);
$this->_em->persist($fix);
@ -168,7 +168,7 @@ class EntityListenersTest extends OrmFunctionalTestCase
$this->_em->persist($fix);
$this->_em->flush();
$this->listener->postUpdateCalls = array();
$this->listener->postUpdateCalls = [];
$fix->setFixPrice(2000);
@ -198,7 +198,7 @@ class EntityListenersTest extends OrmFunctionalTestCase
$this->_em->persist($fix);
$this->_em->flush();
$this->listener->preRemoveCalls = array();
$this->listener->preRemoveCalls = [];
$this->_em->remove($fix);
$this->_em->flush();
@ -226,7 +226,7 @@ class EntityListenersTest extends OrmFunctionalTestCase
$this->_em->persist($fix);
$this->_em->flush();
$this->listener->postRemoveCalls = array();
$this->listener->postRemoveCalls = [];
$this->_em->remove($fix);
$this->_em->flush();
@ -245,4 +245,4 @@ class EntityListenersTest extends OrmFunctionalTestCase
$this->listener->postRemoveCalls[0][1]
);
}
}
}

View File

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

View File

@ -28,7 +28,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
public function tearDown()
{
if ($this->_em) {
$this->_em->getConfiguration()->setEntityNamespaces(array());
$this->_em->getConfiguration()->setEntityNamespaces([]);
}
parent::tearDown();
}
@ -92,7 +92,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->_em->flush();
$this->_em->clear();
return array($user->id, $address->id);
return [$user->id, $address->id];
}
public function loadFixtureUserEmail()
@ -136,7 +136,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->_em->flush();
$this->_em->clear();
return array($user1, $user2, $user3);
return [$user1, $user2, $user3];
}
public function buildUser($name, $username, $status, $address)
@ -183,7 +183,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$user1Id = $this->loadFixture();
$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->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser',$users[0]);
$this->assertEquals('Guilherme', $users[0]->name);
@ -208,7 +208,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->_em->clear();
$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->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress',$addresses[0]);
@ -232,7 +232,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->_em->clear();
$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->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress',$addresses[0]);
@ -277,13 +277,13 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->loadFixture();
$repos = $this->_em->getRepository(CmsUser::class);
$userCount = $repos->count(array());
$userCount = $repos->count([]);
$this->assertSame(4, $userCount);
$userCount = $repos->count(array('status' => 'dev'));
$userCount = $repos->count(['status' => 'dev']);
$this->assertSame(2, $userCount);
$userCount = $repos->count(array('status' => 'nonexistent'));
$userCount = $repos->count(['status' => 'nonexistent']);
$this->assertSame(0, $userCount);
}
@ -405,7 +405,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$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.");
$user = $repos->findBy(array('address' => $addressId));
$user = $repos->findBy(['address' => $addressId]);
}
/**
@ -415,7 +415,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
{
list($userId, $addressId) = $this->loadAssociatedFixture();
$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->assertEquals($addressId, $address->id);
@ -429,8 +429,8 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->loadFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$userAsc = $repos->findOneBy(array(), array("username" => "ASC"));
$userDesc = $repos->findOneBy(array(), array("username" => "DESC"));
$userAsc = $repos->findOneBy([], ["username" => "ASC"]);
$userDesc = $repos->findOneBy([], ["username" => "DESC"]);
$this->assertNotSame($userAsc, $userDesc);
}
@ -442,7 +442,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
{
list($userId, $addressId) = $this->loadAssociatedFixture();
$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->assertEquals(1, count($addresses));
@ -501,11 +501,11 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
public function testIsNullCriteriaDoesNotGenerateAParameter()
{
$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'];
$this->assertEquals(1, count($params), "Should only execute with one parameter.");
$this->assertEquals(array('romanb'), $params);
$this->assertEquals(['romanb'], $params);
}
public function testIsNullCriteria()
@ -514,7 +514,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$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));
}
@ -527,10 +527,10 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$users1 = $repos->findBy(array(), null, 1, 0);
$users2 = $repos->findBy(array(), null, 1, 1);
$users1 = $repos->findBy([], null, 1, 0);
$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($users2));
$this->assertNotSame($users1[0], $users2[0]);
@ -544,8 +544,8 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->loadFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$usersAsc = $repos->findBy(array(), array("username" => "ASC"));
$usersDesc = $repos->findBy(array(), array("username" => "DESC"));
$usersAsc = $repos->findBy([], ["username" => "ASC"]);
$usersDesc = $repos->findBy([], ["username" => "DESC"]);
$this->assertEquals(4, count($usersAsc), "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();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$resultAsc = $repository->findBy(array(), array('email' => 'ASC'));
$resultDesc = $repository->findBy(array(), array('email' => 'DESC'));
$resultAsc = $repository->findBy([], ['email' => 'ASC']);
$resultDesc = $repository->findBy([], ['email' => 'DESC']);
$this->assertCount(3, $resultAsc);
$this->assertCount(3, $resultDesc);
@ -579,8 +579,8 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->loadFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$usersAsc = $repos->findByStatus('dev', array('username' => "ASC"));
$usersDesc = $repos->findByStatus('dev', array('username' => "DESC"));
$usersAsc = $repos->findByStatus('dev', ['username' => "ASC"]);
$usersDesc = $repos->findByStatus('dev', ['username' => "DESC"]);
$this->assertEquals(2, count($usersAsc));
$this->assertEquals(2, count($usersDesc));
@ -601,8 +601,8 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$this->loadFixture();
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$users1 = $repos->findByStatus('dev', array(), 1, 0);
$users2 = $repos->findByStatus('dev', array(), 1, 1);
$users1 = $repos->findByStatus('dev', [], 1, 0);
$users2 = $repos->findByStatus('dev', [], 1, 1);
$this->assertEquals(1, count($users1));
$this->assertEquals(1, count($users2));
@ -680,7 +680,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
public function testInvalidOrderByAssociation()
{
$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');
$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()
{
$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);
$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]);
}
@ -760,7 +760,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$users = $repository->matching(new Criteria(
Criteria::expr()->in('username', array('beberlei', 'gblanco'))
Criteria::expr()->in('username', ['beberlei', 'gblanco'])
));
$this->assertEquals(2, count($users));
@ -775,7 +775,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$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));
@ -874,7 +874,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $userId);
$criteria = new Criteria(
Criteria::expr()->in('user', array($user))
Criteria::expr()->in('user', [$user])
);
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress');
@ -941,7 +941,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$rsm = $repository->createResultSetMappingBuilder('u');
$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: ');
$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: ');
$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: ');
$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->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->assertSame($user1, reset($users));
@ -1044,7 +1044,7 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$users = $this
->_em
->getRepository('Doctrine\Tests\Models\CMS\CmsUser')
->findBy(array('status' => array('foo', null)));
->findBy(['status' => ['foo', null]]);
$this->assertCount(1, $users);
$this->assertSame($user1, reset($users));
@ -1072,12 +1072,12 @@ class EntityRepositoryTest extends OrmFunctionalTestCase
$users = $this
->_em
->getRepository('Doctrine\Tests\Models\CMS\CmsUser')
->findBy(array('status' => array('dbal maintainer', null)));
->findBy(['status' => ['dbal maintainer', null]]);
$this->assertCount(2, $users);
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->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->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);
//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!
// Solution 1: refresh(), broken atm!
@ -125,7 +125,7 @@ class IdentityMapTest extends OrmFunctionalTestCase
$this->assertSame($user1, $address->user);
//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
$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());
//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
$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()));
//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
$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(
'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();
try {
$this->_schemaTool->createSchema(array(
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\LifecycleCallbackEventArgEntity'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\LifecycleCallbackTestEntity'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\LifecycleCallbackTestUser'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\LifecycleCallbackCascader'),
));
]
);
} catch (\Exception $e) {
// Swallow all exceptions. We do not test the schema tool here.
}
@ -270,13 +272,13 @@ DQL;
public function testLifecycleCallbacksGetInherited()
{
$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()
{
$listener = new LifecycleListenerPreUpdate;
$this->_em->getEventManager()->addEventListener(array('preUpdate'), $listener);
$this->_em->getEventManager()->addEventListener(['preUpdate'], $listener);
$user = new LifecycleCallbackTestUser;
$user->setName('Bob');
@ -292,7 +294,7 @@ DQL;
$this->_em->flush(); // preUpdate reverts Alice to Bob
$this->_em->clear();
$this->_em->getEventManager()->removeEventListener(array('preUpdate'), $listener);
$this->_em->getEventManager()->removeEventListener(['preUpdate'], $listener);
$bob = $this->_em->createQuery($dql)->getSingleResult();
@ -315,7 +317,7 @@ DQL;
$this->_em->flush();
$this->_em->refresh($e);
$this->_em->remove($e);
$this->_em->flush();
@ -358,7 +360,7 @@ DQL;
'Doctrine\ORM\Event\LifecycleEventArgs',
$e->calls['postUpdateHandler']
);
$this->assertInstanceOf(
'Doctrine\ORM\Event\LifecycleEventArgs',
$e->calls['preRemoveHandler']
@ -517,7 +519,7 @@ class LifecycleCallbackEventArgEntity
/** @Column() */
public $value;
public $calls = array();
public $calls = [];
/**
* @PostPersist

View File

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

View File

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

View File

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

View File

@ -14,12 +14,14 @@ class OptimisticTest extends OrmFunctionalTestCase
parent::setUp();
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\OptimisticJoinedChild'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Locking\OptimisticStandard'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Locking\OptimisticTimestamp')
));
]
);
} catch (\Exception $e) {
// 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
// $test and make sure the exception is thrown saying the record was
// 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
$test->whatever = 'ok';
@ -95,7 +97,7 @@ class OptimisticTest extends OrmFunctionalTestCase
// 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
// 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
$test->name = 'WHATT???';
@ -151,7 +153,7 @@ class OptimisticTest extends OrmFunctionalTestCase
// 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
// 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
$test->name = 'WHATT???';
@ -210,7 +212,8 @@ class OptimisticTest extends OrmFunctionalTestCase
// Manually increment the version datetime column
$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
$caughtException = null;

View File

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

View File

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

View File

@ -239,7 +239,7 @@ class MergeProxiesTest extends OrmFunctionalTestCase
$config->setProxyDir(realpath(__DIR__ . '/../../Proxies'));
$config->setProxyNamespace('Doctrine\Tests\Proxies');
$config->setMetadataDriverImpl($config->newDefaultAnnotationDriver(
array(realpath(__DIR__ . '/../../Models/Cache')),
[realpath(__DIR__ . '/../../Models/Cache')],
true
));
$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
// to stub out DB-level access and intercept it
$connection = DriverManager::getConnection(
array(
[
'driver' => 'pdo_sqlite',
'memory' => true
),
],
$config
);

View File

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

View File

@ -281,7 +281,8 @@ class NativeQueryTest extends OrmFunctionalTestCase
$rsm = new ResultSetMappingBuilder($this->_em);
$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->setParameter(1, 'romanb');
@ -349,7 +350,8 @@ class NativeQueryTest extends OrmFunctionalTestCase
{
$rsm = new ResultSetMappingBuilder($this->_em);
$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->setParameter(1, 'romanb');
@ -558,7 +560,7 @@ class NativeQueryTest extends OrmFunctionalTestCase
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$result = $repository->createNativeNamedQuery('fetchUserPhonenumberCount')
->setParameter(1, array('test','FabioBatSilva'))->getResult();
->setParameter(1, ['test','FabioBatSilva'])->getResult();
$this->assertEquals(2, count($result));
$this->assertTrue(is_array($result[0]));
@ -746,10 +748,11 @@ class NativeQueryTest extends OrmFunctionalTestCase
public function testGenerateSelectClauseCustomRenames()
{
$rsm = new ResultSetMappingBuilder($this->_em);
$rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u', array(
$rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u', [
'id' => 'id1',
'username' => 'username2'
));
]
);
$selectClause = $rsm->generateSelectClause();
@ -764,7 +767,7 @@ class NativeQueryTest extends OrmFunctionalTestCase
$rsm = new ResultSetMappingBuilder($this->_em);
$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);
}
@ -804,7 +807,7 @@ class NativeQueryTest extends OrmFunctionalTestCase
$rsm->addFieldResult('u', $this->platform->getSQLResultCasing('id'), 'id');
$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);
}

View File

@ -18,7 +18,7 @@ class NewOperatorTest extends OrmFunctionalTestCase
* @var array
*/
private $fixtures;
protected function setUp()
{
$this->useModelSet('cms');
@ -26,13 +26,13 @@ class NewOperatorTest extends OrmFunctionalTestCase
$this->loadFixtures();
}
public function provideDataForHydrationMode()
{
return array(
array(Query::HYDRATE_ARRAY),
array(Query::HYDRATE_OBJECT),
);
return [
[Query::HYDRATE_ARRAY],
[Query::HYDRATE_OBJECT],
];
}
private function loadFixtures()
@ -93,7 +93,7 @@ class NewOperatorTest extends OrmFunctionalTestCase
$this->_em->flush();
$this->_em->clear();
$this->fixtures = array($u1, $u2, $u3);
$this->fixtures = [$u1, $u2, $u3];
}
/**
@ -223,7 +223,7 @@ class NewOperatorTest extends OrmFunctionalTestCase
$this->_em->getConfiguration()
->addEntityNamespace('cms', 'Doctrine\Tests\Models\CMS');
$query = $this->_em->createQuery($dql);
$result = $query->getResult();

View File

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

View File

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

View File

@ -116,7 +116,8 @@ class OneToManySelfReferentialAssociationTest extends OrmFunctionalTestCase
}
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);
}
}

View File

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

View File

@ -144,7 +144,8 @@ class OneToOneBidirectionalAssociationTest extends OrmFunctionalTestCase
}
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);
}
}

View File

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

View File

@ -86,9 +86,11 @@ class OneToOneSelfReferentialAssociationTest extends OrmFunctionalTestCase
public function testMultiSelfReference()
{
try {
$this->_schemaTool->createSchema(array(
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\MultiSelfReference')
));
]
);
} catch (\Exception $e) {
// Swallow all exceptions. We do not test the schema tool here.
}
@ -118,7 +120,8 @@ class OneToOneSelfReferentialAssociationTest extends OrmFunctionalTestCase
}
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);
}

View File

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

View File

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

View File

@ -16,11 +16,13 @@ class OrderedJoinedTableInheritanceCollectionTest extends OrmFunctionalTestCase
{
parent::setUp();
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_Cat'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\OJTIC_Dog'),
));
]
);
} catch (\Exception $e) {
// Swallow all exceptions. We do not test the schema tool here.
}

View File

@ -633,14 +633,15 @@ class PaginationTest extends OrmFunctionalTestCase
{
$dql = 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u';
$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->setUseOutputWalkers(false);
$this->assertCount(1, $paginator->getIterator());
$this->assertEquals(1, $paginator->count());
}
public function testCountQueryStripsParametersInSelect()
{
$query = $this->_em->createQuery(
@ -695,7 +696,7 @@ class PaginationTest extends OrmFunctionalTestCase
public function populate()
{
$groups = array();
$groups = [];
for ($j = 0; $j < 3; $j++) {;
$group = new CmsGroup();
$group->name = "group$j";
@ -762,28 +763,28 @@ class PaginationTest extends OrmFunctionalTestCase
public function useOutputWalkers()
{
return array(
array(true),
array(false),
);
return [
[true],
[false],
];
}
public function fetchJoinCollection()
{
return array(
array(true),
array(false),
);
return [
[true],
[false],
];
}
public function useOutputWalkersAndFetchJoinCollection()
{
return array(
array(true, false),
array(true, true),
array(false, false),
array(false, true),
);
return [
[true, false],
[true, true],
[false, false],
[false, true],
];
}
}

View File

@ -24,7 +24,7 @@ class PersistentCollectionCriteriaTest extends OrmFunctionalTestCase
public function tearDown()
{
if ($this->_em) {
$this->_em->getConfiguration()->setEntityNamespaces(array());
$this->_em->getConfiguration()->setEntityNamespaces([]);
}
parent::tearDown();
}
@ -75,7 +75,7 @@ class PersistentCollectionCriteriaTest extends OrmFunctionalTestCase
$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());
$this->assertInstanceOf('Doctrine\ORM\LazyCriteriaCollection', $tweets);

View File

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

View File

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

View File

@ -46,7 +46,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase
$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);
}
@ -63,7 +63,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase
$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');
@ -83,7 +83,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase
$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');
@ -103,7 +103,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase
$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');
@ -123,12 +123,12 @@ class PostLoadEventTest extends OrmFunctionalTestCase
->method('postLoad')
->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);
// Now deactivate original listener and attach new one
$eventManager->removeEventListener(array(Events::postLoad), $mockListener);
$eventManager->removeEventListener([Events::postLoad], $mockListener);
$mockListener2 = $this->createMock(PostLoadListener::class);
@ -137,7 +137,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase
->method('postLoad')
->will($this->returnValue(true));
$eventManager->addEventListener(array(Events::postLoad), $mockListener2);
$eventManager->addEventListener([Events::postLoad], $mockListener2);
$userProxy->getName();
}
@ -155,7 +155,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase
->method('postLoad')
->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');
@ -177,7 +177,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase
$eventManager = $this->_em->getEventManager();
$eventManager->addEventListener(array(Events::postLoad), $mockListener);
$eventManager->addEventListener([Events::postLoad], $mockListener);
$emailProxy = $user->getEmail();
@ -198,7 +198,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase
$eventManager = $this->_em->getEventManager();
$eventManager->addEventListener(array(Events::postLoad), $mockListener);
$eventManager->addEventListener([Events::postLoad], $mockListener);
$phonenumbersCol = $user->getPhonenumbers();
@ -211,7 +211,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase
public function testAssociationsArePopulatedWhenEventIsFired()
{
$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->leftJoin('u.email', 'email');
@ -229,7 +229,7 @@ class PostLoadEventTest extends OrmFunctionalTestCase
{
$eventManager = $this->_em->getEventManager();
$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->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
{
private $firedByClasses = array();
private $firedByClasses = [];
public function postLoad(LifecycleEventArgs $event)
{

View File

@ -24,14 +24,16 @@ class ProxiesLikeEntitiesTest extends OrmFunctionalTestCase
{
parent::setUp();
try {
$this->_schemaTool->createSchema(array(
$this->_schemaTool->createSchema(
[
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'),
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber'),
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsArticle'),
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'),
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsEmail'),
$this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsGroup'),
));
]
);
} catch (\Exception $e) {
}
$this->user = new CmsUser();
@ -48,7 +50,7 @@ class ProxiesLikeEntitiesTest extends OrmFunctionalTestCase
public function testPersistUpdate()
{
// 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->id = null;
$proxy->username = 'ocra';
@ -87,7 +89,8 @@ class ProxiesLikeEntitiesTest extends OrmFunctionalTestCase
*/
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();
$result = $this
->_em
@ -117,7 +120,7 @@ class ProxiesLikeEntitiesTest extends OrmFunctionalTestCase
$result = $this
->_em
->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->_em->clear();
$result = $this
@ -133,4 +136,4 @@ class ProxiesLikeEntitiesTest extends OrmFunctionalTestCase
{
$this->_em->createQuery('DELETE FROM Doctrine\Tests\Models\CMS\CmsUser u')->execute();
}
}
}

View File

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