mirror of
https://github.com/doctrine/orm.git
synced 2026-04-03 04:42:24 +02:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5527e121ec | ||
|
|
c55394c616 | ||
|
|
1676cf23c0 | ||
|
|
6dd3078153 | ||
|
|
1e2eca1a7e | ||
|
|
7029d3738d | ||
|
|
7f68347c1f | ||
|
|
e63575ea18 | ||
|
|
d7bdae3bbb | ||
|
|
e2c40dc365 | ||
|
|
dfa6ff64c4 | ||
|
|
ef27721db2 | ||
|
|
13d32e6de5 | ||
|
|
bd1e6ac309 | ||
|
|
369a30ad3d | ||
|
|
ac9df05c92 | ||
|
|
2158a0788e | ||
|
|
2389f77d91 | ||
|
|
5b55739990 | ||
|
|
3e53d9d79c |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "doctrine/orm",
|
||||
"type": "library",
|
||||
"type": "library","version":"2.3.0-RC1",
|
||||
"description": "Object-Relational-Mapper for PHP",
|
||||
"keywords": ["orm", "database"],
|
||||
"homepage": "http://www.doctrine-project.org",
|
||||
|
||||
@@ -589,13 +589,13 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
||||
*
|
||||
* @since 2.2
|
||||
* @param string $className
|
||||
* @throws ORMException If not is a \Doctrine\ORM\EntityRepository
|
||||
* @throws ORMException If not is a \Doctrine\Common\Persistence\ObjectRepository
|
||||
*/
|
||||
public function setDefaultRepositoryClassName($className)
|
||||
{
|
||||
$entityRepositoryClassName = 'Doctrine\ORM\EntityRepository';
|
||||
$reflectionClass = new \ReflectionClass($className);
|
||||
|
||||
if ($className !== $entityRepositoryClassName && ! is_subclass_of($className, $entityRepositoryClassName)) {
|
||||
if ( ! $reflectionClass->implementsInterface('Doctrine\Common\Persistence\ObjectRepository')) {
|
||||
throw ORMException::invalidEntityRepository($className);
|
||||
}
|
||||
|
||||
|
||||
@@ -354,21 +354,82 @@ class EntityManager implements ObjectManager
|
||||
|
||||
$this->unitOfWork->commit($entity);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds an Entity by its identifier.
|
||||
*
|
||||
* This is just a convenient shortcut for getRepository($entityName)->find($id).
|
||||
*
|
||||
* @param string $entityName
|
||||
* @param mixed $identifier
|
||||
* @param int $lockMode
|
||||
* @param int $lockVersion
|
||||
* @param mixed $id
|
||||
* @param integer $lockMode
|
||||
* @param integer $lockVersion
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function find($entityName, $identifier, $lockMode = LockMode::NONE, $lockVersion = null)
|
||||
public function find($entityName, $id, $lockMode = LockMode::NONE, $lockVersion = null)
|
||||
{
|
||||
return $this->getRepository($entityName)->find($identifier, $lockMode, $lockVersion);
|
||||
$class = $this->metadataFactory->getMetadataFor(ltrim($entityName, '\\'));
|
||||
|
||||
if ( ! is_array($id)) {
|
||||
$id = array($class->identifier[0] => $id);
|
||||
}
|
||||
|
||||
$sortedId = array();
|
||||
|
||||
foreach ($class->identifier as $identifier) {
|
||||
if ( ! isset($id[$identifier])) {
|
||||
throw ORMException::missingIdentifierField($class->name, $identifier);
|
||||
}
|
||||
|
||||
$sortedId[$identifier] = $id[$identifier];
|
||||
}
|
||||
|
||||
$unitOfWork = $this->getUnitOfWork();
|
||||
|
||||
// Check identity map first
|
||||
if (($entity = $unitOfWork->tryGetById($sortedId, $class->rootEntityName)) !== false) {
|
||||
if ( ! ($entity instanceof $class->name)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
switch ($lockMode) {
|
||||
case LockMode::OPTIMISTIC:
|
||||
$this->lock($entity, $lockMode, $lockVersion);
|
||||
break;
|
||||
|
||||
case LockMode::PESSIMISTIC_READ:
|
||||
case LockMode::PESSIMISTIC_WRITE:
|
||||
$persister = $unitOfWork->getEntityPersister($class->name);
|
||||
$persister->refresh($sortedId, $entity, $lockMode);
|
||||
break;
|
||||
}
|
||||
|
||||
return $entity; // Hit!
|
||||
}
|
||||
|
||||
$persister = $unitOfWork->getEntityPersister($class->name);
|
||||
|
||||
switch ($lockMode) {
|
||||
case LockMode::NONE:
|
||||
return $persister->load($sortedId);
|
||||
|
||||
case LockMode::OPTIMISTIC:
|
||||
if ( ! $class->isVersioned) {
|
||||
throw OptimisticLockException::notVersioned($class->name);
|
||||
}
|
||||
|
||||
$entity = $persister->load($sortedId);
|
||||
|
||||
$unitOfWork->lock($entity, $lockMode, $lockVersion);
|
||||
|
||||
return $entity;
|
||||
|
||||
default:
|
||||
if ( ! $this->getConnection()->isTransactionActive()) {
|
||||
throw TransactionRequiredException::transactionRequired();
|
||||
}
|
||||
|
||||
return $persister->load($sortedId, null, null, array(), $lockMode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -125,71 +125,15 @@ class EntityRepository implements ObjectRepository, Selectable
|
||||
/**
|
||||
* Finds an entity by its primary key / identifier.
|
||||
*
|
||||
* @param $id The identifier.
|
||||
* @param int $lockMode
|
||||
* @param int $lockVersion
|
||||
* @param mixed $id The identifier.
|
||||
* @param integer $lockMode
|
||||
* @param integer $lockVersion
|
||||
*
|
||||
* @return object The entity.
|
||||
*/
|
||||
public function find($id, $lockMode = LockMode::NONE, $lockVersion = null)
|
||||
{
|
||||
if ( ! is_array($id)) {
|
||||
$id = array($this->_class->identifier[0] => $id);
|
||||
}
|
||||
|
||||
$sortedId = array();
|
||||
|
||||
foreach ($this->_class->identifier as $identifier) {
|
||||
if ( ! isset($id[$identifier])) {
|
||||
throw ORMException::missingIdentifierField($this->_class->name, $identifier);
|
||||
}
|
||||
|
||||
$sortedId[$identifier] = $id[$identifier];
|
||||
}
|
||||
|
||||
// Check identity map first
|
||||
if (($entity = $this->_em->getUnitOfWork()->tryGetById($sortedId, $this->_class->rootEntityName)) !== false) {
|
||||
if ( ! ($entity instanceof $this->_class->name)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
switch ($lockMode) {
|
||||
case LockMode::OPTIMISTIC:
|
||||
$this->_em->lock($entity, $lockMode, $lockVersion);
|
||||
break;
|
||||
case LockMode::PESSIMISTIC_READ:
|
||||
case LockMode::PESSIMISTIC_WRITE:
|
||||
$persister = $this->_em->getUnitOfWork()->getEntityPersister($this->_entityName);
|
||||
$persister->refresh($sortedId, $entity, $lockMode);
|
||||
break;
|
||||
}
|
||||
|
||||
return $entity; // Hit!
|
||||
}
|
||||
|
||||
$persister = $this->_em->getUnitOfWork()->getEntityPersister($this->_entityName);
|
||||
|
||||
switch ($lockMode) {
|
||||
case LockMode::NONE:
|
||||
return $persister->load($sortedId);
|
||||
|
||||
case LockMode::OPTIMISTIC:
|
||||
if ( ! $this->_class->isVersioned) {
|
||||
throw OptimisticLockException::notVersioned($this->_entityName);
|
||||
}
|
||||
|
||||
$entity = $persister->load($sortedId);
|
||||
|
||||
$this->_em->getUnitOfWork()->lock($entity, $lockMode, $lockVersion);
|
||||
|
||||
return $entity;
|
||||
|
||||
default:
|
||||
if ( ! $this->_em->getConnection()->isTransactionActive()) {
|
||||
throw TransactionRequiredException::transactionRequired();
|
||||
}
|
||||
|
||||
return $persister->load($sortedId, null, null, array(), $lockMode);
|
||||
}
|
||||
return $this->_em->find($this->_entityName, $id, $lockMode, $lockVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -448,6 +448,7 @@ class ObjectHydrator extends AbstractHydrator
|
||||
$this->_resultPointers[$dqlAlias] = $element;
|
||||
} else {
|
||||
$this->_uow->setOriginalEntityProperty($oid, $relationField, null);
|
||||
$reflField->setValue($parentObject, null);
|
||||
}
|
||||
// else leave $reflFieldValue null for single-valued associations
|
||||
} else {
|
||||
|
||||
@@ -60,8 +60,12 @@ class AnnotationDriver extends AbstractAnnotationDriver
|
||||
|
||||
$classAnnotations = $this->reader->getClassAnnotations($class);
|
||||
|
||||
if ($classAnnotations && is_numeric(key($classAnnotations))) {
|
||||
foreach ($classAnnotations as $annot) {
|
||||
if ($classAnnotations) {
|
||||
foreach ($classAnnotations as $key => $annot) {
|
||||
if ( ! is_numeric($key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$classAnnotations[get_class($annot)] = $annot;
|
||||
}
|
||||
}
|
||||
@@ -456,8 +460,11 @@ class AnnotationDriver extends AbstractAnnotationDriver
|
||||
if ($method->isPublic() && $method->getDeclaringClass()->getName() == $class->name) {
|
||||
$annotations = $this->reader->getMethodAnnotations($method);
|
||||
|
||||
if ($annotations && is_numeric(key($annotations))) {
|
||||
foreach ($annotations as $annot) {
|
||||
if ($annotations) {
|
||||
foreach ($annotations as $key => $annot) {
|
||||
if ( ! is_numeric($key)) {
|
||||
continue;
|
||||
}
|
||||
$annotations[get_class($annot)] = $annot;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,8 +152,7 @@ class ORMException extends Exception
|
||||
|
||||
public static function invalidEntityRepository($className)
|
||||
{
|
||||
return new self("Invalid repository class '".$className."'. ".
|
||||
"it must be a Doctrine\\ORM\\EntityRepository.");
|
||||
return new self("Invalid repository class '".$className."'. It must be a Doctrine\Common\Persistence\ObjectRepository.");
|
||||
}
|
||||
|
||||
public static function missingIdentifierField($className, $fieldName)
|
||||
|
||||
@@ -294,7 +294,7 @@ final class PersistentCollection implements Collection, Selectable
|
||||
/**
|
||||
* INTERNAL: Gets the association mapping of the collection.
|
||||
*
|
||||
* @return \Doctrine\ORM\Mapping\AssociationMapping
|
||||
* @return array
|
||||
*/
|
||||
public function getMapping()
|
||||
{
|
||||
|
||||
@@ -198,7 +198,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
|
||||
}
|
||||
|
||||
// Composite identifier
|
||||
$sourceClass = $this->_em->getClassMetadata(get_class($mapping->getOwner()));
|
||||
$sourceClass = $this->_em->getClassMetadata(get_class($coll->getOwner()));
|
||||
|
||||
foreach ($mapping['relationToSourceKeyColumns'] as $srcColumn) {
|
||||
$params[] = $identifier[$sourceClass->fieldNames[$srcColumn]];
|
||||
|
||||
@@ -21,7 +21,6 @@ namespace Doctrine\ORM\Proxy;
|
||||
|
||||
use Doctrine\ORM\EntityManager,
|
||||
Doctrine\ORM\Mapping\ClassMetadata,
|
||||
Doctrine\ORM\Mapping\AssociationMapping,
|
||||
Doctrine\Common\Util\ClassUtils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -96,7 +96,7 @@ class QueryException extends \Doctrine\ORM\ORMException
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Doctrine\ORM\Mapping\AssociationMapping $assoc
|
||||
* @param array $assoc
|
||||
*/
|
||||
public static function iterateWithFetchJoinCollectionNotAllowed($assoc)
|
||||
{
|
||||
|
||||
@@ -429,7 +429,7 @@ class QueryBuilder
|
||||
*
|
||||
* @param mixed $key The key (index or name) of the bound parameter.
|
||||
*
|
||||
* @return mixed The value of the bound parameter.
|
||||
* @return Query\Parameter|null The value of the bound parameter.
|
||||
*/
|
||||
public function getParameter($key)
|
||||
{
|
||||
@@ -1169,5 +1169,13 @@ class QueryBuilder
|
||||
$this->_dqlParts[$part] = clone $elements;
|
||||
}
|
||||
}
|
||||
|
||||
$parameters = array();
|
||||
|
||||
foreach ($this->parameters as $parameter) {
|
||||
$parameters[] = clone $parameter;
|
||||
}
|
||||
|
||||
$this->parameters = new ArrayCollection($parameters);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ use Symfony\Component\Console\Input\InputArgument,
|
||||
/**
|
||||
* Command to clear the metadata cache of the various cache drivers.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.0
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
@@ -52,20 +52,19 @@ class MetadataCommand extends Console\Command\Command
|
||||
)
|
||||
));
|
||||
|
||||
$fullName = $this->getName();
|
||||
$this->setHelp(<<<EOT
|
||||
The <info>$fullName</info> command is meant to clear the metadata cache of associated Entity Manager.
|
||||
The <info>%command.name%</info> command is meant to clear the metadata cache of associated Entity Manager.
|
||||
It is possible to invalidate all cache entries at once - called delete -, or flushes the cache provider
|
||||
instance completely.
|
||||
|
||||
The execution type differ on how you execute the command.
|
||||
If you want to invalidate the entries (and not delete from cache instance), this command would do the work:
|
||||
|
||||
<info>$fullName</info>
|
||||
<info>%command.name%</info>
|
||||
|
||||
Alternatively, if you want to flush the cache provider using this command:
|
||||
|
||||
<info>$fullName --flush</info>
|
||||
<info>%command.name% --flush</info>
|
||||
|
||||
Finally, be aware that if <info>--flush</info> option is passed, not all cache providers are able to flush entries,
|
||||
because of a limitation of its execution nature.
|
||||
|
||||
@@ -27,7 +27,7 @@ use Symfony\Component\Console\Input\InputArgument,
|
||||
/**
|
||||
* Command to clear the query cache of the various cache drivers.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.0
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
@@ -52,20 +52,19 @@ class QueryCommand extends Console\Command\Command
|
||||
)
|
||||
));
|
||||
|
||||
$fullName = $this->getName();
|
||||
$this->setHelp(<<<EOT
|
||||
The <info>$fullName</info> command is meant to clear the query cache of associated Entity Manager.
|
||||
The <info>%command.name%</info> command is meant to clear the query cache of associated Entity Manager.
|
||||
It is possible to invalidate all cache entries at once - called delete -, or flushes the cache provider
|
||||
instance completely.
|
||||
|
||||
The execution type differ on how you execute the command.
|
||||
If you want to invalidate the entries (and not delete from cache instance), this command would do the work:
|
||||
|
||||
<info>$fullName</info>
|
||||
<info>%command.name%</info>
|
||||
|
||||
Alternatively, if you want to flush the cache provider using this command:
|
||||
|
||||
<info>$fullName --flush</info>
|
||||
<info>%command.name% --flush</info>
|
||||
|
||||
Finally, be aware that if <info>--flush</info> option is passed, not all cache providers are able to flush entries,
|
||||
because of a limitation of its execution nature.
|
||||
|
||||
@@ -27,7 +27,7 @@ use Symfony\Component\Console\Input\InputArgument,
|
||||
/**
|
||||
* Command to clear the result cache of the various cache drivers.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.0
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
@@ -52,20 +52,19 @@ class ResultCommand extends Console\Command\Command
|
||||
)
|
||||
));
|
||||
|
||||
$fullName = $this->getName();
|
||||
$this->setHelp(<<<EOT
|
||||
The <info>$fullName</info> command is meant to clear the result cache of associated Entity Manager.
|
||||
The <info>%command.name%</info> command is meant to clear the result cache of associated Entity Manager.
|
||||
It is possible to invalidate all cache entries at once - called delete -, or flushes the cache provider
|
||||
instance completely.
|
||||
|
||||
The execution type differ on how you execute the command.
|
||||
If you want to invalidate the entries (and not delete from cache instance), this command would do the work:
|
||||
|
||||
<info>$fullName</info>
|
||||
<info>%command.name%</info>
|
||||
|
||||
Alternatively, if you want to flush the cache provider using this command:
|
||||
|
||||
<info>$fullName --flush</info>
|
||||
<info>%command.name% --flush</info>
|
||||
|
||||
Finally, be aware that if <info>--flush</info> option is passed, not all cache providers are able to flush entries,
|
||||
because of a limitation of its execution nature.
|
||||
|
||||
@@ -27,7 +27,7 @@ use Symfony\Component\Console\Command\Command;
|
||||
/**
|
||||
* Show information about mapped entities
|
||||
*
|
||||
*
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.1
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
@@ -40,7 +40,7 @@ class InfoCommand extends Command
|
||||
->setName('orm:info')
|
||||
->setDescription('Show basic information about all mapped entities')
|
||||
->setHelp(<<<EOT
|
||||
The <info>doctrine:mapping:info</info> shows basic information about which
|
||||
The <info>%command.name%</info> shows basic information about which
|
||||
entities exist and possibly if their mapping information contains errors or
|
||||
not.
|
||||
EOT
|
||||
|
||||
@@ -29,7 +29,7 @@ use Symfony\Component\Console\Input\InputArgument,
|
||||
* Command to generate the SQL needed to update the database schema to match
|
||||
* the current mapping information.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
* @since 2.0
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
@@ -68,20 +68,19 @@ class UpdateCommand extends AbstractCommand
|
||||
),
|
||||
));
|
||||
|
||||
$fullName = $this->getName();
|
||||
$this->setHelp(<<<EOT
|
||||
The <info>$fullName</info> command generates the SQL needed to
|
||||
The <info>%command.name%</info> command generates the SQL needed to
|
||||
synchronize the database schema with the current mapping metadata of the
|
||||
default entity manager.
|
||||
|
||||
For example, if you add metadata for a new column to an entity, this command
|
||||
would generate and output the SQL needed to add the new column to the database:
|
||||
|
||||
<info>$fullName --dump-sql</info>
|
||||
<info>%command.name% --dump-sql</info>
|
||||
|
||||
Alternatively, you can execute the generated queries:
|
||||
|
||||
<info>$fullName --force</info>
|
||||
<info>%command.name% --force</info>
|
||||
|
||||
Finally, be aware that if the <info>--complete</info> option is passed, this
|
||||
task will drop all database assets (e.g. tables, etc) that are *not* described
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
namespace Doctrine\ORM\Tools;
|
||||
|
||||
use Doctrine\ORM\Mapping\ClassMetadataInfo,
|
||||
Doctrine\ORM\Mapping\AssociationMapping,
|
||||
Doctrine\Common\Util\Inflector,
|
||||
Doctrine\DBAL\Types\Type;
|
||||
|
||||
@@ -154,6 +153,8 @@ class EntityGenerator
|
||||
Type::TEXT => 'string',
|
||||
Type::BLOB => 'string',
|
||||
Type::DECIMAL => 'float',
|
||||
Type::JSON_ARRAY => 'array',
|
||||
Type::SIMPLE_ARRAY => 'array',
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
namespace Doctrine\ORM\Tools\Export\Driver;
|
||||
|
||||
use Doctrine\ORM\Mapping\ClassMetadataInfo,
|
||||
Doctrine\ORM\Mapping\AssociationMapping,
|
||||
Doctrine\ORM\Tools\EntityGenerator;
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,7 +36,7 @@ class Version
|
||||
/**
|
||||
* Current Doctrine Version
|
||||
*/
|
||||
const VERSION = '2.3.0-DEV';
|
||||
const VERSION = '2.3.0-RC1';
|
||||
|
||||
/**
|
||||
* Compares a Doctrine version with the current one.
|
||||
|
||||
2
lib/vendor/doctrine-common
vendored
2
lib/vendor/doctrine-common
vendored
Submodule lib/vendor/doctrine-common updated: 15b04ec520...9b67267f19
2
lib/vendor/doctrine-dbal
vendored
2
lib/vendor/doctrine-dbal
vendored
Submodule lib/vendor/doctrine-dbal updated: 659de9a189...a2da6c6f8a
@@ -10,7 +10,7 @@ namespace Doctrine\Tests\Mocks;
|
||||
class StatementMock implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
|
||||
{
|
||||
public function bindValue($param, $value, $type = null){}
|
||||
public function bindParam($column, &$variable, $type = null){}
|
||||
public function bindParam($column, &$variable, $type = null, $length = null){}
|
||||
public function errorCode(){}
|
||||
public function errorInfo(){}
|
||||
public function execute($params = null){}
|
||||
|
||||
@@ -30,12 +30,25 @@ class NavPointOfInterest
|
||||
*/
|
||||
private $country;
|
||||
|
||||
/**
|
||||
* @ManyToMany(targetEntity="NavUser", cascade={"persist"})
|
||||
* @JoinTable(name="navigation_pois_visitors",
|
||||
* inverseJoinColumns={@JoinColumn(name="user_id", referencedColumnName="id")},
|
||||
* joinColumns={
|
||||
* @JoinColumn(name="poi_long", referencedColumnName="nav_long"),
|
||||
* @JoinColumn(name="poi_lat", referencedColumnName="nav_lat")
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
private $visitors;
|
||||
|
||||
public function __construct($lat, $long, $name, $country)
|
||||
{
|
||||
$this->lat = $lat;
|
||||
$this->long = $long;
|
||||
$this->name = $name;
|
||||
$this->country = $country;
|
||||
$this->visitors = new \Doctrine\Common\Collections\ArrayCollection;
|
||||
}
|
||||
|
||||
public function getLong() {
|
||||
@@ -53,4 +66,14 @@ class NavPointOfInterest
|
||||
public function getCountry() {
|
||||
return $this->country;
|
||||
}
|
||||
|
||||
public function addVisitor(NavUser $user)
|
||||
{
|
||||
$this->visitors[] = $user;
|
||||
}
|
||||
|
||||
public function getVisitors()
|
||||
{
|
||||
return $this->visitors;
|
||||
}
|
||||
}
|
||||
|
||||
28
tests/Doctrine/Tests/Models/Navigation/NavUser.php
Normal file
28
tests/Doctrine/Tests/Models/Navigation/NavUser.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\Navigation;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="navigation_users")
|
||||
*/
|
||||
class NavUser
|
||||
{
|
||||
/**
|
||||
* @Id
|
||||
* @Column(type="integer")
|
||||
* @generatedValue
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @column(type="string")
|
||||
*/
|
||||
private $name;
|
||||
|
||||
public function __construct($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ use Doctrine\Tests\Models\Navigation\NavCountry;
|
||||
use Doctrine\Tests\Models\Navigation\NavPointOfInterest;
|
||||
use Doctrine\Tests\Models\Navigation\NavTour;
|
||||
use Doctrine\Tests\Models\Navigation\NavPhotos;
|
||||
use Doctrine\Tests\Models\Navigation\NavUser;
|
||||
|
||||
require_once __DIR__ . '/../../TestInit.php';
|
||||
|
||||
@@ -118,4 +119,26 @@ class CompositePrimaryKeyTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->setExpectedException('Doctrine\ORM\ORMException', '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));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-1939
|
||||
*/
|
||||
public function testDeleteCompositePersistentCollection()
|
||||
{
|
||||
$this->putGermanysBrandenburderTor();
|
||||
|
||||
$poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', array('lat' => 100, 'long' => 200));
|
||||
$poi->addVisitor(new NavUser("test1"));
|
||||
$poi->addVisitor(new NavUser("test2"));
|
||||
|
||||
$this->_em->flush();
|
||||
|
||||
$poi->getVisitors()->clear();
|
||||
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
|
||||
$poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', array('lat' => 100, 'long' => 200));
|
||||
$this->assertEquals(0, count($poi->getVisitors()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -528,7 +528,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
/**
|
||||
* @group DDC-753
|
||||
* @expectedException Doctrine\ORM\ORMException
|
||||
* @expectedExceptionMessage Invalid repository class 'Doctrine\Tests\Models\DDC753\DDC753InvalidRepository'. it must be a Doctrine\ORM\EntityRepository.
|
||||
* @expectedExceptionMessage Invalid repository class 'Doctrine\Tests\Models\DDC753\DDC753InvalidRepository'. It must be a Doctrine\Common\Persistence\ObjectRepository.
|
||||
*/
|
||||
public function testSetDefaultRepositoryInvalidClassError()
|
||||
{
|
||||
|
||||
@@ -21,6 +21,7 @@ class OneToOneEagerLoadingTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$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) {}
|
||||
}
|
||||
@@ -181,6 +182,24 @@ class OneToOneEagerLoadingTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->_sqlLoggerStack->queries[$this->_sqlLoggerStack->currentQuery]['sql']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-1946
|
||||
*/
|
||||
public function testEagerLoadingDoesNotBreakRefresh()
|
||||
{
|
||||
$train = new Train(new TrainOwner('Johannes'));
|
||||
$order = new TrainOrder($train);
|
||||
$this->_em->persist($train);
|
||||
$this->_em->persist($order);
|
||||
$this->_em->flush();
|
||||
|
||||
$this->_em->getConnection()->exec("UPDATE TrainOrder SET train_id = NULL");
|
||||
|
||||
$this->assertSame($train, $order->train);
|
||||
$this->_em->refresh($order);
|
||||
$this->assertTrue($order->train === null, "Train reference was not refreshed to NULL.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -305,3 +324,20 @@ class Waggon
|
||||
$this->train = $train;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
*/
|
||||
class TrainOrder
|
||||
{
|
||||
/** @id @generatedValue @column(type="integer") */
|
||||
public $id;
|
||||
|
||||
/** @OneToOne(targetEntity = "Train", fetch = "EAGER") */
|
||||
public $train;
|
||||
|
||||
public function __construct(Train $train)
|
||||
{
|
||||
$this->train = $train;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,9 @@ use Doctrine\ORM\Query;
|
||||
|
||||
require_once __DIR__ . '/../../../TestInit.php';
|
||||
|
||||
/**
|
||||
* @group DDC-371
|
||||
*/
|
||||
class DDC371Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
{
|
||||
protected function setUp()
|
||||
|
||||
@@ -664,6 +664,23 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase
|
||||
$this->assertEquals(2, $expr->count(), "Modifying the second query should affect the first one.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-1933
|
||||
*/
|
||||
public function testParametersAreCloned()
|
||||
{
|
||||
$originalQb = new QueryBuilder($this->_em);
|
||||
|
||||
$originalQb->setParameter('parameter1', 'value1');
|
||||
|
||||
$copy = clone $originalQb;
|
||||
$copy->setParameter('parameter2', 'value2');
|
||||
|
||||
$this->assertCount(1, $originalQb->getParameters());
|
||||
$this->assertSame('value1', $copy->getParameter('parameter1')->getValue());
|
||||
$this->assertSame('value2', $copy->getParameter('parameter2')->getValue());
|
||||
}
|
||||
|
||||
public function testGetRootAlias()
|
||||
{
|
||||
$qb = $this->_em->createQueryBuilder()
|
||||
|
||||
@@ -88,6 +88,7 @@ abstract class OrmFunctionalTestCase extends OrmTestCase
|
||||
'Doctrine\Tests\Models\Routing\RoutingRouteBooking',
|
||||
),
|
||||
'navigation' => array(
|
||||
'Doctrine\Tests\Models\Navigation\NavUser',
|
||||
'Doctrine\Tests\Models\Navigation\NavCountry',
|
||||
'Doctrine\Tests\Models\Navigation\NavPhotos',
|
||||
'Doctrine\Tests\Models\Navigation\NavTour',
|
||||
|
||||
@@ -30,7 +30,7 @@ $connectionOptions = array(
|
||||
|
||||
$em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);
|
||||
|
||||
$helpers = array(
|
||||
$helpers = new Symfony\Component\Console\Helper\HelperSet(array(
|
||||
'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
|
||||
'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)
|
||||
);
|
||||
));
|
||||
Reference in New Issue
Block a user