1
0
mirror of synced 2025-01-29 19:41:45 +03:00

Merge branch 'master' into DDC-551

Conflicts:
	lib/Doctrine/ORM/Persisters/OneToManyPersister.php
This commit is contained in:
Alexander 2011-08-16 16:59:48 +02:00
commit ed0fb4ece7
102 changed files with 2066 additions and 585 deletions

3
UPGRADE_TO_2_2 Normal file
View File

@ -0,0 +1,3 @@
# Removed support for onUpdate in @JoinColumn
The onUpdate foreign key handling makes absolutly no sense in an ORM. Additionally Oracle doesn't even support it. Support for it is removed.

View File

@ -107,6 +107,23 @@
<target name="build" depends="test, build-orm"/>
<target name="package-phar" depends="build-orm">
<pharpackage basedir="${build.dir}/doctrine-orm/" destfile="${dist.dir}/doctrine-orm-${version}.phar" clistub="${build.dir}/doctrine-orm/bin/doctrine.php" signature="sha512">
<fileset dir="${build.dir}/doctrine-orm">
<include name="**/**" />
</fileset>
<metadata>
<element name="version" value="${version}" />
<element name="authors">
<element name="Guilherme Blanco"><element name="e-mail" value="guilhermeblanco@gmail.com" /></element>
<element name="Benjamin Eberlei"><element name="e-mail" value="kontakt@beberlei.de" /></element>
<element name="Jonathan H. Wage"><element name="e-mail" value="jonwage@gmail.com" /></element>
<element name="Roman Borschel"><element name="e-mail" value="roman@code-factory.org" /></element>
</element>
</metadata>
</pharpackage>
</target>
<!--
Runs the full test suite.
-->
@ -206,6 +223,7 @@
<target name="distribute-download">
<copy file="dist/DoctrineORM-${version}-full.tar.gz" todir="${project.download_dir}" />
<copy file="${dist.dir}/doctrine-orm-${version}.phar" todir="${project.download_dir}" />
</target>
<target name="update-dev-version">
@ -217,7 +235,7 @@
<exec command="git commit -m 'Bump Dev Version to ${next_version}-DEV'" passthru="true" />
</target>
<target name="release" depends="git-tag,build-packages,distribute-download,pirum-release,update-dev-version" />
<target name="release" depends="git-tag,build-packages,package-phar,distribute-download,pirum-release,update-dev-version" />
<!--
Builds distributable PEAR packages for the Symfony Dependencies

View File

@ -195,6 +195,8 @@ abstract class AbstractQuery
*/
public function setParameter($key, $value, $type = null)
{
$key = trim($key, ':');
if ($type === null) {
$type = Query\ParameterTypeInferer::inferType($value);
}

View File

@ -85,7 +85,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
/**
* Gets the namespace where proxy classes reside.
*
*
* @return string
*/
public function getProxyNamespace()
@ -96,7 +96,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
/**
* Sets the namespace where proxy classes reside.
*
*
* @param string $ns
*/
public function setProxyNamespace($ns)
@ -118,22 +118,23 @@ class Configuration extends \Doctrine\DBAL\Configuration
/**
* Add a new default annotation driver with a correctly configured annotation reader.
*
*
* @param array $paths
* @return Mapping\Driver\AnnotationDriver
*/
public function newDefaultAnnotationDriver($paths = array())
{
if (version_compare(\Doctrine\Common\Version::VERSION, '3.0.0-DEV', '>=')) {
if (version_compare(\Doctrine\Common\Version::VERSION, '2.2.0-DEV', '>=')) {
// Register the ORM Annotations in the AnnotationRegistry
AnnotationRegistry::registerFile(__DIR__ . '/Mapping/Driver/DoctrineAnnotations.php');
$reader = new AnnotationReader();
$reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader();
$reader->addNamespace('Doctrine\ORM\Mapping');
$reader = new \Doctrine\Common\Annotations\CachedReader($reader, new ArrayCache());
} else if (version_compare(\Doctrine\Common\Version::VERSION, '2.1.0-DEV', '>=')) {
// Register the ORM Annotations in the AnnotationRegistry
AnnotationRegistry::registerFile(__DIR__ . '/Mapping/Driver/DoctrineAnnotations.php');
$reader = new AnnotationReader();
$reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\');
$reader->setIgnoreNotImportedAnnotations(true);
@ -162,7 +163,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
/**
* Resolves a registered namespace alias to the full namespace.
*
* @param string $entityNamespaceAlias
* @param string $entityNamespaceAlias
* @return string
* @throws MappingException
*/
@ -185,10 +186,10 @@ class Configuration extends \Doctrine\DBAL\Configuration
{
$this->_attributes['entityNamespaces'] = $entityNamespaces;
}
/**
* Retrieves the list of registered entity namespace aliases.
*
*
* @return array
*/
public function getEntityNamespaces()
@ -360,7 +361,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
/**
* Gets the implementation class name of a registered custom string DQL function.
*
*
* @param string $name
* @return string
*/
@ -403,7 +404,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
/**
* Gets the implementation class name of a registered custom numeric DQL function.
*
*
* @param string $name
* @return string
*/
@ -446,7 +447,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
/**
* Gets the implementation class name of a registered custom date/time DQL function.
*
*
* @param string $name
* @return string
*/
@ -497,7 +498,7 @@ class Configuration extends \Doctrine\DBAL\Configuration
/**
* Set a class metadata factory.
*
*
* @param string $cmf
*/
public function setClassMetadataFactoryName($cmfName)

View File

@ -216,13 +216,21 @@ class ObjectHydrator extends AbstractHydrator
private function _getEntityFromIdentityMap($className, array $data)
{
// TODO: Abstract this code and UnitOfWork::createEntity() equivalent?
$class = $this->_ce[$className];
/* @var $class ClassMetadata */
if ($class->isIdentifierComposite) {
$idHash = '';
foreach ($class->identifier as $fieldName) {
$idHash .= $data[$fieldName] . ' ';
if (isset($class->associationMappings[$fieldName])) {
$idHash .= $data[$class->associationMappings[$fieldName]['joinColumns'][0]['name']] . ' ';
} else {
$idHash .= $data[$fieldName] . ' ';
}
}
return $this->_uow->tryGetByIdHash(rtrim($idHash), $class->rootEntityName);
} else if (isset($class->associationMappings[$class->identifier[0]])) {
return $this->_uow->tryGetByIdHash($data[$class->associationMappings[$class->identifier[0]]['joinColumns'][0]['name']], $class->rootEntityName);
} else {
return $this->_uow->tryGetByIdHash($data[$class->identifier[0]], $class->rootEntityName);
}

View File

@ -833,15 +833,11 @@ class ClassMetadataInfo implements ClassMetadata
// Cascades
$cascades = isset($mapping['cascade']) ? array_map('strtolower', $mapping['cascade']) : array();
if (in_array('all', $cascades)) {
$cascades = array(
'remove',
'persist',
'refresh',
'merge',
'detach'
);
$cascades = array('remove', 'persist', 'refresh', 'merge', 'detach');
}
$mapping['cascade'] = $cascades;
$mapping['isCascadeRemove'] = in_array('remove', $cascades);
$mapping['isCascadePersist'] = in_array('persist', $cascades);
@ -1800,7 +1796,7 @@ class ClassMetadataInfo implements ClassMetadata
$this->versionField = $mapping['fieldName'];
if ( ! isset($mapping['default'])) {
if ($mapping['type'] == 'integer') {
if (in_array($mapping['type'], array('integer', 'bigint', 'smallint'))) {
$mapping['default'] = 1;
} else if ($mapping['type'] == 'datetime') {
$mapping['default'] = 'CURRENT_TIMESTAMP';

View File

@ -97,6 +97,16 @@ class AnnotationDriver implements Driver
return $this->_paths;
}
/**
* Retrieve the current annotation reader
*
* @return AnnotationReader
*/
public function getReader()
{
return $this->_reader;
}
/**
* Get the file extension used to look for mapping files under
*
@ -243,7 +253,6 @@ class AnnotationDriver implements Driver
'unique' => $joinColumnAnnot->unique,
'nullable' => $joinColumnAnnot->nullable,
'onDelete' => $joinColumnAnnot->onDelete,
'onUpdate' => $joinColumnAnnot->onUpdate,
'columnDefinition' => $joinColumnAnnot->columnDefinition,
);
} else if ($joinColumnsAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\JoinColumns')) {
@ -254,7 +263,6 @@ class AnnotationDriver implements Driver
'unique' => $joinColumn->unique,
'nullable' => $joinColumn->nullable,
'onDelete' => $joinColumn->onDelete,
'onUpdate' => $joinColumn->onUpdate,
'columnDefinition' => $joinColumn->columnDefinition,
);
}
@ -362,7 +370,6 @@ class AnnotationDriver implements Driver
'unique' => $joinColumn->unique,
'nullable' => $joinColumn->nullable,
'onDelete' => $joinColumn->onDelete,
'onUpdate' => $joinColumn->onUpdate,
'columnDefinition' => $joinColumn->columnDefinition,
);
}
@ -374,7 +381,6 @@ class AnnotationDriver implements Driver
'unique' => $joinColumn->unique,
'nullable' => $joinColumn->nullable,
'onDelete' => $joinColumn->onDelete,
'onUpdate' => $joinColumn->onUpdate,
'columnDefinition' => $joinColumn->columnDefinition,
);
}

View File

@ -23,19 +23,31 @@ use Doctrine\Common\Annotations\Annotation;
/* Annotations */
/** @Annotation */
/**
* @Annotation
* @Target("CLASS")
*/
final class Entity extends Annotation {
public $repositoryClass;
public $readOnly = false;
}
/** @Annotation */
/**
* @Annotation
* @Target("CLASS")
*/
final class MappedSuperclass extends Annotation {}
/** @Annotation */
/**
* @Annotation
* @Target("CLASS")
*/
final class InheritanceType extends Annotation {}
/** @Annotation */
/**
* @Annotation
* @Target("CLASS")
*/
final class DiscriminatorColumn extends Annotation {
public $name;
public $fieldName; // field name used in non-object hydration (array/scalar)
@ -43,21 +55,36 @@ final class DiscriminatorColumn extends Annotation {
public $length;
}
/** @Annotation */
/**
* @Annotation
* @Target("CLASS")
*/
final class DiscriminatorMap extends Annotation {}
/** @Annotation */
/**
* @Annotation
* @Target("PROPERTY")
*/
final class Id extends Annotation {}
/** @Annotation */
/**
* @Annotation
* @Target("PROPERTY")
*/
final class GeneratedValue extends Annotation {
public $strategy = 'AUTO';
}
/** @Annotation */
/**
* @Annotation
* @Target("PROPERTY")
*/
final class Version extends Annotation {}
/** @Annotation */
/**
* @Annotation
* @Target({"PROPERTY","ANNOTATION"})
*/
final class JoinColumn extends Annotation {
public $name;
public $fieldName; // field name used in non-object hydration (array/scalar)
@ -65,14 +92,19 @@ final class JoinColumn extends Annotation {
public $unique = false;
public $nullable = true;
public $onDelete;
public $onUpdate;
public $columnDefinition;
}
/** @Annotation */
/**
* @Annotation
* @Target("PROPERTY")
*/
final class JoinColumns extends Annotation {}
/** @Annotation */
/**
* @Annotation
* @Target("PROPERTY")
*/
final class Column extends Annotation {
public $type = 'string';
public $length;
@ -87,7 +119,10 @@ final class Column extends Annotation {
public $columnDefinition;
}
/** @Annotation */
/**
* @Annotation
* @Target("PROPERTY")
*/
final class OneToOne extends Annotation {
public $targetEntity;
public $mappedBy;
@ -97,7 +132,10 @@ final class OneToOne extends Annotation {
public $orphanRemoval = false;
}
/** @Annotation */
/**
* @Annotation
* @Target("PROPERTY")
*/
final class OneToMany extends Annotation {
public $mappedBy;
public $targetEntity;
@ -107,7 +145,10 @@ final class OneToMany extends Annotation {
public $indexBy;
}
/** @Annotation */
/**
* @Annotation
* @Target("PROPERTY")
*/
final class ManyToOne extends Annotation {
public $targetEntity;
public $cascade;
@ -115,7 +156,10 @@ final class ManyToOne extends Annotation {
public $inversedBy;
}
/** @Annotation */
/**
* @Annotation
* @Target("PROPERTY")
*/
final class ManyToMany extends Annotation {
public $targetEntity;
public $mappedBy;
@ -125,12 +169,19 @@ final class ManyToMany extends Annotation {
public $indexBy;
}
/** @Annotation */
/**
* @Annotation
* @Target("ALL")
* @todo check available targets
*/
final class ElementCollection extends Annotation {
public $tableName;
}
/** @Annotation */
/**
* @Annotation
* @Target("CLASS")
*/
final class Table extends Annotation {
public $name;
public $schema;
@ -138,19 +189,28 @@ final class Table extends Annotation {
public $uniqueConstraints;
}
/** @Annotation */
/**
* @Annotation
* @Target("ANNOTATION")
*/
final class UniqueConstraint extends Annotation {
public $name;
public $columns;
}
/** @Annotation */
/**
* @Annotation
* @Target("ANNOTATION")
*/
final class Index extends Annotation {
public $name;
public $columns;
}
/** @Annotation */
/**
* @Annotation
* @Target("PROPERTY")
*/
final class JoinTable extends Annotation {
public $name;
public $schema;
@ -158,49 +218,89 @@ final class JoinTable extends Annotation {
public $inverseJoinColumns = array();
}
/** @Annotation */
/**
* @Annotation
* @Target("PROPERTY")
*/
final class SequenceGenerator extends Annotation {
public $sequenceName;
public $allocationSize = 1;
public $initialValue = 1;
}
/** @Annotation */
/**
* @Annotation
* @Target("CLASS")
*/
final class ChangeTrackingPolicy extends Annotation {}
/** @Annotation */
/**
* @Annotation
* @Target("PROPERTY")
*/
final class OrderBy extends Annotation {}
/** @Annotation */
/**
* @Annotation
* @Target("CLASS")
*/
final class NamedQueries extends Annotation {}
/** @Annotation */
/**
* @Annotation
* @Target("ANNOTATION")
*/
final class NamedQuery extends Annotation {
public $name;
public $query;
}
/* Annotations for lifecycle callbacks */
/** @Annotation */
/**
* @Annotation
* @Target("CLASS")
*/
final class HasLifecycleCallbacks extends Annotation {}
/** @Annotation */
/**
* @Annotation
* @Target("METHOD")
*/
final class PrePersist extends Annotation {}
/** @Annotation */
/**
* @Annotation
* @Target("METHOD")
*/
final class PostPersist extends Annotation {}
/** @Annotation */
/**
* @Annotation
* @Target("METHOD")
*/
final class PreUpdate extends Annotation {}
/** @Annotation */
/**
* @Annotation
* @Target("METHOD")
*/
final class PostUpdate extends Annotation {}
/** @Annotation */
/**
* @Annotation
* @Target("METHOD")
*/
final class PreRemove extends Annotation {}
/** @Annotation */
/**
* @Annotation
* @Target("METHOD")
*/
final class PostRemove extends Annotation {}
/** @Annotation */
/**
* @Annotation
* @Target("METHOD")
*/
final class PostLoad extends Annotation {}

View File

@ -88,15 +88,20 @@ class DriverChain implements Driver
public function getAllClassNames()
{
$classNames = array();
$driverClasses = array();
foreach ($this->_drivers AS $namespace => $driver) {
$driverClasses = $driver->getAllClassNames();
foreach ($driverClasses AS $className) {
$oid = spl_object_hash($driver);
if (!isset($driverClasses[$oid])) {
$driverClasses[$oid] = $driver->getAllClassNames();
}
foreach ($driverClasses[$oid] AS $className) {
if (strpos($className, $namespace) === 0) {
$classNames[] = $className;
$classNames[$className] = true;
}
}
}
return array_unique($classNames);
return array_keys($classNames);
}
/**

View File

@ -285,8 +285,8 @@ class XmlDriver extends AbstractFileDriver
$mapping['cascade'] = $this->_getCascadeMappings($oneToOneElement->cascade);
}
if (isset($oneToOneElement->{'orphan-removal'})) {
$mapping['orphanRemoval'] = (bool)$oneToOneElement->{'orphan-removal'};
if (isset($oneToOneElement['orphan-removal'])) {
$mapping['orphanRemoval'] = (bool)$oneToOneElement['orphan-removal'];
}
$metadata->mapOneToOne($mapping);
@ -310,8 +310,8 @@ class XmlDriver extends AbstractFileDriver
$mapping['cascade'] = $this->_getCascadeMappings($oneToManyElement->cascade);
}
if (isset($oneToManyElement->{'orphan-removal'})) {
$mapping['orphanRemoval'] = (bool)$oneToManyElement->{'orphan-removal'};
if (isset($oneToManyElement['orphan-removal'])) {
$mapping['orphanRemoval'] = (bool)$oneToManyElement['orphan-removal'];
}
if (isset($oneToManyElement->{'order-by'})) {
@ -322,8 +322,8 @@ class XmlDriver extends AbstractFileDriver
$mapping['orderBy'] = $orderBy;
}
if (isset($oneToManyElement->{'index-by'})) {
$mapping['indexBy'] = (string)$oneToManyElement->{'index-by'};
if (isset($oneToManyElement['index-by'])) {
$mapping['indexBy'] = (string)$oneToManyElement['index-by'];
}
$metadata->mapOneToMany($mapping);
@ -471,10 +471,6 @@ class XmlDriver extends AbstractFileDriver
$joinColumn['onDelete'] = (string)$joinColumnElement['on-delete'];
}
if (isset($joinColumnElement['on-update'])) {
$joinColumn['onUpdate'] = (string)$joinColumnElement['on-update'];
}
if (isset($joinColumnElement['column-definition'])) {
$joinColumn['columnDefinition'] = (string)$joinColumnElement['column-definition'];
}

View File

@ -490,10 +490,6 @@ class YamlDriver extends AbstractFileDriver
$joinColumn['onDelete'] = $joinColumnElement['onDelete'];
}
if (isset($joinColumnElement['onUpdate'])) {
$joinColumn['onUpdate'] = $joinColumnElement['onUpdate'];
}
if (isset($joinColumnElement['columnDefinition'])) {
$joinColumn['columnDefinition'] = $joinColumnElement['columnDefinition'];
}

View File

@ -39,8 +39,8 @@ class ORMException extends Exception
{
return new self(
"Entity of type " . get_class($entity) . " has identity through a foreign entity " . get_class($relatedEntity) . ", " .
"however this entity has no ientity itself. You have to call EntityManager#persist() on the related entity " .
"and make sure it an identifier was generated before trying to persist '" . get_class($entity) . "'. In case " .
"however this entity has no identity itself. You have to call EntityManager#persist() on the related entity " .
"and make sure that an identifier was generated before trying to persist '" . get_class($entity) . "'. In case " .
"of Post Insert ID Generation (such as MySQL Auto-Increment or PostgreSQL SERIAL) this means you have to call " .
"EntityManager#flush() between both persist operations."
);

View File

@ -26,6 +26,7 @@ use PDO,
Doctrine\ORM\ORMException,
Doctrine\ORM\OptimisticLockException,
Doctrine\ORM\EntityManager,
Doctrine\ORM\UnitOfWork,
Doctrine\ORM\Query,
Doctrine\ORM\PersistentCollection,
Doctrine\ORM\Mapping\MappingException,
@ -1221,7 +1222,7 @@ class BasicEntityPersister
} else {
$conditionSql .= $this->_getSQLTableAlias($this->_class->name) . '.';
}
$conditionSql .= $this->_class->associationMappings[$field]['joinColumns'][0]['name'];
} else if ($assoc !== null && strpos($field, " ") === false && strpos($field, "(") === false) {
// very careless developers could potentially open up this normally hidden api for userland attacks,
@ -1232,6 +1233,7 @@ class BasicEntityPersister
} else {
throw ORMException::unrecognizedField($field);
}
$conditionSql .= (is_array($value)) ? ' IN (?)' : (($value === null) ? ' IS NULL' : ' = ?');
}
return $conditionSql;
@ -1321,18 +1323,96 @@ class BasicEntityPersister
continue; // skip null values.
}
$type = null;
if (isset($this->_class->fieldMappings[$field])) {
$types[] = $this->getType($field, $value);
$params[] = $this->getValue($value);
}
return array($params, $types);
}
/**
* Infer field type to be used by parameter type casting.
*
* @param string $field
* @param mixed $value
* @return integer
*/
private function getType($field, $value)
{
switch (true) {
case (isset($this->_class->fieldMappings[$field])):
$type = Type::getType($this->_class->fieldMappings[$field]['type'])->getBindingType();
}
if (is_array($value)) {
$type += Connection::ARRAY_PARAM_OFFSET;
break;
case (isset($this->_class->associationMappings[$field])):
$assoc = $this->_class->associationMappings[$field];
if (count($assoc['sourceToTargetKeyColumns']) > 1) {
throw Query\QueryException::associationPathCompositeKeyNotSupported();
}
$targetClass = $this->_em->getClassMetadata($assoc['targetEntity']);
$targetColumn = $assoc['joinColumns'][0]['referencedColumnName'];
$type = null;
if (isset($targetClass->fieldNames[$targetColumn])) {
$type = Type::getType($targetClass->fieldMappings[$targetClass->fieldNames[$targetColumn]]['type'])->getBindingType();
}
break;
default:
$type = null;
}
if (is_array($value)) {
$type += Connection::ARRAY_PARAM_OFFSET;
}
return $type;
}
/**
* Retrieve parameter value
*
* @param mixed $value
* @return mixed
*/
private function getValue($value)
{
if (is_array($value)) {
$newValue = array();
foreach ($value as $itemValue) {
$newValue[] = $this->getIndividualValue($itemValue);
}
$params[] = $value;
$types[] = $type;
return $newValue;
}
return array($params, $types);
return $this->getIndividualValue($value);
}
/**
* Retrieve an invidiual parameter value
*
* @param mixed $value
* @return mixed
*/
private function getIndividualValue($value)
{
if (is_object($value) && $this->_em->getMetadataFactory()->hasMetadataFor(get_class($value))) {
if ($this->_em->getUnitOfWork()->getEntityState($value) === UnitOfWork::STATE_MANAGED) {
$idValues = $this->_em->getUnitOfWork()->getEntityIdentifier($value);
} else {
$class = $this->_em->getClassMetadata(get_class($value));
$idValues = $class->getIdentifierValues($value);
}
$value = $idValues[key($idValues)];
}
return $value;
}
/**

View File

@ -124,28 +124,30 @@ class OneToManyPersister extends AbstractCollectionPersister
public function count(PersistentCollection $coll)
{
$mapping = $coll->getMapping();
$class = $this->_em->getClassMetadata($mapping['targetEntity']);
$targetClass = $this->_em->getClassMetadata($mapping['targetEntity']);
$sourceClass = $this->_em->getClassMetadata($mapping['sourceEntity']);
$params = array();
$id = $this->_em->getUnitOfWork()->getEntityIdentifier($coll->getOwner());
$where = '';
foreach ($class->associationMappings[$mapping['mappedBy']]['joinColumns'] AS $joinColumn) {
foreach ($targetClass->associationMappings[$mapping['mappedBy']]['joinColumns'] AS $joinColumn) {
if ($where != '') {
$where .= ' AND ';
}
$where .= 't.' . $joinColumn['name'] . " = ?";
if ($class->containsForeignIdentifier) {
$params[] = $id[$class->getFieldForColumn($joinColumn['referencedColumnName'])];
$where .= "t." . $joinColumn['name'] . " = ?";
if ($targetClass->containsForeignIdentifier) {
$params[] = $id[$sourceClass->getFieldForColumn($joinColumn['referencedColumnName'])];
} else {
$params[] = $id[$class->fieldNames[$joinColumn['referencedColumnName']]];
$params[] = $id[$sourceClass->fieldNames[$joinColumn['referencedColumnName']]];
}
}
$sql = "SELECT count(*) FROM " . $class->getQuotedTableName($this->_conn->getDatabasePlatform()) . " t WHERE " . $where;
$sql = "SELECT count(*) FROM " . $targetClass->getQuotedTableName($this->_conn->getDatabasePlatform()) . " t WHERE " . $where;
// Apply the filters
foreach($this->_em->getEnabledFilters() as $filter) {
if("" !== $filterExpr = $filter->addFilterConstraint($class, 't')) {
if("" !== $filterExpr = $filter->addFilterConstraint($targetClass, 't')) {
$sql .= ' AND (' . $filterExpr . ')';
}
}
@ -188,4 +190,4 @@ class OneToManyPersister extends AbstractCollectionPersister
return $uow->getEntityPersister($mapping['targetEntity'])
->exists($element, array($mapping['mappedBy'] => $id));
}
}
}

View File

@ -172,7 +172,7 @@ class ProxyFactory
}
if ($method->isPublic() && ! $method->isFinal() && ! $method->isStatic()) {
$methods .= PHP_EOL . ' public function ';
$methods .= "\n" . ' public function ';
if ($method->returnsReference()) {
$methods .= '&';
}
@ -208,10 +208,10 @@ class ProxyFactory
}
$methods .= $parameterString . ')';
$methods .= PHP_EOL . ' {' . PHP_EOL;
$methods .= ' $this->__load();' . PHP_EOL;
$methods .= "\n" . ' {' . "\n";
$methods .= ' $this->__load();' . "\n";
$methods .= ' return parent::' . $method->getName() . '(' . $argumentString . ');';
$methods .= PHP_EOL . ' }' . PHP_EOL;
$methods .= "\n" . ' }' . "\n";
}
}

View File

@ -0,0 +1,48 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* GeneralCaseExpression ::= "CASE" WhenClause {WhenClause}* "ELSE" ScalarExpression "END"
*
* @since 2.2
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
class GeneralCaseExpression extends Node
{
public $whenClauses = array();
public $elseScalarExpression = null;
public function __construct(array $whenClauses, $elseScalarExpression)
{
$this->whenClauses = $whenClauses;
$this->elseScalarExpression = $elseScalarExpression;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkGeneralCaseExpression($this);
}
}

View File

@ -20,7 +20,8 @@
namespace Doctrine\ORM\Query\AST;
/**
* InstanceOfExpression ::= IdentificationVariable ["NOT"] "INSTANCE" ["OF"] (AbstractSchemaName | InputParameter)
* InstanceOfExpression ::= IdentificationVariable ["NOT"] "INSTANCE" ["OF"] (InstanceOfParameter | "(" InstanceOfParameter {"," InstanceOfParameter}* ")")
* InstanceOfParameter ::= AbstractSchemaName | InputParameter
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org

View File

@ -0,0 +1,50 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* SimpleCaseExpression ::= "CASE" CaseOperand SimpleWhenClause {SimpleWhenClause}* "ELSE" ScalarExpression "END"
*
* @since 2.2
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
class SimpleCaseExpression extends Node
{
public $caseOperand = null;
public $simpleWhenClauses = array();
public $elseScalarExpression = null;
public function __construct($caseOperand, array $simpleWhenClauses, $elseScalarExpression)
{
$this->caseOperand = $caseOperand;
$this->simpleWhenClauses = $simpleWhenClauses;
$this->elseScalarExpression = $elseScalarExpression;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkSimpleCaseExpression($this);
}
}

View File

@ -0,0 +1,48 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* SimpleWhenClause ::= "WHEN" ScalarExpression "THEN" ScalarExpression
*
* @since 2.2
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
class SimpleWhenClause extends Node
{
public $caseScalarExpression = null;
public $thenScalarExpression = null;
public function __construct($caseScalarExpression, $thenScalarExpression)
{
$this->caseScalarExpression = $caseScalarExpression;
$this->thenScalarExpression = $thenScalarExpression;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkWhenClauseExpression($this);
}
}

View File

@ -0,0 +1,48 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Query\AST;
/**
* WhenClause ::= "WHEN" ConditionalExpression "THEN" ScalarExpression
*
* @since 2.2
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
*/
class WhenClause extends Node
{
public $caseConditionExpression = null;
public $thenScalarExpression = null;
public function __construct($caseConditionExpression, $thenScalarExpression)
{
$this->caseConditionExpression = $caseConditionExpression;
$this->thenScalarExpression = $thenScalarExpression;
}
public function dispatch($sqlWalker)
{
return $sqlWalker->walkWhenClauseExpression($this);
}
}

View File

@ -39,5 +39,6 @@ class Andx extends Composite
'Doctrine\ORM\Query\Expr\Comparison',
'Doctrine\ORM\Query\Expr\Func',
'Doctrine\ORM\Query\Expr\Orx',
'Doctrine\ORM\Query\Expr\Andx',
);
}

View File

@ -36,8 +36,9 @@ class Orx extends Composite
{
protected $_separator = ' OR ';
protected $_allowedClasses = array(
'Doctrine\ORM\Query\Expr\Andx',
'Doctrine\ORM\Query\Expr\Comparison',
'Doctrine\ORM\Query\Expr\Func',
'Doctrine\ORM\Query\Expr\Andx',
'Doctrine\ORM\Query\Expr\Orx',
);
}

View File

@ -67,46 +67,49 @@ class Lexer extends \Doctrine\Common\Lexer
const T_DELETE = 113;
const T_DESC = 114;
const T_DISTINCT = 115;
const T_EMPTY = 116;
const T_ESCAPE = 117;
const T_EXISTS = 118;
const T_FALSE = 119;
const T_FROM = 120;
const T_GROUP = 121;
const T_HAVING = 122;
const T_IN = 123;
const T_INDEX = 124;
const T_INNER = 125;
const T_INSTANCE = 126;
const T_IS = 127;
const T_JOIN = 128;
const T_LEADING = 129;
const T_LEFT = 130;
const T_LIKE = 131;
const T_MAX = 132;
const T_MEMBER = 133;
const T_MIN = 134;
const T_NOT = 135;
const T_NULL = 136;
const T_NULLIF = 137;
const T_OF = 138;
const T_OR = 139;
const T_ORDER = 140;
const T_OUTER = 141;
const T_SELECT = 142;
const T_SET = 143;
const T_SIZE = 144;
const T_SOME = 145;
const T_SUM = 146;
const T_TRAILING = 147;
const T_TRUE = 148;
const T_UPDATE = 149;
const T_WHEN = 150;
const T_WHERE = 151;
const T_WITH = 153;
const T_PARTIAL = 154;
const T_MOD = 155;
const T_ELSE = 116;
const T_EMPTY = 117;
const T_END = 118;
const T_ESCAPE = 119;
const T_EXISTS = 120;
const T_FALSE = 121;
const T_FROM = 122;
const T_GROUP = 123;
const T_HAVING = 124;
const T_IN = 125;
const T_INDEX = 126;
const T_INNER = 127;
const T_INSTANCE = 128;
const T_IS = 129;
const T_JOIN = 130;
const T_LEADING = 131;
const T_LEFT = 132;
const T_LIKE = 133;
const T_MAX = 134;
const T_MEMBER = 135;
const T_MIN = 136;
const T_NOT = 137;
const T_NULL = 138;
const T_NULLIF = 139;
const T_OF = 140;
const T_OR = 141;
const T_ORDER = 142;
const T_OUTER = 143;
const T_SELECT = 144;
const T_SET = 145;
const T_SIZE = 146;
const T_SOME = 147;
const T_SUM = 148;
const T_THEN = 149;
const T_TRAILING = 150;
const T_TRUE = 151;
const T_UPDATE = 152;
const T_WHEN = 153;
const T_WHERE = 154;
const T_WITH = 155;
const T_PARTIAL = 156;
const T_MOD = 157;
/**
* Creates a new query scanner object.
*

View File

@ -1342,10 +1342,7 @@ class Parser
}
/**
* OrderByItem ::= (ResultVariable | StateFieldPathExpression) ["ASC" | "DESC"]
*
* @todo Post 2.0 release. Support general SingleValuedPathExpression instead
* of only StateFieldPathExpression.
* OrderByItem ::= (ResultVariable | SingleValuedPathExpression) ["ASC" | "DESC"]
*
* @return \Doctrine\ORM\Query\AST\OrderByItem
*/
@ -1360,7 +1357,7 @@ class Parser
$token = $this->_lexer->lookahead;
$expr = $this->ResultVariable();
} else {
$expr = $this->StateFieldPathExpression();
$expr = $this->SingleValuedPathExpression();
}
$item = new AST\OrderByItem($expr);
@ -1624,7 +1621,7 @@ class Parser
/**
* ScalarExpression ::= SimpleArithmeticExpression | StringPrimary | DateTimePrimary |
* StateFieldPathExpression | BooleanPrimary | CaseExpression |
* EntityTypeExpression
* InstanceOfExpression
*
* @return mixed One of the possible expressions or subexpressions.
*/
@ -1659,9 +1656,9 @@ class Parser
if ($this->_isAggregateFunction($this->_lexer->lookahead['type'])) {
return $this->AggregateExpression();
} else {
return $this->FunctionDeclaration();
}
return $this->FunctionDeclaration();
} else if ($lookahead == Lexer::T_STRING) {
return $this->StringPrimary();
} else if ($lookahead == Lexer::T_INPUT_PARAMETER) {
@ -1674,25 +1671,42 @@ class Parser
}
}
/**
* CaseExpression ::= GeneralCaseExpression | SimpleCaseExpression | CoalesceExpression | NullifExpression
* GeneralCaseExpression ::= "CASE" WhenClause {WhenClause}* "ELSE" ScalarExpression "END"
* WhenClause ::= "WHEN" ConditionalExpression "THEN" ScalarExpression
* SimpleCaseExpression ::= "CASE" CaseOperand SimpleWhenClause {SimpleWhenClause}* "ELSE" ScalarExpression "END"
* CaseOperand ::= StateFieldPathExpression | TypeDiscriminator
* SimpleWhenClause ::= "WHEN" ScalarExpression "THEN" ScalarExpression
* CoalesceExpression ::= "COALESCE" "(" ScalarExpression {"," ScalarExpression}* ")"
* NullifExpression ::= "NULLIF" "(" ScalarExpression "," ScalarExpression ")"
*
* @return mixed One of the possible expressions or subexpressions.
*/
public function CaseExpression()
{
$lookahead = $this->_lexer->lookahead['type'];
// if "CASE" "WHEN" => GeneralCaseExpression
// else if "CASE" => SimpleCaseExpression
// [DONE] else if "COALESCE" => CoalesceExpression
// [DONE] else if "NULLIF" => NullifExpression
switch ($lookahead) {
case Lexer::T_NULLIF:
return $this->NullIfExpression();
case Lexer::T_COALESCE:
return $this->CoalesceExpression();
case Lexer::T_CASE:
$peek = $this->_lexer->peek();
return ($peek['type'] === Lexer::T_WHEN)
? $this->GeneralCaseExpression()
: $this->SimpleCaseExpression();
default:
$this->semanticalError('CaseExpression not yet supported.');
return null;
// Do nothing
break;
}
$this->syntaxError();
}
/**
@ -1722,7 +1736,7 @@ class Parser
/**
* NullIfExpression ::= "NULLIF" "(" ScalarExpression "," ScalarExpression ")"
*
* @return Doctrine\ORM\Query\AST\ExistsExpression
* @return Doctrine\ORM\Query\AST\NullIfExpression
*/
public function NullIfExpression()
{
@ -1737,6 +1751,80 @@ class Parser
return new AST\NullIfExpression($firstExpression, $secondExpression);
}
/**
* GeneralCaseExpression ::= "CASE" WhenClause {WhenClause}* "ELSE" ScalarExpression "END"
*
* @return Doctrine\ORM\Query\AST\GeneralExpression
*/
public function GeneralCaseExpression()
{
$this->match(Lexer::T_CASE);
// Process WhenClause (1..N)
$whenClauses = array();
do {
$whenClauses[] = $this->WhenClause();
} while ($this->_lexer->isNextToken(Lexer::T_WHEN));
$this->match(Lexer::T_ELSE);
$scalarExpression = $this->ScalarExpression();
$this->match(Lexer::T_END);
return new AST\GeneralCaseExpression($whenClauses, $scalarExpression);
}
/**
* SimpleCaseExpression ::= "CASE" CaseOperand SimpleWhenClause {SimpleWhenClause}* "ELSE" ScalarExpression "END"
* CaseOperand ::= StateFieldPathExpression | TypeDiscriminator
*/
public function SimpleCaseExpression()
{
$this->match(Lexer::T_CASE);
$caseOperand = $this->StateFieldPathExpression();
// Process SimpleWhenClause (1..N)
$simpleWhenClauses = array();
do {
$simpleWhenClauses[] = $this->SimpleWhenClause();
} while ($this->_lexer->isNextToken(Lexer::T_WHEN));
$this->match(Lexer::T_ELSE);
$scalarExpression = $this->ScalarExpression();
$this->match(Lexer::T_END);
return new AST\SimpleCaseExpression($caseOperand, $simpleWhenClauses, $scalarExpression);
}
/**
* WhenClause ::= "WHEN" ConditionalExpression "THEN" ScalarExpression
*
* @return Doctrine\ORM\Query\AST\WhenExpression
*/
public function WhenClause()
{
$this->match(Lexer::T_WHEN);
$conditionalExpression = $this->ConditionalExpression();
$this->match(Lexer::T_THEN);
return new AST\WhenClause($conditionalExpression, $this->ScalarExpression());
}
/**
* SimpleWhenClause ::= "WHEN" ScalarExpression "THEN" ScalarExpression
*
* @return Doctrine\ORM\Query\AST\SimpleWhenExpression
*/
public function SimpleWhenClause()
{
$this->match(Lexer::T_WHEN);
$conditionalExpression = $this->ScalarExpression();
$this->match(Lexer::T_THEN);
return new AST\SimpleWhenClause($conditionalExpression, $this->ScalarExpression());
}
/**
* SelectExpression ::=
@ -1782,7 +1870,7 @@ class Parser
$expression = $this->ScalarExpression();
} else if ($this->_isAggregateFunction($this->_lexer->lookahead['type'])) {
$expression = $this->AggregateExpression();
} else if (in_array ($lookaheadType, array(Lexer::T_CASE, Lexer::T_COALESCE, Lexer::T_NULLIF))) {
} else if (in_array($lookaheadType, array(Lexer::T_COALESCE, Lexer::T_NULLIF))) {
$expression = $this->CaseExpression();
} else {
// Shortcut: ScalarExpression => Function
@ -1797,10 +1885,13 @@ class Parser
$this->_lexer->lookahead['type'] == Lexer::T_STRING) {
// Shortcut: ScalarExpression => SimpleArithmeticExpression
$expression = $this->SimpleArithmeticExpression();
} else if ($this->_lexer->lookahead['type'] == Lexer::T_CASE) {
$expression = $this->CaseExpression();
} else {
$this->syntaxError('IdentificationVariable | StateFieldPathExpression'
. ' | AggregateExpression | "(" Subselect ")" | ScalarExpression',
$this->_lexer->lookahead);
$this->syntaxError(
'IdentificationVariable | StateFieldPathExpression | AggregateExpression | "(" Subselect ")" | ScalarExpression',
$this->_lexer->lookahead
);
}
if ($supportsAlias) {
@ -2290,7 +2381,7 @@ class Parser
/**
* ArithmeticPrimary ::= SingleValuedPathExpression | Literal | "(" SimpleArithmeticExpression ")"
* | FunctionsReturningNumerics | AggregateExpression | FunctionsReturningStrings
* | FunctionsReturningDatetime | IdentificationVariable
* | FunctionsReturningDatetime | IdentificationVariable | CaseExpression
*/
public function ArithmeticPrimary()
{
@ -2304,6 +2395,11 @@ class Parser
}
switch ($this->_lexer->lookahead['type']) {
case Lexer::T_COALESCE:
case Lexer::T_NULLIF:
case Lexer::T_CASE:
return $this->CaseExpression();
case Lexer::T_IDENTIFIER:
$peek = $this->_lexer->glimpse();
@ -2359,7 +2455,7 @@ class Parser
}
/**
* StringPrimary ::= StateFieldPathExpression | string | InputParameter | FunctionsReturningStrings | AggregateExpression
* StringPrimary ::= StateFieldPathExpression | string | InputParameter | FunctionsReturningStrings | AggregateExpression | CaseExpression
*/
public function StringPrimary()
{
@ -2382,6 +2478,8 @@ class Parser
return $this->InputParameter();
} else if ($this->_isAggregateFunction($this->_lexer->lookahead['type'])) {
return $this->AggregateExpression();
} else if (in_array($this->_lexer->lookahead['type'], array(Lexer::T_CASE, Lexer::T_COALESCE, Lexer::T_NULLIF))) {
return $this->CaseExpression();
}
$this->syntaxError('StateFieldPathExpression | string | InputParameter | FunctionsReturningStrings | AggregateExpression');
@ -2578,7 +2676,7 @@ class Parser
}
/**
* InstanceOfExpression ::= IdentificationVariable ["NOT"] "INSTANCE" ["OF"] (AbstractSchemaName | InputParameter)
* InstanceOfExpression ::= IdentificationVariable ["NOT"] "INSTANCE" ["OF"] (InstanceOfParameter | "(" InstanceOfParameter {"," InstanceOfParameter}* ")")
*
* @return \Doctrine\ORM\Query\AST\InstanceOfExpression
*/
@ -2592,22 +2690,50 @@ class Parser
}
$this->match(Lexer::T_INSTANCE);
$this->match(Lexer::T_OF);
$exprValues = array();
if ($this->_lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS)) {
$this->match(Lexer::T_OPEN_PARENTHESIS);
$exprValues[] = $this->InstanceOfParameter();
if ($this->_lexer->isNextToken(Lexer::T_OF)) {
$this->match(Lexer::T_OF);
while ($this->_lexer->isNextToken(Lexer::T_COMMA)) {
$this->match(Lexer::T_COMMA);
$exprValues[] = $this->InstanceOfParameter();
}
$this->match(Lexer::T_CLOSE_PARENTHESIS);
$instanceOfExpression->value = $exprValues;
return $instanceOfExpression;
}
if ($this->_lexer->isNextToken(Lexer::T_INPUT_PARAMETER)) {
$this->match(Lexer::T_INPUT_PARAMETER);
$exprValue = new AST\InputParameter($this->_lexer->token['value']);
} else {
$exprValue = $this->AliasIdentificationVariable();
}
$exprValues[] = $this->InstanceOfParameter();
$instanceOfExpression->value = $exprValue;
$instanceOfExpression->value = $exprValues;
return $instanceOfExpression;
}
/**
* InstanceOfParameter ::= AbstractSchemaName | InputParameter
*
* @return mixed
*/
public function InstanceOfParameter()
{
if ($this->_lexer->isNextToken(Lexer::T_INPUT_PARAMETER)) {
$this->match(Lexer::T_INPUT_PARAMETER);
return new AST\InputParameter($this->_lexer->token['value']);
}
return $this->AliasIdentificationVariable();
}
/**
* LikeExpression ::= StringExpression ["NOT"] "LIKE" (string | input_parameter) ["ESCAPE" char]

View File

@ -20,6 +20,7 @@
namespace Doctrine\ORM\Query;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
/**
* A ResultSetMappingBuilder uses the EntityManager to automatically populate entity fields
@ -52,21 +53,7 @@ class ResultSetMappingBuilder extends ResultSetMapping
public function addRootEntityFromClassMetadata($class, $alias, $renamedColumns = array())
{
$this->addEntityResult($class, $alias);
$classMetadata = $this->em->getClassMetadata($class);
if ($classMetadata->isInheritanceTypeSingleTable() || $classMetadata->isInheritanceTypeJoined()) {
throw new \InvalidArgumentException('ResultSetMapping builder does not currently support inheritance.');
}
$platform = $this->em->getConnection()->getDatabasePlatform();
foreach ($classMetadata->getColumnNames() AS $columnName) {
$propertyName = $classMetadata->getFieldName($columnName);
if (isset($renamedColumns[$columnName])) {
$columnName = $renamedColumns[$columnName];
}
if (isset($this->fieldMappings[$columnName])) {
throw new \InvalidArgumentException("The column '$columnName' conflicts with another column in the mapper.");
}
$this->addFieldResult($alias, $platform->getSQLResultCasing($columnName), $propertyName);
}
$this->addAllClassFields($class, $alias, $renamedColumns);
}
/**
@ -81,6 +68,14 @@ class ResultSetMappingBuilder extends ResultSetMapping
public function addJoinedEntityFromClassMetadata($class, $alias, $parentAlias, $relation, $renamedColumns = array())
{
$this->addJoinedEntityResult($class, $alias, $parentAlias, $relation);
$this->addAllClassFields($class, $alias, $renamedColumns);
}
/**
* Adds all fields of the given class to the result set mapping (columns and meta fields)
*/
protected function addAllClassFields($class, $alias, $renamedColumns = array())
{
$classMetadata = $this->em->getClassMetadata($class);
if ($classMetadata->isInheritanceTypeSingleTable() || $classMetadata->isInheritanceTypeJoined()) {
throw new \InvalidArgumentException('ResultSetMapping builder does not currently support inheritance.');
@ -96,5 +91,17 @@ class ResultSetMappingBuilder extends ResultSetMapping
}
$this->addFieldResult($alias, $platform->getSQLResultCasing($columnName), $propertyName);
}
foreach ($classMetadata->associationMappings AS $associationMapping) {
if ($associationMapping['isOwningSide'] && $associationMapping['type'] & ClassMetadataInfo::TO_ONE) {
foreach ($associationMapping['joinColumns'] AS $joinColumn) {
$columnName = $joinColumn['name'];
$renamedColumnName = isset($renamedColumns[$columnName]) ? $renamedColumns[$columnName] : $columnName;
if (isset($this->metaMappings[$renamedColumnName])) {
throw new \InvalidArgumentException("The column '$renamedColumnName' conflicts with another column in the mapper.");
}
$this->addMetaResult($alias, $platform->getSQLResultCasing($renamedColumnName), $platform->getSQLResultCasing($columnName));
}
}
}
}
}

View File

@ -493,20 +493,20 @@ class SqlWalker implements TreeWalker
$assoc = $class->associationMappings[$fieldName];
if ($assoc['isOwningSide']) {
// COMPOSITE KEYS NOT (YET?) SUPPORTED
if (count($assoc['sourceToTargetKeyColumns']) > 1) {
throw QueryException::associationPathCompositeKeyNotSupported();
}
if ($this->_useSqlTableAliases) {
$sql .= $this->getSQLTableAlias($class->table['name'], $dqlAlias) . '.';
}
$sql .= reset($assoc['targetToSourceKeyColumns']);
} else {
if ( ! $assoc['isOwningSide']) {
throw QueryException::associationPathInverseSideNotSupported();
}
// COMPOSITE KEYS NOT (YET?) SUPPORTED
if (count($assoc['sourceToTargetKeyColumns']) > 1) {
throw QueryException::associationPathCompositeKeyNotSupported();
}
if ($this->_useSqlTableAliases) {
$sql .= $this->getSQLTableAlias($class->table['name'], $dqlAlias) . '.';
}
$sql .= reset($assoc['targetToSourceKeyColumns']);
break;
default:
@ -524,9 +524,8 @@ class SqlWalker implements TreeWalker
*/
public function walkSelectClause($selectClause)
{
$sql = 'SELECT ' . (($selectClause->isDistinct) ? 'DISTINCT ' : '') . implode(
', ', array_map(array($this, 'walkSelectExpression'), $selectClause->selectExpressions)
);
$sql = 'SELECT ' . (($selectClause->isDistinct) ? 'DISTINCT ' : '');
$sqlSelectExpressions = array_filter(array_map(array($this, 'walkSelectExpression'), $selectClause->selectExpressions));
$addMetaColumns = ! $this->_query->getHint(Query::HINT_FORCE_PARTIAL_LOAD) &&
$this->_query->getHydrationMode() == Query::HYDRATE_OBJECT
@ -552,7 +551,8 @@ class SqlWalker implements TreeWalker
$tblAlias = $this->getSQLTableAlias($rootClass->table['name'], $dqlAlias);
$discrColumn = $rootClass->discriminatorColumn;
$columnAlias = $this->getSQLColumnAlias($discrColumn['name']);
$sql .= ", $tblAlias." . $discrColumn['name'] . ' AS ' . $columnAlias;
$sqlSelectExpressions[] = $tblAlias . '.' . $discrColumn['name'] . ' AS ' . $columnAlias;
$columnAlias = $this->_platform->getSQLResultCasing($columnAlias);
$this->_rsm->setDiscriminatorColumn($dqlAlias, $columnAlias);
@ -572,7 +572,9 @@ class SqlWalker implements TreeWalker
foreach ($assoc['targetToSourceKeyColumns'] as $srcColumn) {
$columnAlias = $this->getSQLColumnAlias($srcColumn);
$sql .= ", $sqlTableAlias." . $srcColumn . ' AS ' . $columnAlias;
$sqlSelectExpressions[] = $sqlTableAlias . '.' . $srcColumn . ' AS ' . $columnAlias;
$columnAlias = $this->_platform->getSQLResultCasing($columnAlias);
$this->_rsm->addMetaResult($dqlAlias, $this->_platform->getSQLResultCasing($columnAlias), $srcColumn, (isset($assoc['id']) && $assoc['id'] === true));
}
@ -587,7 +589,9 @@ class SqlWalker implements TreeWalker
if ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE) {
foreach ($assoc['targetToSourceKeyColumns'] as $srcColumn) {
$columnAlias = $this->getSQLColumnAlias($srcColumn);
$sql .= ', ' . $sqlTableAlias . '.' . $srcColumn . ' AS ' . $columnAlias;
$sqlSelectExpressions[] = $sqlTableAlias . '.' . $srcColumn . ' AS ' . $columnAlias;
$columnAlias = $this->_platform->getSQLResultCasing($columnAlias);
$this->_rsm->addMetaResult($dqlAlias, $this->_platform->getSQLResultCasing($columnAlias), $srcColumn, (isset($assoc['id']) && $assoc['id'] === true));
}
@ -596,6 +600,8 @@ class SqlWalker implements TreeWalker
}
}
}
$sql .= implode(', ', $sqlSelectExpressions);
return $sql;
}
@ -884,6 +890,32 @@ class SqlWalker implements TreeWalker
return $sql;
}
/**
* Walks down a CaseExpression AST node and generates the corresponding SQL.
*
* @param CoalesceExpression|NullIfExpression|GeneralCaseExpression|SimpleCaseExpression $expression
* @return string The SQL.
*/
public function walkCaseExpression($expression)
{
switch (true) {
case ($expression instanceof AST\CoalesceExpression):
return $this->walkCoalesceExpression($expression);
case ($expression instanceof AST\NullIfExpression):
return $this->walkNullIfExpression($expression);
case ($expression instanceof AST\GeneralCaseExpression):
return $this->walkGeneralCaseExpression($expression);
case ($expression instanceof AST\SimpleCaseExpression):
return $this->walkSimpleCaseExpression($expression);
default:
return '';
}
}
/**
* Walks down a CoalesceExpression AST node and generates the corresponding SQL.
*
@ -905,20 +937,6 @@ class SqlWalker implements TreeWalker
return $sql;
}
public function walkCaseExpression($expression)
{
switch (true) {
case ($expression instanceof AST\CoalesceExpression):
return $this->walkCoalesceExpression($expression);
case ($expression instanceof AST\NullIfExpression):
return $this->walkNullIfExpression($expression);
default:
return '';
}
}
/**
* Walks down a NullIfExpression AST node and generates the corresponding SQL.
*
@ -937,6 +955,46 @@ class SqlWalker implements TreeWalker
return 'NULLIF(' . $firstExpression . ', ' . $secondExpression . ')';
}
/**
* Walks down a GeneralCaseExpression AST node and generates the corresponding SQL.
*
* @param GeneralCaseExpression $generalCaseExpression
* @return string The SQL.
*/
public function walkGeneralCaseExpression(AST\GeneralCaseExpression $generalCaseExpression)
{
$sql = 'CASE';
foreach ($generalCaseExpression->whenClauses as $whenClause) {
$sql .= ' WHEN ' . $this->walkConditionalExpression($whenClause->caseConditionExpression);
$sql .= ' THEN ' . $this->walkSimpleArithmeticExpression($whenClause->thenScalarExpression);
}
$sql .= ' ELSE ' . $this->walkSimpleArithmeticExpression($generalCaseExpression->elseScalarExpression) . ' END';
return $sql;
}
/**
* Walks down a SimpleCaseExpression AST node and generates the corresponding SQL.
*
* @param SimpleCaseExpression $simpleCaseExpression
* @return string The SQL.
*/
public function walkSimpleCaseExpression($simpleCaseExpression)
{
$sql = 'CASE ' . $this->walkStateFieldPathExpression($simpleCaseExpression->caseOperand);
foreach ($simpleCaseExpression->simpleWhenClauses as $simpleWhenClause) {
$sql .= ' WHEN ' . $this->walkSimpleArithmeticExpression($simpleWhenClause->caseScalarExpression);
$sql .= ' THEN ' . $this->walkSimpleArithmeticExpression($simpleWhenClause->thenScalarExpression);
}
$sql .= ' ELSE ' . $this->walkSimpleArithmeticExpression($simpleCaseExpression->elseScalarExpression) . ' END';
return $sql;
}
/**
* Walks down a SelectExpression AST node and generates the corresponding SQL.
@ -950,36 +1008,35 @@ class SqlWalker implements TreeWalker
$expr = $selectExpression->expression;
if ($expr instanceof AST\PathExpression) {
if ($expr->type == AST\PathExpression::TYPE_STATE_FIELD) {
$fieldName = $expr->field;
$dqlAlias = $expr->identificationVariable;
$qComp = $this->_queryComponents[$dqlAlias];
$class = $qComp['metadata'];
if ( ! $selectExpression->fieldIdentificationVariable) {
$resultAlias = $fieldName;
} else {
$resultAlias = $selectExpression->fieldIdentificationVariable;
}
if ($class->isInheritanceTypeJoined()) {
$tableName = $this->_em->getUnitOfWork()->getEntityPersister($class->name)->getOwningTable($fieldName);
} else {
$tableName = $class->getTableName();
}
$sqlTableAlias = $this->getSQLTableAlias($tableName, $dqlAlias);
$columnName = $class->getQuotedColumnName($fieldName, $this->_platform);
$columnAlias = $this->getSQLColumnAlias($columnName);
$sql .= $sqlTableAlias . '.' . $columnName . ' AS ' . $columnAlias;
$columnAlias = $this->_platform->getSQLResultCasing($columnAlias);
$this->_rsm->addScalarResult($columnAlias, $resultAlias);
} else {
if ($expr->type !== AST\PathExpression::TYPE_STATE_FIELD) {
throw QueryException::invalidPathExpression($expr->type);
}
}
else if ($expr instanceof AST\AggregateExpression) {
$fieldName = $expr->field;
$dqlAlias = $expr->identificationVariable;
$qComp = $this->_queryComponents[$dqlAlias];
$class = $qComp['metadata'];
if ( ! $selectExpression->fieldIdentificationVariable) {
$resultAlias = $fieldName;
} else {
$resultAlias = $selectExpression->fieldIdentificationVariable;
}
if ($class->isInheritanceTypeJoined()) {
$tableName = $this->_em->getUnitOfWork()->getEntityPersister($class->name)->getOwningTable($fieldName);
} else {
$tableName = $class->getTableName();
}
$sqlTableAlias = $this->getSQLTableAlias($tableName, $dqlAlias);
$columnName = $class->getQuotedColumnName($fieldName, $this->_platform);
$columnAlias = $this->getSQLColumnAlias($columnName);
$sql .= $sqlTableAlias . '.' . $columnName . ' AS ' . $columnAlias;
$columnAlias = $this->_platform->getSQLResultCasing($columnAlias);
$this->_rsm->addScalarResult($columnAlias, $resultAlias);
} else if ($expr instanceof AST\AggregateExpression) {
if ( ! $selectExpression->fieldIdentificationVariable) {
$resultAlias = $this->_scalarResultCounter++;
} else {
@ -992,8 +1049,7 @@ class SqlWalker implements TreeWalker
$columnAlias = $this->_platform->getSQLResultCasing($columnAlias);
$this->_rsm->addScalarResult($columnAlias, $resultAlias);
}
else if ($expr instanceof AST\Subselect) {
} else if ($expr instanceof AST\Subselect) {
if ( ! $selectExpression->fieldIdentificationVariable) {
$resultAlias = $this->_scalarResultCounter++;
} else {
@ -1006,8 +1062,7 @@ class SqlWalker implements TreeWalker
$columnAlias = $this->_platform->getSQLResultCasing($columnAlias);
$this->_rsm->addScalarResult($columnAlias, $resultAlias);
}
else if ($expr instanceof AST\Functions\FunctionNode) {
} else if ($expr instanceof AST\Functions\FunctionNode) {
if ( ! $selectExpression->fieldIdentificationVariable) {
$resultAlias = $this->_scalarResultCounter++;
} else {
@ -1048,7 +1103,8 @@ class SqlWalker implements TreeWalker
} else if (
$expr instanceof AST\NullIfExpression ||
$expr instanceof AST\CoalesceExpression ||
$expr instanceof AST\CaseExpression
$expr instanceof AST\GeneralCaseExpression ||
$expr instanceof AST\SimpleCaseExpression
) {
if ( ! $selectExpression->fieldIdentificationVariable) {
$resultAlias = $this->_scalarResultCounter++;
@ -1752,34 +1808,41 @@ class SqlWalker implements TreeWalker
if ($this->_useSqlTableAliases) {
$sql .= $this->getSQLTableAlias($discrClass->table['name'], $dqlAlias) . '.';
}
$sql .= $class->discriminatorColumn['name'] . ($instanceOfExpr->not ? ' NOT IN ' : ' IN ');
$sqlParameterList = array();
foreach ($instanceOfExpr->value as $parameter) {
if ($parameter instanceof AST\InputParameter) {
// We need to modify the parameter value to be its correspondent mapped value
$dqlParamKey = $parameter->name;
$paramValue = $this->_query->getParameter($dqlParamKey);
$sql .= $class->discriminatorColumn['name'] . ($instanceOfExpr->not ? ' <> ' : ' = ');
if ( ! ($paramValue instanceof \Doctrine\ORM\Mapping\ClassMetadata)) {
throw QueryException::invalidParameterType('ClassMetadata', get_class($paramValue));
}
if ($instanceOfExpr->value instanceof AST\InputParameter) {
// We need to modify the parameter value to be its correspondent mapped value
$dqlParamKey = $instanceOfExpr->value->name;
$paramValue = $this->_query->getParameter($dqlParamKey);
if ( ! ($paramValue instanceof \Doctrine\ORM\Mapping\ClassMetadata)) {
throw QueryException::invalidParameterType('ClassMetadata', get_class($paramValue));
$entityClassName = $paramValue->name;
} else {
// Get name from ClassMetadata to resolve aliases.
$entityClassName = $this->_em->getClassMetadata($parameter)->name;
}
$entityClassName = $paramValue->name;
} else {
// Get name from ClassMetadata to resolve aliases.
$entityClassName = $this->_em->getClassMetadata($instanceOfExpr->value)->name;
}
if ($entityClassName == $class->name) {
$sql .= $this->_conn->quote($class->discriminatorValue);
} else {
$discrMap = array_flip($class->discriminatorMap);
if (!isset($discrMap[$entityClassName])) {
throw QueryException::instanceOfUnrelatedClass($entityClassName, $class->rootEntityName);
if ($entityClassName == $class->name) {
$sqlParameterList[] = $this->_conn->quote($class->discriminatorValue);
} else {
$discrMap = array_flip($class->discriminatorMap);
if (!isset($discrMap[$entityClassName])) {
throw QueryException::instanceOfUnrelatedClass($entityClassName, $class->rootEntityName);
}
$sqlParameterList[] = $this->_conn->quote($discrMap[$entityClassName]);
}
$sql .= $this->_conn->quote($discrMap[$entityClassName]);
}
$sql .= '(' . implode(', ', $sqlParameterList) . ')';
return $sql;
}

View File

@ -323,6 +323,8 @@ class QueryBuilder
*/
public function setParameter($key, $value, $type = null)
{
$key = trim($key, ':');
if ($type === null) {
$type = Query\ParameterTypeInferer::inferType($value);
}

View File

@ -248,7 +248,6 @@ class ConvertDoctrine1Schema
'name' => $relation['local'],
'referencedColumnName' => $relation['foreign'],
'onDelete' => isset($relation['onDelete']) ? $relation['onDelete'] : null,
'onUpdate' => isset($relation['onUpdate']) ? $relation['onUpdate'] : null,
)
);
}

View File

@ -302,7 +302,7 @@ public function <methodName>()
*/
public function setAnnotationPrefix($prefix)
{
if (version_compare(\Doctrine\Common\Version::VERSION, '3.0.0-DEV', '>=')) {
if (version_compare(\Doctrine\Common\Version::VERSION, '2.2.0-DEV', '>=')) {
return;
}
$this->_annotationsPrefix = $prefix;
@ -462,6 +462,14 @@ public function <methodName>()
private function _hasProperty($property, ClassMetadataInfo $metadata)
{
if ($this->_extendsClass()) {
// don't generate property if its already on the base class.
$reflClass = new \ReflectionClass($this->_getClassToExtend());
if ($reflClass->hasProperty($property)) {
return true;
}
}
return (
isset($this->_staticReflection[$metadata->name]) &&
in_array($property, $this->_staticReflection[$metadata->name]['properties'])
@ -470,6 +478,14 @@ public function <methodName>()
private function _hasMethod($method, ClassMetadataInfo $metadata)
{
if ($this->_extendsClass()) {
// don't generate method if its already on the base class.
$reflClass = new \ReflectionClass($this->_getClassToExtend());
if ($reflClass->hasMethod($method)) {
return true;
}
}
return (
isset($this->_staticReflection[$metadata->name]) &&
in_array($method, $this->_staticReflection[$metadata->name]['methods'])
@ -770,10 +786,6 @@ public function <methodName>()
$joinColumnAnnot[] = 'onDelete=' . ($joinColumn['onDelete'] ? 'true' : 'false');
}
if (isset($joinColumn['onUpdate'])) {
$joinColumnAnnot[] = 'onUpdate=' . ($joinColumn['onUpdate'] ? 'true' : 'false');
}
if (isset($joinColumn['columnDefinition'])) {
$joinColumnAnnot[] = 'columnDefinition="' . $joinColumn['columnDefinition'] . '"';
}

View File

@ -215,9 +215,6 @@ class XmlExporter extends AbstractExporter
if (isset($joinColumn['onDelete'])) {
$joinColumnXml->addAttribute('on-delete', $joinColumn['onDelete']);
}
if (isset($joinColumn['onUpdate'])) {
$joinColumnXml->addAttribute('on-update', $joinColumn['onUpdate']);
}
}
$inverseJoinColumnsXml = $joinTableXml->addChild('inverse-join-columns');
foreach ($associationMapping['joinTable']['inverseJoinColumns'] as $inverseJoinColumn) {
@ -227,9 +224,6 @@ class XmlExporter extends AbstractExporter
if (isset($inverseJoinColumn['onDelete'])) {
$inverseJoinColumnXml->addAttribute('on-delete', $inverseJoinColumn['onDelete']);
}
if (isset($inverseJoinColumn['onUpdate'])) {
$inverseJoinColumnXml->addAttribute('on-update', $inverseJoinColumn['onUpdate']);
}
if (isset($inverseJoinColumn['columnDefinition'])) {
$inverseJoinColumnXml->addAttribute('column-definition', $inverseJoinColumn['columnDefinition']);
}
@ -250,9 +244,6 @@ class XmlExporter extends AbstractExporter
if (isset($joinColumn['onDelete'])) {
$joinColumnXml->addAttribute('on-delete', $joinColumn['onDelete']);
}
if (isset($joinColumn['onUpdate'])) {
$joinColumnXml->addAttribute('on-update', $joinColumn['onUpdate']);
}
if (isset($joinColumn['columnDefinition'])) {
$joinColumnXml->addAttribute('column-definition', $joinColumn['columnDefinition']);
}

View File

@ -154,9 +154,6 @@ class YamlExporter extends AbstractExporter
if (isset($joinColumn['onDelete'])) {
$newJoinColumns[$joinColumn['name']]['onDelete'] = $joinColumn['onDelete'];
}
if (isset($joinColumn['onUpdate'])) {
$newJoinColumns[$joinColumn['name']]['onUpdate'] = $joinColumn['onUpdate'];
}
}
$oneToOneMappingArray = array(
'mappedBy' => $associationMapping['mappedBy'],

View File

@ -523,10 +523,6 @@ class SchemaTool
$uniqueConstraints[] = array('columns' => array($columnName));
}
if (isset($joinColumn['onUpdate'])) {
$fkOptions['onUpdate'] = $joinColumn['onUpdate'];
}
if (isset($joinColumn['onDelete'])) {
$fkOptions['onDelete'] = $joinColumn['onDelete'];
}

View File

@ -1456,7 +1456,8 @@ class UnitOfWork implements PropertyChangedListener
}
if ($assoc2['isCascadeMerge']) {
$managedCol->initialize();
if (!$managedCol->isEmpty()) {
// clear and set dirty a managed collection if its not also the same collection to merge from.
if (!$managedCol->isEmpty() && $managedCol != $mergeCol) {
$managedCol->unwrap()->clear();
$managedCol->setDirty(true);
if ($assoc2['isOwningSide'] && $assoc2['type'] == ClassMetadata::MANY_TO_MANY && $class->isChangeTrackingNotify()) {
@ -1655,6 +1656,10 @@ class UnitOfWork implements PropertyChangedListener
}
$relatedEntities = $class->reflFields[$assoc['fieldName']]->getValue($entity);
if ($relatedEntities instanceof Collection) {
if ($relatedEntities === $class->reflFields[$assoc['fieldName']]->getValue($managedCopy)) {
continue;
}
if ($relatedEntities instanceof PersistentCollection) {
// Unwrap so that foreach() does not initialize
$relatedEntities = $relatedEntities->unwrap();

@ -1 +1 @@
Subproject commit 40f1bf16e84ddc5291a6a63aa00b9879c40e3500
Subproject commit 74a2c924cd08b30785877808b1fb519b4b2e60b1

@ -1 +1 @@
Subproject commit 0127ee98a4301f2f6e3463c824adc3a3687f901f
Subproject commit be3790059cc43b674a55548eb42d5d25846ea6a9

View File

@ -27,6 +27,11 @@ class DDC117Article
*/
private $translations;
/**
* @OneToMany(targetEntity="DDC117Link", mappedBy="source")
*/
private $links;
public function __construct($title)
{
$this->title = $title;

View File

@ -0,0 +1,31 @@
<?php
namespace Doctrine\Tests\Models\DDC117;
/**
* Foreign Key Entity without additional fields!
*
* @Entity
*/
class DDC117Link
{
/**
* @Id
* @ManyToOne(targetEntity="DDC117Article", inversedBy="links")
* @JoinColumn(name="source_id", referencedColumnName="article_id")
*/
public $source;
/**
* @Id
* @ManyToOne(targetEntity="DDC117Article")
* @JoinColumn(name="target_id", referencedColumnName="article_id")
*/
public $target;
public function __construct($source, $target, $description)
{
$this->source = $source;
$this->target = $target;
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace Doctrine\Tests\Models\Legacy;
/**
* @Entity
* @Table(name="legacy_articles")
*/
class LegacyArticle
{
/**
* @Id
* @Column(name="iArticleId", type="integer")
* @GeneratedValue(strategy="AUTO")
*/
public $_id;
/**
* @Column(name="sTopic", type="string", length=255)
*/
public $_topic;
/**
* @Column(name="sText", type="text")
*/
public $_text;
/**
* @ManyToOne(targetEntity="LegacyUser", inversedBy="_articles")
* @JoinColumn(name="iUserId", referencedColumnName="iUserId")
*/
public $_user;
public function setAuthor(LegacyUser $author) {
$this->_user = $author;
}
}

View File

@ -0,0 +1,41 @@
<?php
namespace Doctrine\Tests\Models\Legacy;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @Entity
* @Table(name="legacy_cars")
*/
class LegacyCar
{
/**
* @Id
* @GeneratedValue
* @Column(name="iCarId", type="integer", nullable=false)
*/
public $_id;
/**
* @ManyToMany(targetEntity="LegacyUser", mappedBy="_cars")
*/
public $_users;
/**
* @Column(name="sDescription", type="string", length=255, unique=true)
*/
public $_description;
function getDescription()
{
return $this->_description;
}
public function addUser(LegacyUser $user) {
$this->_users[] = $user;
}
public function getUsers() {
return $this->_users;
}
}

View File

@ -0,0 +1,80 @@
<?php
namespace Doctrine\Tests\Models\Legacy;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @Entity
* @Table(name="legacy_users")
*/
class LegacyUser
{
/**
* @Id
* @GeneratedValue
* @Column(name="iUserId", type="integer", nullable=false)
*/
public $_id;
/**
* @Column(name="sUsername", type="string", length=255, unique=true)
*/
public $_username;
/**
* @Column(type="string", length=255)
*/
public $_name;
/**
* @OneToMany(targetEntity="LegacyArticle", mappedBy="_user")
*/
public $_articles;
/**
* @OneToMany(targetEntity="LegacyUserReference", mappedBy="_source", cascade={"remove"})
*/
public $_references;
/**
* @ManyToMany(targetEntity="LegacyCar", inversedBy="_users", cascade={"persist", "merge"})
* @JoinTable(name="legacy_users_cars",
* joinColumns={@JoinColumn(name="iUserId", referencedColumnName="iUserId")},
* inverseJoinColumns={@JoinColumn(name="iCarId", referencedColumnName="iCarId")}
* )
*/
public $_cars;
public function __construct() {
$this->_articles = new ArrayCollection;
$this->_references = new ArrayCollection;
$this->_cars = new ArrayCollection;
}
public function getId() {
return $this->_id;
}
public function getUsername() {
return $this->_username;
}
public function addArticle(LegacyArticle $article) {
$this->_articles[] = $article;
$article->setAuthor($this);
}
public function addReference($reference)
{
$this->_references[] = $reference;
}
public function references()
{
return $this->_references;
}
public function addCar(LegacyCar $car) {
$this->_cars[] = $car;
$car->addUser($this);
}
public function getCars() {
return $this->_cars;
}
}

View File

@ -0,0 +1,65 @@
<?php
namespace Doctrine\Tests\Models\Legacy;
/**
* @Entity
* @Table(name="legacy_users_reference")
*/
class LegacyUserReference
{
/**
* @Id
* @ManyToOne(targetEntity="LegacyUser", inversedBy="_references")
* @JoinColumn(name="iUserIdSource", referencedColumnName="iUserId")
*/
private $_source;
/**
* @Id
* @ManyToOne(targetEntity="LegacyUser", inversedBy="_references")
* @JoinColumn(name="iUserIdTarget", referencedColumnName="iUserId")
*/
private $_target;
/**
* @column(type="string")
*/
private $_description;
/**
* @column(type="datetime")
*/
private $_created;
public function __construct($source, $target, $description)
{
$source->addReference($this);
$target->addReference($this);
$this->_source = $source;
$this->_target = $target;
$this->_description = $description;
$this->_created = new \DateTime("now");
}
public function source()
{
return $this->_source;
}
public function target()
{
return $this->_target;
}
public function setDescription($desc)
{
$this->_description = $desc;
}
public function getDescription()
{
return $this->_description;
}
}

View File

@ -26,32 +26,32 @@ class EntityManagerTest extends \Doctrine\Tests\OrmTestCase
public function testGetConnection()
{
$this->assertInstanceOf('\Doctrine\DBAL\Connection', $this->_em->getConnection());
$this->assertInstanceOf('Doctrine\DBAL\Connection', $this->_em->getConnection());
}
public function testGetMetadataFactory()
{
$this->assertInstanceOf('\Doctrine\ORM\Mapping\ClassMetadataFactory', $this->_em->getMetadataFactory());
$this->assertInstanceOf('Doctrine\ORM\Mapping\ClassMetadataFactory', $this->_em->getMetadataFactory());
}
public function testGetConfiguration()
{
$this->assertInstanceOf('\Doctrine\ORM\Configuration', $this->_em->getConfiguration());
$this->assertInstanceOf('Doctrine\ORM\Configuration', $this->_em->getConfiguration());
}
public function testGetUnitOfWork()
{
$this->assertInstanceOf('\Doctrine\ORM\UnitOfWork', $this->_em->getUnitOfWork());
$this->assertInstanceOf('Doctrine\ORM\UnitOfWork', $this->_em->getUnitOfWork());
}
public function testGetProxyFactory()
{
$this->assertInstanceOf('\Doctrine\ORM\Proxy\ProxyFactory', $this->_em->getProxyFactory());
$this->assertInstanceOf('Doctrine\ORM\Proxy\ProxyFactory', $this->_em->getProxyFactory());
}
public function testGetEventManager()
{
$this->assertInstanceOf('\Doctrine\Common\EventManager', $this->_em->getEventManager());
$this->assertInstanceOf('Doctrine\Common\EventManager', $this->_em->getEventManager());
}
public function testCreateNativeQuery()
@ -64,7 +64,7 @@ class EntityManagerTest extends \Doctrine\Tests\OrmTestCase
public function testCreateQueryBuilder()
{
$this->assertInstanceOf('\Doctrine\ORM\QueryBuilder', $this->_em->createQueryBuilder());
$this->assertInstanceOf('Doctrine\ORM\QueryBuilder', $this->_em->createQueryBuilder());
}
public function testCreateQueryBuilderAliasValid()
@ -83,7 +83,7 @@ class EntityManagerTest extends \Doctrine\Tests\OrmTestCase
public function testCreateQuery_DqlIsOptional()
{
$this->assertInstanceOf('\Doctrine\ORM\Query', $this->_em->createQuery());
$this->assertInstanceOf('Doctrine\ORM\Query', $this->_em->createQuery());
}
public function testGetPartialReference()
@ -97,7 +97,7 @@ class EntityManagerTest extends \Doctrine\Tests\OrmTestCase
public function testCreateQuery()
{
$q = $this->_em->createQuery('SELECT 1');
$this->assertInstanceOf('\Doctrine\ORM\Query', $q);
$this->assertInstanceOf('Doctrine\ORM\Query', $q);
$this->assertEquals('SELECT 1', $q->getDql());
}

View File

@ -64,8 +64,8 @@ class AdvancedAssociationTest extends \Doctrine\Tests\OrmFunctionalTestCase
$query = $this->_em->createQuery("SELECT p,t FROM Doctrine\Tests\ORM\Functional\Phrase p JOIN p.type t");
$res = $query->getResult();
$this->assertEquals(1, count($res));
$this->assertTrue($res[0]->getType() instanceof PhraseType);
$this->assertTrue($res[0]->getType()->getPhrases() instanceof \Doctrine\ORM\PersistentCollection);
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\PhraseType', $res[0]->getType());
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $res[0]->getType()->getPhrases());
$this->assertFalse($res[0]->getType()->getPhrases()->isInitialized());
$this->_em->clear();
@ -74,8 +74,8 @@ class AdvancedAssociationTest extends \Doctrine\Tests\OrmFunctionalTestCase
$query = $this->_em->createQuery("SELECT p,t,pp FROM Doctrine\Tests\ORM\Functional\Phrase p JOIN p.type t JOIN t.phrases pp");
$res = $query->getResult();
$this->assertEquals(1, count($res));
$this->assertTrue($res[0]->getType() instanceof PhraseType);
$this->assertTrue($res[0]->getType()->getPhrases() instanceof \Doctrine\ORM\PersistentCollection);
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\PhraseType', $res[0]->getType());
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $res[0]->getType()->getPhrases());
$this->assertTrue($res[0]->getType()->getPhrases()->isInitialized());
$this->_em->clear();
@ -83,8 +83,8 @@ class AdvancedAssociationTest extends \Doctrine\Tests\OrmFunctionalTestCase
// test3 - lazy-loading one-to-many after find()
$phrase3 = $this->_em->find('Doctrine\Tests\ORM\Functional\Phrase', $phrase->getId());
$definitions = $phrase3->getDefinitions();
$this->assertTrue($definitions instanceof \Doctrine\ORM\PersistentCollection);
$this->assertTrue($definitions[0] instanceof Definition);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $definitions);
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Definition', $definitions[0]);
$this->_em->clear();
@ -95,7 +95,7 @@ class AdvancedAssociationTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertEquals(1, count($res));
$this->assertTrue($definitions[0] instanceof Definition);
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Definition', $definitions[0]);
$this->assertEquals(2, $definitions->count());
}
@ -119,7 +119,7 @@ class AdvancedAssociationTest extends \Doctrine\Tests\OrmFunctionalTestCase
$res = $query->getResult();
$types = $res[0]->getTypes();
$this->assertTrue($types[0] instanceof Type);
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Type', $types[0]);
}
}

View File

@ -46,7 +46,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->flush();
$this->assertTrue($this->_em->contains($ph));
$this->assertTrue($this->_em->contains($user));
//$this->assertTrue($user->phonenumbers instanceof \Doctrine\ORM\PersistentCollection);
//$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $user->phonenumbers);
// Update name
$user->name = 'guilherme';
@ -92,7 +92,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->persist($user);
$this->_em->flush();
//$this->assertTrue($user->phonenumbers instanceof \Doctrine\ORM\PersistentCollection);
//$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $user->phonenumbers);
// Remove the first element from the collection
unset($user->phonenumbers[0]);
@ -136,8 +136,8 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
->getSingleResult();
// Address has been eager-loaded because it cant be lazy
$this->assertTrue($user2->address instanceof CmsAddress);
$this->assertFalse($user2->address instanceof \Doctrine\ORM\Proxy\Proxy);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $user2->address);
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $user2->address);
}
/**
@ -276,7 +276,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertEquals('Guilherme', $users[0]->name);
$this->assertEquals('gblanco', $users[0]->username);
$this->assertEquals('developer', $users[0]->status);
$this->assertTrue($users[0]->phonenumbers instanceof \Doctrine\ORM\PersistentCollection);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $users[0]->phonenumbers);
$this->assertTrue($users[0]->phonenumbers->isInitialized());
$this->assertEquals(0, $users[0]->phonenumbers->count());
//$this->assertNull($users[0]->articles);
@ -520,8 +520,8 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$query = $this->_em->createQuery("select u, a from Doctrine\Tests\Models\CMS\CmsUser u join u.address a where u.username='gblanco'");
$gblanco = $query->getSingleResult();
$this->assertTrue($gblanco instanceof CmsUser);
$this->assertTrue($gblanco->getAddress() instanceof CmsAddress);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $gblanco);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $gblanco->getAddress());
$this->assertEquals('Berlin', $gblanco->getAddress()->getCity());
}
@ -629,7 +629,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$user2 = $query->getSingleResult();
$this->assertEquals(1, count($user2->articles));
$this->assertTrue($user2->address instanceof CmsAddress);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $user2->address);
$oldLogger = $this->_em->getConnection()->getConfiguration()->getSQLLogger();
$debugStack = new \Doctrine\DBAL\Logging\DebugStack;
@ -690,7 +690,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
->setParameter('user', $userRef)
->getSingleResult();
$this->assertTrue($address2->getUser() instanceof \Doctrine\ORM\Proxy\Proxy);
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $address2->getUser());
$this->assertTrue($userRef === $address2->getUser());
$this->assertFalse($userRef->__isInitialized__);
$this->assertEquals('Germany', $address2->country);
@ -905,7 +905,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->clear();
$user2 = $this->_em->find(get_class($managedUser), $userId);
$this->assertTrue($user2 instanceof CmsUser);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $user2);
}
public function testMergeThrowsExceptionIfEntityWithGeneratedIdentifierDoesNotExist()

View File

@ -50,8 +50,8 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$entities = $query->getResult();
$this->assertEquals(2, count($entities));
$this->assertTrue($entities[0] instanceof CompanyPerson);
$this->assertTrue($entities[1] instanceof CompanyEmployee);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyPerson', $entities[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $entities[1]);
$this->assertTrue(is_numeric($entities[0]->getId()));
$this->assertTrue(is_numeric($entities[1]->getId()));
$this->assertEquals('Roman S. Borschel', $entities[0]->getName());
@ -65,7 +65,7 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$entities = $query->getResult();
$this->assertEquals(1, count($entities));
$this->assertTrue($entities[0] instanceof CompanyEmployee);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $entities[0]);
$this->assertTrue(is_numeric($entities[0]->getId()));
$this->assertEquals('Guilherme Blanco', $entities[0]->getName());
$this->assertEquals(100000, $entities[0]->getSalary());
@ -73,7 +73,7 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->clear();
$guilherme = $this->_em->getRepository(get_class($employee))->findOneBy(array('name' => 'Guilherme Blanco'));
$this->assertTrue($guilherme instanceof CompanyEmployee);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $guilherme);
$this->assertEquals('Guilherme Blanco', $guilherme->getName());
$this->_em->clear();
@ -110,7 +110,7 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$manager = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $manager->getId());
$this->assertTrue($manager instanceof CompanyManager);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyManager', $manager);
$this->assertEquals('Roman B.', $manager->getName());
$this->assertEquals(119000, $manager->getSalary());
$this->assertEquals('CEO', $manager->getTitle());
@ -130,12 +130,12 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$person = $this->_em->find('Doctrine\Tests\Models\Company\CompanyPerson', $manager->getId());
$this->assertTrue($person instanceof CompanyManager);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyManager', $person);
$this->assertEquals('Roman S. Borschel', $person->getName());
$this->assertEquals(100000, $person->getSalary());
$this->assertEquals('CTO', $person->getTitle());
$this->assertTrue(is_numeric($person->getId()));
//$this->assertTrue($person->getCar() instanceof CompanyCar);
//$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyCar', $person->getCar());
}
public function testSelfReferencingOneToOne() {
@ -167,9 +167,9 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$result = $query->getResult();
$this->assertEquals(1, count($result));
$this->assertTrue($result[0] instanceof CompanyPerson);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyPerson', $result[0]);
$this->assertEquals('Mary Smith', $result[0]->getName());
$this->assertTrue($result[0]->getSpouse() instanceof CompanyEmployee);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $result[0]->getSpouse());
$this->assertEquals('John Smith', $result[0]->getSpouse()->getName());
$this->assertSame($result[0], $result[0]->getSpouse()->getSpouse());
}
@ -229,20 +229,20 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$result = $q->getResult();
$this->assertEquals(1, count($result));
$this->assertTrue($result[0] instanceof CompanyOrganization);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyOrganization', $result[0]);
$this->assertNull($result[0]->getMainEvent());
$events = $result[0]->getEvents();
$this->assertTrue($events instanceof \Doctrine\ORM\PersistentCollection);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $events);
$this->assertFalse($events->isInitialized());
$this->assertEquals(2, count($events));
if ($events[0] instanceof CompanyAuction) {
$this->assertTrue($events[1] instanceof CompanyRaffle);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyRaffle', $events[1]);
} else {
$this->assertTrue($events[0] instanceof CompanyRaffle);
$this->assertTrue($events[1] instanceof CompanyAuction);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyRaffle', $events[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyAuction', $events[1]);
}
}
@ -263,7 +263,7 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$result = $q->getResult();
$this->assertEquals(1, count($result));
$this->assertTrue($result[0] instanceof CompanyAuction, sprintf("Is of class %s",get_class($result[0])));
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyAuction', $result[0], sprintf("Is of class %s",get_class($result[0])));
$this->_em->clear();
@ -273,12 +273,12 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$result = $q->getResult();
$this->assertEquals(1, count($result));
$this->assertTrue($result[0] instanceof CompanyOrganization);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyOrganization', $result[0]);
$mainEvent = $result[0]->getMainEvent();
// mainEvent should have been loaded because it can't be lazy
$this->assertTrue($mainEvent instanceof CompanyAuction);
$this->assertFalse($mainEvent instanceof \Doctrine\ORM\Proxy\Proxy);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyAuction', $mainEvent);
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $mainEvent);
}
/**

View File

@ -43,9 +43,9 @@ class ClassTableInheritanceTest2 extends \Doctrine\Tests\OrmFunctionalTestCase
$related2 = $this->_em->find('Doctrine\Tests\ORM\Functional\CTIRelated', $relatedId);
$this->assertTrue($related2 instanceof CTIRelated);
$this->assertTrue($related2->getCTIParent() instanceof CTIChild);
$this->assertFalse($related2->getCTIParent() instanceof \Doctrine\ORM\Proxy\Proxy);
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\CTIRelated', $related2);
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\CTIChild', $related2->getCTIParent());
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $related2->getCTIParent());
$this->assertEquals('hello', $related2->getCTIParent()->getData());
$this->assertSame($related2, $related2->getCTIParent()->getRelated());
@ -69,7 +69,7 @@ class ClassTableInheritanceTest2 extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertFalse($mmrel2->getCTIChildren()->isInitialized());
$this->assertEquals(1, count($mmrel2->getCTIChildren()));
$this->assertTrue($mmrel2->getCTIChildren()->isInitialized());
$this->assertTrue($mmrel2->getCTIChildren()->get(0) instanceof CTIChild);
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\CTIChild', $mmrel2->getCTIChildren()->get(0));
}
}

View File

@ -45,7 +45,7 @@ class CompositePrimaryKeyTest extends \Doctrine\Tests\OrmFunctionalTestCase
$poi = $this->_em->find('Doctrine\Tests\Models\Navigation\NavPointOfInterest', array('lat' => 100, 'long' => 200));
$this->assertType('Doctrine\Tests\Models\Navigation\NavPointOfInterest', $poi);
$this->assertInstanceOf('Doctrine\Tests\Models\Navigation\NavPointOfInterest', $poi);
$this->assertEquals(100, $poi->getLat());
$this->assertEquals(200, $poi->getLong());
$this->assertEquals('Brandenburger Tor', $poi->getName());

View File

@ -50,7 +50,7 @@ class DefaultValuesTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->clear();
$a2 = $this->_em->find(get_class($a), $a->id);
$this->assertTrue($a2->getUser() instanceof DefaultValueUser);
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\DefaultValueUser', $a2->getUser());
$this->assertEquals($userId, $a2->getUser()->getId());
$this->assertEquals('Poweruser', $a2->getUser()->type);
}

View File

@ -137,14 +137,14 @@ class DetachedEntityTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->clear();
$address2 = $this->_em->find(get_class($address), $address->id);
$this->assertTrue($address2->user instanceof \Doctrine\ORM\Proxy\Proxy);
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $address2->user);
$this->assertFalse($address2->user->__isInitialized__);
$detachedAddress2 = unserialize(serialize($address2));
$this->assertTrue($detachedAddress2->user instanceof \Doctrine\ORM\Proxy\Proxy);
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $detachedAddress2->user);
$this->assertFalse($detachedAddress2->user->__isInitialized__);
$managedAddress2 = $this->_em->merge($detachedAddress2);
$this->assertTrue($managedAddress2->user instanceof \Doctrine\ORM\Proxy\Proxy);
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $managedAddress2->user);
$this->assertFalse($managedAddress2->user === $detachedAddress2->user);
$this->assertFalse($managedAddress2->user->__isInitialized__);
}

View File

@ -3,8 +3,8 @@
namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\Models\CMS\CmsPhonenumber;
use Doctrine\Tests\Models\CMS\CmsAddress;
use Doctrine\Tests\Models\CMS\CmsPhonenumber;
require_once __DIR__ . '/../../TestInit.php';
@ -18,6 +18,12 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
parent::setUp();
}
public function tearDown()
{
$this->_em->getConfiguration()->setEntityNamespaces(array());
parent::tearDown();
}
public function loadFixture()
{
$user = new CmsUser;
@ -33,13 +39,66 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->persist($user2);
$this->_em->flush();
$user1Id = $user->getId();
unset($user);
unset($user2);
$this->_em->clear();
return $user1Id;
}
public function loadAssociatedFixture()
{
$address = new CmsAddress();
$address->city = "Berlin";
$address->country = "Germany";
$address->street = "Foostreet";
$address->zip = "12345";
$user = new CmsUser();
$user->name = 'Roman';
$user->username = 'romanb';
$user->status = 'freak';
$user->setAddress($address);
$this->_em->persist($user);
$this->_em->persist($address);
$this->_em->flush();
$this->_em->clear();
return array($user->id, $address->id);
}
public function buildUser($name, $username, $status, $address)
{
$user = new CmsUser();
$user->name = $name;
$user->username = $username;
$user->status = $status;
$user->setAddress($address);
$this->_em->persist($user);
$this->_em->flush();
return $user;
}
public function buildAddress($country, $city, $street, $zip)
{
$address = new CmsAddress();
$address->country = $country;
$address->city = $city;
$address->street = $street;
$address->zip = $zip;
$this->_em->persist($address);
$this->_em->flush();
return $address;
}
public function testBasicFind()
{
@ -47,7 +106,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
$user = $repos->find($user1Id);
$this->assertTrue($user instanceof CmsUser);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser',$user);
$this->assertEquals('Roman', $user->name);
$this->assertEquals('freak', $user->status);
}
@ -59,11 +118,58 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$users = $repos->findBy(array('status' => 'dev'));
$this->assertEquals(1, count($users));
$this->assertTrue($users[0] instanceof CmsUser);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser',$users[0]);
$this->assertEquals('Guilherme', $users[0]->name);
$this->assertEquals('dev', $users[0]->status);
}
public function testFindByAssociationWithIntegerAsParameter()
{
$address1 = $this->buildAddress('Germany', 'Berlim', 'Foo st.', '123456');
$user1 = $this->buildUser('Benjamin', 'beberlei', 'dev', $address1);
$address2 = $this->buildAddress('Brazil', 'São Paulo', 'Bar st.', '654321');
$user2 = $this->buildUser('Guilherme', 'guilhermeblanco', 'freak', $address2);
$address3 = $this->buildAddress('USA', 'Nashville', 'Woo st.', '321654');
$user3 = $this->buildUser('Jonathan', 'jwage', 'dev', $address3);
unset($address1);
unset($address2);
unset($address3);
$this->_em->clear();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress');
$addresses = $repository->findBy(array('user' => array($user1->getId(), $user2->getId())));
$this->assertEquals(2, count($addresses));
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress',$addresses[0]);
}
public function testFindByAssociationWithObjectAsParameter()
{
$address1 = $this->buildAddress('Germany', 'Berlim', 'Foo st.', '123456');
$user1 = $this->buildUser('Benjamin', 'beberlei', 'dev', $address1);
$address2 = $this->buildAddress('Brazil', 'São Paulo', 'Bar st.', '654321');
$user2 = $this->buildUser('Guilherme', 'guilhermeblanco', 'freak', $address2);
$address3 = $this->buildAddress('USA', 'Nashville', 'Woo st.', '321654');
$user3 = $this->buildUser('Jonathan', 'jwage', 'dev', $address3);
unset($address1);
unset($address2);
unset($address3);
$this->_em->clear();
$repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress');
$addresses = $repository->findBy(array('user' => array($user1, $user2)));
$this->assertEquals(2, count($addresses));
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress',$addresses[0]);
}
public function testFindFieldByMagicCall()
{
@ -72,7 +178,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$users = $repos->findByStatus('dev');
$this->assertEquals(1, count($users));
$this->assertTrue($users[0] instanceof CmsUser);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser',$users[0]);
$this->assertEquals('Guilherme', $users[0]->name);
$this->assertEquals('dev', $users[0]->status);
}
@ -99,12 +205,6 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertEquals(2, count($users));
}
public function tearDown()
{
$this->_em->getConfiguration()->setEntityNamespaces(array());
parent::tearDown();
}
/**
* @expectedException \Doctrine\ORM\ORMException
*/
@ -201,28 +301,6 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$repos->foo();
}
public function loadAssociatedFixture()
{
$address = new CmsAddress();
$address->city = "Berlin";
$address->country = "Germany";
$address->street = "Foostreet";
$address->zip = "12345";
$user = new CmsUser();
$user->name = 'Roman';
$user->username = 'romanb';
$user->status = 'freak';
$user->setAddress($address);
$this->_em->persist($user);
$this->_em->persist($address);
$this->_em->flush();
$this->_em->clear();
return array($user->id, $address->id);
}
/**
* @group DDC-817
*/
@ -244,7 +322,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress');
$address = $repos->findOneBy(array('user' => $userId));
$this->assertType('Doctrine\Tests\Models\CMS\CmsAddress', $address);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $address);
$this->assertEquals($addressId, $address->id);
}
@ -285,7 +363,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress');
$address = $repos->findOneByUser($userId);
$this->assertType('Doctrine\Tests\Models\CMS\CmsAddress', $address);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $address);
$this->assertEquals($addressId, $address->id);
}
@ -295,7 +373,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$query = $repos->createNamedQuery('all');
$this->assertType('Doctrine\ORM\Query', $query);
$this->assertInstanceOf('Doctrine\ORM\Query', $query);
$this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $query->getDQL());
}

View File

@ -47,7 +47,7 @@ class ManyToManyBasicAssociationTest extends \Doctrine\Tests\OrmFunctionalTestCa
$result = $query->getResult();
$this->assertEquals(2, $this->_em->getUnitOfWork()->size());
$this->assertTrue($result[0] instanceof CmsUser);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]);
$this->assertEquals('Guilherme', $result[0]->name);
$this->assertEquals(1, $result[0]->getGroups()->count());
$groups = $result[0]->getGroups();
@ -56,8 +56,8 @@ class ManyToManyBasicAssociationTest extends \Doctrine\Tests\OrmFunctionalTestCa
$this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($result[0]));
$this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($groups[0]));
$this->assertTrue($groups instanceof \Doctrine\ORM\PersistentCollection);
$this->assertTrue($groups[0]->getUsers() instanceof \Doctrine\ORM\PersistentCollection);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $groups);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $groups[0]->getUsers());
$groups[0]->getUsers()->clear();
$groups->clear();

View File

@ -117,8 +117,8 @@ class ManyToManyBidirectionalAssociationTest extends AbstractManyToManyAssociati
//$query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true);
$result = $query->getResult();
$this->assertEquals(2, count($result));
$this->assertTrue($result[0] instanceof ECommerceCategory);
$this->assertTrue($result[1] instanceof ECommerceCategory);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $result[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $result[1]);
$prods1 = $result[0]->getProducts();
$prods2 = $result[1]->getProducts();
$this->assertTrue($prods1->isInitialized());
@ -157,10 +157,10 @@ class ManyToManyBidirectionalAssociationTest extends AbstractManyToManyAssociati
$this->assertEquals(2, count($secondCategoryProducts)); // lazy-load
$this->assertTrue($secondCategoryProducts->isInitialized());
$this->assertTrue($firstCategoryProducts[0] instanceof ECommerceProduct);
$this->assertTrue($firstCategoryProducts[1] instanceof ECommerceProduct);
$this->assertTrue($secondCategoryProducts[0] instanceof ECommerceProduct);
$this->assertTrue($secondCategoryProducts[1] instanceof ECommerceProduct);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $firstCategoryProducts[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $firstCategoryProducts[1]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $secondCategoryProducts[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $secondCategoryProducts[1]);
$this->assertCollectionEquals($firstCategoryProducts, $secondCategoryProducts);
}
@ -192,10 +192,10 @@ class ManyToManyBidirectionalAssociationTest extends AbstractManyToManyAssociati
$this->assertEquals(2, count($secondProductCategories)); // lazy-load
$this->assertTrue($secondProductCategories->isInitialized());
$this->assertTrue($firstProductCategories[0] instanceof ECommerceCategory);
$this->assertTrue($firstProductCategories[1] instanceof ECommerceCategory);
$this->assertTrue($secondProductCategories[0] instanceof ECommerceCategory);
$this->assertTrue($secondProductCategories[1] instanceof ECommerceCategory);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $firstProductCategories[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $firstProductCategories[1]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $secondProductCategories[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $secondProductCategories[1]);
$this->assertCollectionEquals($firstProductCategories, $secondProductCategories);
}

View File

@ -95,10 +95,10 @@ class ManyToManySelfReferentialAssociationTest extends AbstractManyToManyAssocia
$this->assertEquals(2, count($firstRelatedBy));
$this->assertEquals(2, count($secondRelatedBy));
$this->assertTrue($firstRelatedBy[0] instanceof ECommerceProduct);
$this->assertTrue($firstRelatedBy[1] instanceof ECommerceProduct);
$this->assertTrue($secondRelatedBy[0] instanceof ECommerceProduct);
$this->assertTrue($secondRelatedBy[1] instanceof ECommerceProduct);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $firstRelatedBy[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $firstRelatedBy[1]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $secondRelatedBy[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $secondRelatedBy[1]);
$this->assertCollectionEquals($firstRelatedBy, $secondRelatedBy);
}

View File

@ -69,8 +69,8 @@ class ManyToManyUnidirectionalAssociationTest extends AbstractManyToManyAssociat
$products = $firstCart->getProducts();
$secondCart = $result[1];
$this->assertTrue($products[0] instanceof ECommerceProduct);
$this->assertTrue($products[1] instanceof ECommerceProduct);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $products[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $products[1]);
$this->assertCollectionEquals($products, $secondCart->getProducts());
//$this->assertEquals("Doctrine 1.x Manual", $products[0]->getName());
//$this->assertEquals("Doctrine 2.x Manual", $products[1]->getName());
@ -88,8 +88,8 @@ class ManyToManyUnidirectionalAssociationTest extends AbstractManyToManyAssociat
$products = $firstCart->getProducts();
$secondCart = $result[1];
$this->assertTrue($products[0] instanceof ECommerceProduct);
$this->assertTrue($products[1] instanceof ECommerceProduct);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $products[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $products[1]);
$this->assertCollectionEquals($products, $secondCart->getProducts());
}

View File

@ -38,9 +38,9 @@ class MappedSuperclassTest extends \Doctrine\Tests\OrmFunctionalTestCase
$cleanFile = $this->_em->find(get_class($file), $file->getId());
$this->assertType('Doctrine\Tests\Models\DirectoryTree\Directory', $cleanFile->getParent());
$this->assertInstanceOf('Doctrine\Tests\Models\DirectoryTree\Directory', $cleanFile->getParent());
$this->assertEquals($directory->getId(), $cleanFile->getParent()->getId());
$this->assertType('Doctrine\Tests\Models\DirectoryTree\Directory', $cleanFile->getParent()->getParent());
$this->assertInstanceOf('Doctrine\Tests\Models\DirectoryTree\Directory', $cleanFile->getParent()->getParent());
$this->assertEquals($root->getId(), $cleanFile->getParent()->getParent()->getId());
}
}

View File

@ -49,9 +49,51 @@ class NativeQueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$users = $query->getResult();
$this->assertEquals(1, count($users));
$this->assertTrue($users[0] instanceof CmsUser);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]);
$this->assertEquals('Roman', $users[0]->name);
}
public function testBasicNativeQueryWithMetaResult()
{
$user = new CmsUser;
$user->name = 'Roman';
$user->username = 'romanb';
$user->status = 'dev';
$addr = new CmsAddress;
$addr->country = 'germany';
$addr->zip = 10827;
$addr->city = 'Berlin';
$user->setAddress($addr);
$this->_em->persist($user);
$this->_em->flush();
$this->_em->clear();
$rsm = new ResultSetMapping;
$rsm->addEntityResult('Doctrine\Tests\Models\CMS\CmsAddress', 'a');
$rsm->addFieldResult('a', $this->platform->getSQLResultCasing('id'), 'id');
$rsm->addFieldResult('a', $this->platform->getSQLResultCasing('country'), 'country');
$rsm->addFieldResult('a', $this->platform->getSQLResultCasing('zip'), 'zip');
$rsm->addFieldResult('a', $this->platform->getSQLResultCasing('city'), 'city');
$rsm->addMetaResult('a', $this->platform->getSQLResultCasing('user_id'), 'user_id');
$query = $this->_em->createNativeQuery('SELECT a.id, a.country, a.zip, a.city, a.user_id FROM cms_addresses a WHERE a.id = ?', $rsm);
$query->setParameter(1, $addr->id);
$addresses = $query->getResult();
$this->assertEquals(1, count($addresses));
$this->assertTrue($addresses[0] instanceof CmsAddress);
$this->assertEquals($addr->country, $addresses[0]->country);
$this->assertEquals($addr->zip, $addresses[0]->zip);
$this->assertEquals($addr->city, $addresses[0]->city);
$this->assertEquals($addr->street, $addresses[0]->street);
$this->assertTrue($addresses[0]->user instanceof CmsUser);
}
public function testJoinedOneToManyNativeQuery()
{
@ -83,9 +125,9 @@ class NativeQueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$users = $query->getResult();
$this->assertEquals(1, count($users));
$this->assertTrue($users[0] instanceof CmsUser);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]);
$this->assertEquals('Roman', $users[0]->name);
$this->assertTrue($users[0]->getPhonenumbers() instanceof \Doctrine\ORM\PersistentCollection);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $users[0]->getPhonenumbers());
$this->assertTrue($users[0]->getPhonenumbers()->isInitialized());
$this->assertEquals(1, count($users[0]->getPhonenumbers()));
$phones = $users[0]->getPhonenumbers();
@ -132,11 +174,11 @@ class NativeQueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$users = $query->getResult();
$this->assertEquals(1, count($users));
$this->assertTrue($users[0] instanceof CmsUser);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]);
$this->assertEquals('Roman', $users[0]->name);
$this->assertTrue($users[0]->getPhonenumbers() instanceof \Doctrine\ORM\PersistentCollection);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $users[0]->getPhonenumbers());
$this->assertFalse($users[0]->getPhonenumbers()->isInitialized());
$this->assertTrue($users[0]->getAddress() instanceof CmsAddress);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $users[0]->getAddress());
$this->assertTrue($users[0]->getAddress()->getUser() == $users[0]);
$this->assertEquals('germany', $users[0]->getAddress()->getCountry());
$this->assertEquals(10827, $users[0]->getAddress()->getZipCode());
@ -185,14 +227,25 @@ class NativeQueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$users = $query->getResult();
$this->assertEquals(1, count($users));
$this->assertTrue($users[0] instanceof CmsUser);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]);
$this->assertEquals('Roman', $users[0]->name);
$this->assertTrue($users[0]->getPhonenumbers() instanceof \Doctrine\ORM\PersistentCollection);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $users[0]->getPhonenumbers());
$this->assertTrue($users[0]->getPhonenumbers()->isInitialized());
$this->assertEquals(1, count($users[0]->getPhonenumbers()));
$phones = $users[0]->getPhonenumbers();
$this->assertEquals(424242, $phones[0]->phonenumber);
$this->assertTrue($phones[0]->getUser() === $users[0]);
$this->_em->clear();
$rsm = new ResultSetMappingBuilder($this->_em);
$rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber', 'p');
$query = $this->_em->createNativeQuery('SELECT p.* FROM cms_phonenumbers p WHERE p.phonenumber = ?', $rsm);
$query->setParameter(1, $phone->phonenumber);
$phone = $query->getSingleResult();
$this->assertNotNull($phone->getUser());
$this->assertEquals($user->name, $phone->getUser()->getName());
}
public function testJoinedOneToOneNativeQueryWithRSMBuilder()
@ -226,15 +279,26 @@ class NativeQueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$users = $query->getResult();
$this->assertEquals(1, count($users));
$this->assertTrue($users[0] instanceof CmsUser);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]);
$this->assertEquals('Roman', $users[0]->name);
$this->assertTrue($users[0]->getPhonenumbers() instanceof \Doctrine\ORM\PersistentCollection);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $users[0]->getPhonenumbers());
$this->assertFalse($users[0]->getPhonenumbers()->isInitialized());
$this->assertTrue($users[0]->getAddress() instanceof CmsAddress);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $users[0]->getAddress());
$this->assertTrue($users[0]->getAddress()->getUser() == $users[0]);
$this->assertEquals('germany', $users[0]->getAddress()->getCountry());
$this->assertEquals(10827, $users[0]->getAddress()->getZipCode());
$this->assertEquals('Berlin', $users[0]->getAddress()->getCity());
$this->_em->clear();
$rsm = new ResultSetMappingBuilder($this->_em);
$rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress', 'a');
$query = $this->_em->createNativeQuery('SELECT a.* FROM cms_addresses a WHERE a.id = ?', $rsm);
$query->setParameter(1, $addr->getId());
$address = $query->getSingleResult();
$this->assertNotNull($address->getUser());
$this->assertEquals($user->name, $address->getUser()->getName());
}
/**

View File

@ -77,13 +77,13 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
$features = $product->getFeatures();
$this->assertTrue($features[0] instanceof ECommerceFeature);
$this->assertFalse($features[0]->getProduct() instanceof \Doctrine\ORM\Proxy\Proxy);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $features[0]);
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $features[0]->getProduct());
$this->assertSame($product, $features[0]->getProduct());
$this->assertEquals('Model writing tutorial', $features[0]->getDescription());
$this->assertTrue($features[1] instanceof ECommerceFeature);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $features[1]);
$this->assertSame($product, $features[1]->getProduct());
$this->assertFalse($features[1]->getProduct() instanceof \Doctrine\ORM\Proxy\Proxy);
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $features[1]->getProduct());
$this->assertEquals('Annotations examples', $features[1]->getDescription());
}
@ -97,11 +97,11 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
$features = $product->getFeatures();
$this->assertFalse($features->isInitialized());
$this->assertTrue($features[0] instanceof ECommerceFeature);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $features[0]);
$this->assertTrue($features->isInitialized());
$this->assertSame($product, $features[0]->getProduct());
$this->assertEquals('Model writing tutorial', $features[0]->getDescription());
$this->assertTrue($features[1] instanceof ECommerceFeature);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceFeature', $features[1]);
$this->assertSame($product, $features[1]->getProduct());
$this->assertEquals('Annotations examples', $features[1]->getDescription());
}
@ -114,8 +114,8 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
$features = $query->getResult();
$product = $features[0]->getProduct();
$this->assertTrue($product instanceof \Doctrine\ORM\Proxy\Proxy);
$this->assertTrue($product instanceof ECommerceProduct);
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $product);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $product);
$this->assertFalse($product->__isInitialized__);
$this->assertSame('Doctrine Cookbook', $product->getName());
$this->assertTrue($product->__isInitialized__);
@ -130,8 +130,8 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
$features = $query->getResult();
$product = $features[0]->getProduct();
$this->assertFalse($product instanceof \Doctrine\ORM\Proxy\Proxy);
$this->assertTrue($product instanceof ECommerceProduct);
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $product);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $product);
$this->assertSame('Doctrine Cookbook', $product->getName());
$this->assertFalse($product->getFeatures()->isInitialized());

View File

@ -79,10 +79,10 @@ class OneToManySelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunctio
$parent = $result[0];
$children = $parent->getChildren();
$this->assertTrue($children[0] instanceof ECommerceCategory);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $children[0]);
$this->assertSame($parent, $children[0]->getParent());
$this->assertEquals(' books', strstr($children[0]->getName(), ' books'));
$this->assertTrue($children[1] instanceof ECommerceCategory);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $children[1]);
$this->assertSame($parent, $children[1]->getParent());
$this->assertEquals(' books', strstr($children[1]->getName(), ' books'));
}
@ -98,10 +98,10 @@ class OneToManySelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunctio
$parent = $result[0];
$children = $parent->getChildren();
$this->assertTrue($children[0] instanceof ECommerceCategory);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $children[0]);
$this->assertSame($parent, $children[0]->getParent());
$this->assertEquals(' books', strstr($children[0]->getName(), ' books'));
$this->assertTrue($children[1] instanceof ECommerceCategory);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $children[1]);
$this->assertSame($parent, $children[1]->getParent());
$this->assertEquals(' books', strstr($children[1]->getName(), ' books'));
}

View File

@ -62,7 +62,7 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional
$result = $query->getResult();
$customer = $result[0];
$this->assertTrue($customer->getCart() instanceof ECommerceCart);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCart', $customer->getCart());
$this->assertEquals('paypal', $customer->getCart()->getPayment());
}
@ -75,7 +75,7 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional
$result = $query->getResult();
$cart = $result[0];
$this->assertTrue($cart->getCustomer() instanceof ECommerceCustomer);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCustomer', $cart->getCustomer());
$this->assertEquals('Giorgio', $cart->getCustomer()->getName());
}
@ -90,8 +90,8 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional
$customer = $result[0];
$this->assertNull($customer->getMentor());
$this->assertTrue($customer->getCart() instanceof ECommerceCart);
$this->assertFalse($customer->getCart() instanceof \Doctrine\ORM\Proxy\Proxy);
$this->assertInstanceOF('Doctrine\Tests\Models\ECommerce\ECommerceCart', $customer->getCart());
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $customer->getCart());
$this->assertEquals('paypal', $customer->getCart()->getPayment());
}
@ -107,7 +107,7 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional
$this->_em->flush();
$this->_em->clear();
$this->assertTrue($cust->getCart() instanceof ECommerceCart);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCart', $cust->getCart());
$this->assertEquals('Roman', $cust->getName());
$this->assertSame($cust, $cart->getCustomer());
@ -126,7 +126,7 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional
$cart3 = $query2->getSingleResult();
$this->assertTrue($cart3->getCustomer() instanceof ECommerceCustomer);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCustomer', $cart3->getCustomer());
$this->assertEquals('Roman', $cart3->getCustomer()->getName());
}

View File

@ -104,8 +104,8 @@ class OneToOneSelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunction
$entity2 = $this->_em->find(get_class($entity1), $entity1->getId());
$this->assertTrue($entity2->getOther1() instanceof MultiSelfReference);
$this->assertTrue($entity2->getOther2() instanceof MultiSelfReference);
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\MultiSelfReference', $entity2->getOther1());
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\MultiSelfReference', $entity2->getOther2());
$this->assertNull($entity2->getOther1()->getOther1());
$this->assertNull($entity2->getOther1()->getOther2());
$this->assertNull($entity2->getOther2()->getOther1());
@ -114,7 +114,7 @@ class OneToOneSelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunction
public function assertLoadingOfAssociation($customer)
{
$this->assertTrue($customer->getMentor() instanceof ECommerceCustomer);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCustomer', $customer->getMentor());
$this->assertEquals('Obi-wan Kenobi', $customer->getMentor()->getName());
}

View File

@ -56,7 +56,7 @@ class OneToOneUnidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
$result = $query->getResult();
$product = $result[0];
$this->assertTrue($product->getShipping() instanceof ECommerceShipping);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceShipping', $product->getShipping());
$this->assertEquals(1, $product->getShipping()->getDays());
}
@ -69,7 +69,7 @@ class OneToOneUnidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
$result = $query->getResult();
$product = $result[0];
$this->assertTrue($product->getShipping() instanceof ECommerceShipping);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceShipping', $product->getShipping());
$this->assertEquals(1, $product->getShipping()->getDays());
}

View File

@ -38,7 +38,7 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$result = $query->getResult();
$this->assertEquals(1, count($result));
$this->assertTrue($result[0][0] instanceof CmsUser);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][0]);
$this->assertEquals('Guilherme', $result[0][0]->name);
$this->assertEquals('gblanco', $result[0][0]->username);
$this->assertEquals('developer', $result[0][0]->status);
@ -90,7 +90,7 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$query = $this->_em->createQuery("select u, a from Doctrine\Tests\Models\CMS\CmsUser u join u.articles a");
$users = $query->getResult();
$this->assertEquals(1, count($users));
$this->assertTrue($users[0] instanceof CmsUser);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]);
$this->assertEquals(2, count($users[0]->articles));
$this->assertEquals('Doctrine 2', $users[0]->articles[0]->topic);
$this->assertEquals('Symfony 2', $users[0]->articles[1]->topic);
@ -361,9 +361,9 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$result = $q->getResult();
$this->assertEquals(1, count($result));
$this->assertTrue($result[0] instanceof CmsArticle);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[0]);
$this->assertEquals("dr. dolittle", $result[0]->topic);
$this->assertTrue($result[0]->user instanceof \Doctrine\ORM\Proxy\Proxy);
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $result[0]->user);
$this->assertFalse($result[0]->user->__isInitialized__);
}

View File

@ -64,7 +64,7 @@ class StandardEntityPersisterTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->flush();
$this->assertEquals(2, count($p->getFeatures()));
$this->assertTrue($p->getFeatures() instanceof \Doctrine\ORM\PersistentCollection);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $p->getFeatures());
$q = $this->_em->createQuery(
'SELECT p, f
@ -75,7 +75,7 @@ class StandardEntityPersisterTest extends \Doctrine\Tests\OrmFunctionalTestCase
$res = $q->getResult();
$this->assertEquals(2, count($p->getFeatures()));
$this->assertTrue($p->getFeatures() instanceof \Doctrine\ORM\PersistentCollection);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $p->getFeatures());
// Check that the features are the same instances still
foreach ($p->getFeatures() as $feature) {

View File

@ -0,0 +1,85 @@
<?php
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Tests\Models\CMS\CmsEmployee;
require_once __DIR__ . '/../../../TestInit.php';
/**
* @group DDC-1225
*/
class DDC1225Test extends \Doctrine\Tests\OrmFunctionalTestCase
{
public function setUp()
{
parent::setUp();
try {
$this->_schemaTool->createSchema(array(
$this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1225_TestEntity1'),
$this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1225_TestEntity2'),
));
} catch(\PDOException $e) {
}
}
public function testIssue()
{
$qb = $this->_em->createQueryBuilder();
$qb->from('Doctrine\Tests\ORM\Functional\Ticket\DDC1225_TestEntity1', 'te1')
->select('te1')
->where('te1.testEntity2 = ?1')
->setParameter(1, 0);
$this->assertEquals(
'SELECT t0_.test_entity2_id AS test_entity2_id0 FROM te1 t0_ WHERE t0_.test_entity2_id = ?',
$qb->getQuery()->getSQL()
);
}
}
/**
* @Entity
* @Table(name="te1")
*/
class DDC1225_TestEntity1
{
/**
* @Id
* @ManyToOne(targetEntity="Doctrine\Tests\ORM\Functional\Ticket\DDC1225_TestEntity2")
* @JoinColumn(name="test_entity2_id", referencedColumnName="id", nullable=false)
*/
private $testEntity2;
/**
* @param DDC1225_TestEntity2 $testEntity2
*/
public function setTestEntity2(DDC1225_TestEntity2 $testEntity2)
{
$this->testEntity2 = $testEntity2;
}
/**
* @return DDC1225_TestEntity2
*/
public function getTestEntity2()
{
return $this->testEntity2;
}
}
/**
* @Entity
* @Table(name="te2")
*/
class DDC1225_TestEntity2
{
/**
* @Id
* @GeneratedValue(strategy="AUTO")
* @Column(type="integer")
*/
private $id;
}

View File

@ -0,0 +1,50 @@
<?php
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\Models\CMS\CmsGroup;
require_once __DIR__ . '/../../../TestInit.php';
/**
* @group DDC-1276
*/
class DDC1276Test extends \Doctrine\Tests\OrmFunctionalTestCase
{
public function setUp()
{
$this->useModelSet('cms');
parent::setUp();
}
public function testIssue()
{
$user = new CmsUser();
$user->name = "Benjamin";
$user->username = "beberlei";
$user->status = "active";
$this->_em->persist($user);
for ($i = 0; $i < 2; $i++) {
$group = new CmsGroup();
$group->name = "group".$i;
$user->groups[] = $group;
$this->_em->persist($group);
}
$this->_em->flush();
$this->_em->clear();
$user = $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $user->id);
$cloned = clone $user;
$this->assertSame($user->groups, $cloned->groups);
$this->assertEquals(2, count($user->groups));
$this->_em->merge($cloned);
$this->assertEquals(2, count($user->groups));
$this->_em->flush();
}
}

View File

@ -0,0 +1,108 @@
<?php
namespace Doctrine\Tests\ORM\Functional\Ticket;
require_once __DIR__ . '/../../../TestInit.php';
/**
* @group DDC-1300
*/
class DDC1300Test extends \Doctrine\Tests\OrmFunctionalTestCase
{
public function setUp()
{
parent::setUp();
$this->_schemaTool->createSchema(array(
$this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1300Foo'),
$this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1300FooLocale'),
));
}
public function testIssue()
{
$foo = new DDC1300Foo();
$foo->_fooReference = "foo";
$this->_em->persist($foo);
$this->_em->flush();
$locale = new DDC1300FooLocale();
$locale->_foo = $foo;
$locale->_locale = "en";
$locale->_title = "blub";
$this->_em->persist($locale);
$this->_em->flush();
$query = $this->_em->createQuery('SELECT f, fl FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1300Foo f JOIN f._fooLocaleRefFoo fl');
$result = $query->getResult();
$this->assertEquals(1, count($result));
}
}
/**
* @Entity
*/
class DDC1300Foo
{
/**
* @var integer fooID
* @Column(name="fooID", type="integer", nullable=false)
* @GeneratedValue(strategy="AUTO")
* @Id
*/
public $_fooID = null;
/**
* @var string fooReference
* @Column(name="fooReference", type="string", nullable=true, length=45)
*/
public $_fooReference = null;
/**
* @OneToMany(targetEntity="DDC1300FooLocale", mappedBy="_foo",
* cascade={"persist"})
*/
public $_fooLocaleRefFoo = null;
/**
* Constructor
*
* @param array|Zend_Config|null $options
* @return Bug_Model_Foo
*/
public function __construct($options = null)
{
$this->_fooLocaleRefFoo = new \Doctrine\Common\Collections\ArrayCollection();
}
}
/**
* @Entity
*/
class DDC1300FooLocale
{
/**
* @ManyToOne(targetEntity="DDC1300Foo")
* @JoinColumn(name="fooID", referencedColumnName="fooID")
* @Id
*/
public $_foo = null;
/**
* @var string locale
* @Column(name="locale", type="string", nullable=false, length=5)
* @Id
*/
public $_locale = null;
/**
* @var string title
* @Column(name="title", type="string", nullable=true, length=150)
*/
public $_title = null;
}

View File

@ -0,0 +1,148 @@
<?php
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
require_once __DIR__ . '/../../../TestInit.php';
/**
* @author asm89
*/
class DDC1301Test extends \Doctrine\Tests\OrmFunctionalTestCase
{
private $userId;
public function setUp()
{
$this->useModelSet('legacy');
parent::setUp();
$class = $this->_em->getClassMetadata('Doctrine\Tests\Models\Legacy\LegacyUser');
$class->associationMappings['_articles']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY;
$class->associationMappings['_references']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY;
$class->associationMappings['_cars']['fetch'] = ClassMetadataInfo::FETCH_EXTRA_LAZY;
$this->loadFixture();
}
public function tearDown()
{
parent::tearDown();
$class = $this->_em->getClassMetadata('Doctrine\Tests\Models\Legacy\LegacyUser');
$class->associationMappings['_articles']['fetch'] = ClassMetadataInfo::FETCH_LAZY;
$class->associationMappings['_references']['fetch'] = ClassMetadataInfo::FETCH_LAZY;
$class->associationMappings['_cars']['fetch'] = ClassMetadataInfo::FETCH_LAZY;
}
public function testCountNotInitializesLegacyCollection()
{
$user = $this->_em->find('Doctrine\Tests\Models\Legacy\LegacyUser', $this->userId);
$queryCount = $this->getCurrentQueryCount();
$this->assertFalse($user->_articles->isInitialized());
$this->assertEquals(2, count($user->_articles));
$this->assertFalse($user->_articles->isInitialized());
foreach ($user->_articles AS $article) { }
$this->assertEquals($queryCount + 2, $this->getCurrentQueryCount(), "Expecting two queries to be fired for count, then iteration.");
}
public function testCountNotInitializesLegacyCollectionWithForeignIdentifier()
{
$user = $this->_em->find('Doctrine\Tests\Models\Legacy\LegacyUser', $this->userId);
$queryCount = $this->getCurrentQueryCount();
$this->assertFalse($user->_references->isInitialized());
$this->assertEquals(2, count($user->_references));
$this->assertFalse($user->_references->isInitialized());
foreach ($user->_references AS $reference) { }
$this->assertEquals($queryCount + 2, $this->getCurrentQueryCount(), "Expecting two queries to be fired for count, then iteration.");
}
public function testCountNotInitializesLegacyManyToManyCollection()
{
$user = $this->_em->find('Doctrine\Tests\Models\Legacy\LegacyUser', $this->userId);
$queryCount = $this->getCurrentQueryCount();
$this->assertFalse($user->_cars->isInitialized());
$this->assertEquals(3, count($user->_cars));
$this->assertFalse($user->_cars->isInitialized());
foreach ($user->_cars AS $reference) { }
$this->assertEquals($queryCount + 2, $this->getCurrentQueryCount(), "Expecting two queries to be fired for count, then iteration.");
}
public function loadFixture()
{
$user1 = new \Doctrine\Tests\Models\Legacy\LegacyUser();
$user1->_username = "beberlei";
$user1->_name = "Benjamin";
$user1->_status = "active";
$user2 = new \Doctrine\Tests\Models\Legacy\LegacyUser();
$user2->_username = "jwage";
$user2->_name = "Jonathan";
$user2->_status = "active";
$user3 = new \Doctrine\Tests\Models\Legacy\LegacyUser();
$user3->_username = "romanb";
$user3->_name = "Roman";
$user3->_status = "active";
$this->_em->persist($user1);
$this->_em->persist($user2);
$this->_em->persist($user3);
$article1 = new \Doctrine\Tests\Models\Legacy\LegacyArticle();
$article1->_topic = "Test";
$article1->_text = "Test";
$article1->setAuthor($user1);
$article2 = new \Doctrine\Tests\Models\Legacy\LegacyArticle();
$article2->_topic = "Test";
$article2->_text = "Test";
$article2->setAuthor($user1);
$this->_em->persist($article1);
$this->_em->persist($article2);
$car1 = new \Doctrine\Tests\Models\Legacy\LegacyCar();
$car1->_description = "Test1";
$car2 = new \Doctrine\Tests\Models\Legacy\LegacyCar();
$car2->_description = "Test2";
$car3 = new \Doctrine\Tests\Models\Legacy\LegacyCar();
$car3->_description = "Test3";
$user1->addCar($car1);
$user1->addCar($car2);
$user1->addCar($car3);
$user2->addCar($car1);
$user3->addCar($car1);
$this->_em->persist($car1);
$this->_em->persist($car2);
$this->_em->persist($car3);
$this->_em->flush();
$detail1 = new \Doctrine\Tests\Models\Legacy\LegacyUserReference($user1, $user2, "foo");
$detail2 = new \Doctrine\Tests\Models\Legacy\LegacyUserReference($user1, $user3, "bar");
$this->_em->persist($detail1);
$this->_em->persist($detail2);
$this->_em->flush();
$this->_em->clear();
$this->userId = $user1->getId();
}
}

View File

@ -58,7 +58,7 @@ class DDC168Test extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertEquals("bar", $theEmployee->getDepartment());
$this->assertEquals("Foo", $theEmployee->getName());
$this->assertEquals(1000, $theEmployee->getSalary());
$this->assertTrue($theEmployee instanceof CompanyEmployee);
$this->assertTrue($theEmployee->getSpouse() instanceof CompanyEmployee);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $theEmployee);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $theEmployee->getSpouse());
}
}

View File

@ -40,11 +40,11 @@ class DDC199Test extends \Doctrine\Tests\OrmFunctionalTestCase
$result = $query->getResult();
$this->assertEquals(1, count($result));
$this->assertTrue($result[0] instanceof DDC199ChildClass);
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\DDC199ParentClass', $result[0]);
$this->assertTrue($result[0]->relatedEntities->isInitialized());
$this->assertEquals(2, $result[0]->relatedEntities->count());
$this->assertTrue($result[0]->relatedEntities[0] instanceof DDC199RelatedClass);
$this->assertTrue($result[0]->relatedEntities[1] instanceof DDC199RelatedClass);
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\DDC199RelatedClass', $result[0]->relatedEntities[0]);
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\DDC199RelatedClass', $result[0]->relatedEntities[1]);
}
}

View File

@ -37,7 +37,7 @@ class DDC237Test extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->clear();
$x2 = $this->_em->find(get_class($x), $x->id); // proxy injected for Y
$this->assertTrue($x2->y instanceof \Doctrine\ORM\Proxy\Proxy);
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $x2->y);
$this->assertFalse($x2->y->__isInitialized__);
// proxy for Y is in identity map
@ -45,7 +45,7 @@ class DDC237Test extends \Doctrine\Tests\OrmFunctionalTestCase
$z2 = $this->_em->createQuery('select z,y from ' . get_class($z) . ' z join z.y y where z.id = ?1')
->setParameter(1, $z->id)
->getSingleResult();
$this->assertTrue($z2->y instanceof \Doctrine\ORM\Proxy\Proxy);
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $z2->y);
$this->assertTrue($z2->y->__isInitialized__);
$this->assertEquals('Y', $z2->y->data);
$this->assertEquals($y->id, $z2->y->id);
@ -56,7 +56,7 @@ class DDC237Test extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertNotSame($x, $x2);
$this->assertNotSame($z, $z2);
$this->assertSame($z2->y, $x2->y);
$this->assertTrue($z2->y instanceof \Doctrine\ORM\Proxy\Proxy);
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $z2->y);
}
}

View File

@ -44,7 +44,7 @@ class DDC258Test extends \Doctrine\Tests\OrmFunctionalTestCase
$e2 = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC258Super', $c2->id);
$this->assertType('Doctrine\Tests\ORM\Functional\Ticket\DDC258Class2', $e2);
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\DDC258Class2', $e2);
$this->assertEquals('Bar', $e2->title);
$this->assertEquals('Bar', $e2->description);
$this->assertEquals('Bar', $e2->text);

View File

@ -48,7 +48,7 @@ class DDC345Test extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertEquals(1, $membership->prePersistCallCount);
$this->assertEquals(0, $membership->preUpdateCallCount);
$this->assertTrue($membership->updated instanceof \DateTime);
$this->assertInstanceOf('DateTime', $membership->updated);
}
}

View File

@ -41,7 +41,7 @@ class DDC371Test extends \Doctrine\Tests\OrmFunctionalTestCase
->getResult();
$this->assertEquals(1, count($children));
$this->assertFalse($children[0]->parent instanceof \Doctrine\ORM\Proxy\Proxy);
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $children[0]->parent);
$this->assertFalse($children[0]->parent->children->isInitialized());
$this->assertEquals(0, $children[0]->parent->children->unwrap()->count());
}

View File

@ -28,7 +28,7 @@ class DDC422Test extends \Doctrine\Tests\OrmFunctionalTestCase
$customer = $this->_em->find(get_class($customer), $customer->id);
$this->assertTrue($customer->contacts instanceof \Doctrine\ORM\PersistentCollection);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $customer->contacts);
$this->assertFalse($customer->contacts->isInitialized());
$contact = new DDC422Contact;
$customer->contacts->add($contact);

View File

@ -64,13 +64,13 @@ class DDC440Test extends \Doctrine\Tests\OrmFunctionalTestCase
// Test the first phone. The assertion actually failed because original entity data is not set properly.
// This was because it is also set as MainPhone and that one is created as a proxy, not the
// original object when the find on Client is called. However loading proxies did not work correctly.
$this->assertType('Doctrine\Tests\ORM\Functional\Ticket\DDC440Phone', $p1);
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\DDC440Phone', $p1);
$originalData = $uw->getOriginalEntityData($p1);
$this->assertEquals($phone->getNumber(), $originalData['number']);
//If you comment out previous test, this one should pass
$this->assertType('Doctrine\Tests\ORM\Functional\Ticket\DDC440Phone', $p2);
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\DDC440Phone', $p2);
$originalData = $uw->getOriginalEntityData($p2);
$this->assertEquals($phone2->getNumber(), $originalData['number']);
}

View File

@ -42,7 +42,7 @@ class DDC448MainTable
/**
* @ManyToOne(targetEntity="DDC448ConnectedClass", cascade={"all"}, fetch="EAGER")
* @JoinColumn(name="connectedClassId", referencedColumnName="id", onDelete="CASCADE", onUpdate="CASCADE", nullable=true)
* @JoinColumn(name="connectedClassId", referencedColumnName="id", onDelete="CASCADE", nullable=true)
*/
private $connectedClassId;
}

View File

@ -50,7 +50,7 @@ class DDC501Test extends OrmFunctionalTestCase
// freeze and unfreeze
$userClone = unserialize(serialize($userReloaded));
$this->assertType('Doctrine\Tests\Models\CMS\CmsUser', $userClone);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $userClone);
// detached user can't know about his phonenumbers
$this->assertEquals(0, count($userClone->getPhonenumbers()));

View File

@ -32,14 +32,14 @@ class DDC512Test extends \Doctrine\Tests\OrmFunctionalTestCase
$result = $q->getResult();
$this->assertEquals(2, count($result));
$this->assertTrue($result[0] instanceof DDC512Customer);
$this->assertTrue($result[1] instanceof DDC512Customer);
$this->assertInstanceOf(__NAMESPACE__ . '\DDC512Customer', $result[0]);
$this->assertInstanceOf(__NAMESPACE__ . '\DDC512Customer', $result[1]);
if ($result[0]->id == $customer1->id) {
$this->assertTrue($result[0]->item instanceof DDC512OfferItem);
$this->assertInstanceOf(__NAMESPACE__ . '\DDC512OfferItem', $result[0]->item);
$this->assertEquals($item->id, $result[0]->item->id);
$this->assertNull($result[1]->item);
} else {
$this->assertTrue($result[1]->item instanceof DDC512OfferItem);
$this->assertInstanceOf(__NAMESPACE__ . '\DDC512OfferItem', $result[1]->item);
$this->assertNull($result[0]->item);
}
}

View File

@ -48,9 +48,9 @@ class DDC522Test extends \Doctrine\Tests\OrmFunctionalTestCase
$r = $this->_em->createQuery("select ca,c from ".get_class($cart)." ca join ca.customer c")
->getResult();
$this->assertTrue($r[0] instanceof DDC522Cart);
$this->assertTrue($r[0]->customer instanceof DDC522Customer);
$this->assertFalse($r[0]->customer instanceof \Doctrine\ORM\Proxy\Proxy);
$this->assertInstanceOf(__NAMESPACE__ . '\DDC522Cart', $r[0]);
$this->assertInstanceOf(__NAMESPACE__ . '\DDC522Customer', $r[0]->customer);
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $r[0]->customer);
$this->assertEquals('name', $r[0]->customer->name);
$fkt = new DDC522ForeignKeyTest();
@ -62,7 +62,7 @@ class DDC522Test extends \Doctrine\Tests\OrmFunctionalTestCase
$fkt2 = $this->_em->find(get_class($fkt), $fkt->id);
$this->assertEquals($fkt->cart->id, $fkt2->cartId);
$this->assertTrue($fkt2->cart instanceof \Doctrine\ORM\Proxy\Proxy);
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $fkt2->cart);
$this->assertFalse($fkt2->cart->__isInitialized__);
}

View File

@ -29,8 +29,8 @@ class DDC531Test extends \Doctrine\Tests\OrmFunctionalTestCase
$item3 = $this->_em->find(__NAMESPACE__ . '\DDC531Item', $item2->id); // Load child item first (id 2)
// parent will already be loaded, cannot be lazy because it has mapped subclasses and we would not
// know which proxy type to put in.
$this->assertTrue($item3->parent instanceof DDC531Item);
$this->assertFalse($item3->parent instanceof \Doctrine\ORM\Proxy\Proxy);
$this->assertInstanceOf(__NAMESPACE__ . '\DDC531Item', $item3->parent);
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $item3->parent);
$item4 = $this->_em->find(__NAMESPACE__ . '\DDC531Item', $item1->id); // Load parent item (id 1)
$this->assertNull($item4->parent);
$this->assertNotNull($item4->getChildren());

View File

@ -66,7 +66,7 @@ class DDC633Test extends \Doctrine\Tests\OrmFunctionalTestCase
$appointments = $this->_em->createQuery("SELECT a FROM " . __NAMESPACE__ . "\DDC633Appointment a")->getResult();
foreach ($appointments AS $eagerAppointment) {
$this->assertType('Doctrine\ORM\Proxy\Proxy', $eagerAppointment->patient);
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $eagerAppointment->patient);
$this->assertTrue($eagerAppointment->patient->__isInitialized__, "Proxy should already be initialized due to eager loading!");
}
}

View File

@ -36,11 +36,11 @@ class DDC729Test extends \Doctrine\Tests\OrmFunctionalTestCase
$a = new DDC729A();
$a->id = $aId;
$this->assertType('Doctrine\Common\Collections\ArrayCollection', $a->related);
$this->assertInstanceOf('Doctrine\Common\Collections\ArrayCollection', $a->related);
$a = $this->_em->merge($a);
$this->assertType('Doctrine\ORM\PersistentCollection', $a->related);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $a->related);
$this->assertFalse($a->related->isInitialized(), "Collection should not be marked initialized.");
$this->assertFalse($a->related->isDirty(), "Collection should not be marked as dirty.");

View File

@ -72,7 +72,7 @@ class DDC736Test extends \Doctrine\Tests\OrmFunctionalTestCase
/* @var $cart2 Doctrine\Tests\Models\ECommerce\ECommerceCart */
$cart2 = $result[0][0];
$this->assertType('Doctrine\ORM\Proxy\Proxy', $cart2->getCustomer());
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $cart2->getCustomer());
}
}

View File

@ -33,10 +33,10 @@ class DDC748Test extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->persist($article);
$this->_em->flush();
$this->assertType('Doctrine\Common\Collections\Collection', $user->articles);
$this->assertInstanceOf('Doctrine\Common\Collections\Collection', $user->articles);
$this->_em->refresh($article);
$this->assertTrue($article !== $user->articles, "The article should not be replaced on the inverse side of the relation.");
$this->assertType('Doctrine\Common\Collections\Collection', $user->articles);
$this->assertInstanceOf('Doctrine\Common\Collections\Collection', $user->articles);
}
public function testRefreshOneToOne()

View File

@ -52,20 +52,20 @@ class DDC837Test extends \Doctrine\Tests\OrmFunctionalTestCase
// Test Class1
$e1 = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC837Super', $c1->id);
$this->assertType('Doctrine\Tests\ORM\Functional\Ticket\DDC837Class1', $e1);
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\DDC837Class1', $e1);
$this->assertEquals('Foo', $e1->title);
$this->assertEquals('Foo', $e1->description);
$this->assertType(__NAMESPACE__ . '\DDC837Aggregate', $e1->aggregate);
$this->assertInstanceOf(__NAMESPACE__ . '\DDC837Aggregate', $e1->aggregate);
$this->assertEquals('test1', $e1->aggregate->getSysname());
// Test Class 2
$e2 = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC837Super', $c2->id);
$this->assertType('Doctrine\Tests\ORM\Functional\Ticket\DDC837Class2', $e2);
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\DDC837Class2', $e2);
$this->assertEquals('Bar', $e2->title);
$this->assertEquals('Bar', $e2->description);
$this->assertEquals('Bar', $e2->text);
$this->assertType(__NAMESPACE__ . '\DDC837Aggregate', $e2->aggregate);
$this->assertInstanceOf(__NAMESPACE__ . '\DDC837Aggregate', $e2->aggregate);
$this->assertEquals('test2', $e2->aggregate->getSysname());
$all = $this->_em->getRepository(__NAMESPACE__.'\DDC837Super')->findAll();

View File

@ -34,10 +34,10 @@ class DDC949Test extends \Doctrine\Tests\OrmFunctionalTestCase
$true = $this->_em->getRepository('Doctrine\Tests\Models\Generic\BooleanModel')->findOneBy(array('booleanField' => true));
$false = $this->_em->getRepository('Doctrine\Tests\Models\Generic\BooleanModel')->findOneBy(array('booleanField' => false));
$this->assertType('Doctrine\Tests\Models\Generic\BooleanModel', $true);
$this->assertInstanceOf('Doctrine\Tests\Models\Generic\BooleanModel', $true);
$this->assertTrue($true->booleanField, "True Boolean Model should be true.");
$this->assertType('Doctrine\Tests\Models\Generic\BooleanModel', $false);
$this->assertInstanceOf('Doctrine\Tests\Models\Generic\BooleanModel', $false);
$this->assertFalse($false->booleanField, "False Boolean Model should be false.");
}
}

View File

@ -85,11 +85,11 @@ class AdvancedAssociationTest extends \Doctrine\Tests\OrmFunctionalTestCase {
$lemma = $res[0];
$this->assertEquals('foo', $lemma->getLemma());
$this->assertTrue($lemma instanceof Lemma);
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\Lemma', $lemma);
$relations = $lemma->getRelations();
foreach($relations as $relation) {
$this->assertTrue($relation instanceof Relation);
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\Ticket\Relation', $relation);
$this->assertTrue($relation->getType()->getType() != '');
}

View File

@ -15,7 +15,7 @@ class CustomHydratorTest extends HydrationTestCase
$config->addCustomHydrationMode('CustomHydrator', 'Doctrine\Tests\ORM\Hydration\CustomHydrator');
$hydrator = $em->newHydrator('CustomHydrator');
$this->assertTrue($hydrator instanceof \Doctrine\Tests\ORM\Hydration\CustomHydrator);
$this->assertInstanceOf('Doctrine\Tests\ORM\Hydration\CustomHydrator', $hydrator);
$this->assertNull($config->getCustomHydrationMode('does not exist'));
}
}

View File

@ -44,8 +44,8 @@ class ObjectHydratorTest extends HydrationTestCase
$result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true));
$this->assertEquals(2, count($result));
$this->assertTrue($result[0] instanceof \Doctrine\Tests\Models\CMS\CmsUser);
$this->assertTrue($result[1] instanceof \Doctrine\Tests\Models\CMS\CmsUser);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1]);
$this->assertEquals(1, $result[0]->id);
$this->assertEquals('romanb', $result[0]->name);
$this->assertEquals(2, $result[1]->id);
@ -116,10 +116,10 @@ class ObjectHydratorTest extends HydrationTestCase
$this->assertEquals(4, count($result));
$this->assertTrue($result[0] instanceof \Doctrine\Tests\Models\CMS\CmsUser);
$this->assertTrue($result[1] instanceof \Doctrine\Tests\Models\CMS\CmsArticle);
$this->assertTrue($result[2] instanceof \Doctrine\Tests\Models\CMS\CmsUser);
$this->assertTrue($result[3] instanceof \Doctrine\Tests\Models\CMS\CmsArticle);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[1]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[2]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[3]);
$this->assertEquals(1, $result[0]->id);
$this->assertEquals('romanb', $result[0]->name);
@ -173,7 +173,7 @@ class ObjectHydratorTest extends HydrationTestCase
$result = $hydrator->hydrateAll($stmt, $rsm);
$this->assertEquals(1, count($result));
$this->assertTrue($result[0] instanceof \Doctrine\Tests\Models\ECommerce\ECommerceProduct);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $result[0]);
}
/**
@ -231,12 +231,12 @@ class ObjectHydratorTest extends HydrationTestCase
$this->assertTrue(is_array($result[0]));
$this->assertTrue(is_array($result[1]));
$this->assertTrue($result[0][0] instanceof \Doctrine\Tests\Models\CMS\CmsUser);
$this->assertTrue($result[0][0]->phonenumbers instanceof \Doctrine\ORM\PersistentCollection);
$this->assertTrue($result[0][0]->phonenumbers[0] instanceof \Doctrine\Tests\Models\CMS\CmsPhonenumber);
$this->assertTrue($result[0][0]->phonenumbers[1] instanceof \Doctrine\Tests\Models\CMS\CmsPhonenumber);
$this->assertTrue($result[1][0] instanceof \Doctrine\Tests\Models\CMS\CmsUser);
$this->assertTrue($result[1][0]->phonenumbers instanceof \Doctrine\ORM\PersistentCollection);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][0]);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0][0]->phonenumbers);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[0][0]->phonenumbers[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[0][0]->phonenumbers[1]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1][0]);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[1][0]->phonenumbers);
// first user => 2 phonenumbers
$this->assertEquals(2, count($result[0][0]->phonenumbers));
@ -293,8 +293,8 @@ class ObjectHydratorTest extends HydrationTestCase
$this->assertEquals(2, $result[0]['numPhones']);
// second user => 1 phonenumber
$this->assertEquals(1, $result[1]['numPhones']);
$this->assertTrue($result[0][0] instanceof \Doctrine\Tests\Models\CMS\CmsUser);
$this->assertTrue($result[1][0] instanceof \Doctrine\Tests\Models\CMS\CmsUser);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1][0]);
}
/**
@ -359,9 +359,9 @@ class ObjectHydratorTest extends HydrationTestCase
$this->assertEquals('ROMANB', $result[0]['nameUpper']);
$this->assertEquals('JWAGE', $result[1]['nameUpper']);
$this->assertTrue($result[0]['1'] instanceof \Doctrine\Tests\Models\CMS\CmsUser);
$this->assertTrue($result[1]['2'] instanceof \Doctrine\Tests\Models\CMS\CmsUser);
$this->assertTrue($result[0]['1']->phonenumbers instanceof \Doctrine\ORM\PersistentCollection);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]['1']);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1]['2']);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0]['1']->phonenumbers);
// first user => 2 phonenumbers. notice the custom indexing by user id
$this->assertEquals(2, count($result[0]['1']->phonenumbers));
// second user => 1 phonenumber. notice the custom indexing by user id
@ -469,18 +469,18 @@ class ObjectHydratorTest extends HydrationTestCase
$this->assertTrue(is_array($result[0]));
$this->assertTrue(is_array($result[1]));
$this->assertTrue($result[0][0] instanceof \Doctrine\Tests\Models\CMS\CmsUser);
$this->assertTrue($result[0][0]->phonenumbers instanceof \Doctrine\ORM\PersistentCollection);
$this->assertTrue($result[0][0]->phonenumbers[0] instanceof \Doctrine\Tests\Models\CMS\CmsPhonenumber);
$this->assertTrue($result[0][0]->phonenumbers[1] instanceof \Doctrine\Tests\Models\CMS\CmsPhonenumber);
$this->assertTrue($result[0][0]->articles instanceof \Doctrine\ORM\PersistentCollection);
$this->assertTrue($result[0][0]->articles[0] instanceof \Doctrine\Tests\Models\CMS\CmsArticle);
$this->assertTrue($result[0][0]->articles[1] instanceof \Doctrine\Tests\Models\CMS\CmsArticle);
$this->assertTrue($result[1][0] instanceof \Doctrine\Tests\Models\CMS\CmsUser);
$this->assertTrue($result[1][0]->phonenumbers instanceof \Doctrine\ORM\PersistentCollection);
$this->assertTrue($result[1][0]->phonenumbers[0] instanceof \Doctrine\Tests\Models\CMS\CmsPhonenumber);
$this->assertTrue($result[1][0]->articles[0] instanceof \Doctrine\Tests\Models\CMS\CmsArticle);
$this->assertTrue($result[1][0]->articles[1] instanceof \Doctrine\Tests\Models\CMS\CmsArticle);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][0]);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0][0]->phonenumbers);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[0][0]->phonenumbers[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[0][0]->phonenumbers[1]);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0][0]->articles);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[0][0]->articles[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[0][0]->articles[1]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1][0]);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[1][0]->phonenumbers);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[1][0]->phonenumbers[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[1][0]->articles[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[1][0]->articles[1]);
}
/**
@ -604,29 +604,29 @@ class ObjectHydratorTest extends HydrationTestCase
$this->assertTrue(is_array($result[0]));
$this->assertTrue(is_array($result[1]));
$this->assertTrue($result[0][0] instanceof \Doctrine\Tests\Models\CMS\CmsUser);
$this->assertTrue($result[1][0] instanceof \Doctrine\Tests\Models\CMS\CmsUser);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1][0]);
// phonenumbers
$this->assertTrue($result[0][0]->phonenumbers instanceof \Doctrine\ORM\PersistentCollection);
$this->assertTrue($result[0][0]->phonenumbers[0] instanceof \Doctrine\Tests\Models\CMS\CmsPhonenumber);
$this->assertTrue($result[0][0]->phonenumbers[1] instanceof \Doctrine\Tests\Models\CMS\CmsPhonenumber);
$this->assertTrue($result[1][0]->phonenumbers instanceof \Doctrine\ORM\PersistentCollection);
$this->assertTrue($result[1][0]->phonenumbers[0] instanceof \Doctrine\Tests\Models\CMS\CmsPhonenumber);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0][0]->phonenumbers);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[0][0]->phonenumbers[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[0][0]->phonenumbers[1]);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[1][0]->phonenumbers);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[1][0]->phonenumbers[0]);
// articles
$this->assertTrue($result[0][0]->articles instanceof \Doctrine\ORM\PersistentCollection);
$this->assertTrue($result[0][0]->articles[0] instanceof \Doctrine\Tests\Models\CMS\CmsArticle);
$this->assertTrue($result[0][0]->articles[1] instanceof \Doctrine\Tests\Models\CMS\CmsArticle);
$this->assertTrue($result[1][0]->articles[0] instanceof \Doctrine\Tests\Models\CMS\CmsArticle);
$this->assertTrue($result[1][0]->articles[1] instanceof \Doctrine\Tests\Models\CMS\CmsArticle);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0][0]->articles);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[0][0]->articles[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[0][0]->articles[1]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[1][0]->articles[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[1][0]->articles[1]);
// article comments
$this->assertTrue($result[0][0]->articles[0]->comments instanceof \Doctrine\ORM\PersistentCollection);
$this->assertTrue($result[0][0]->articles[0]->comments[0] instanceof \Doctrine\Tests\Models\CMS\CmsComment);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0][0]->articles[0]->comments);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsComment', $result[0][0]->articles[0]->comments[0]);
// empty comment collections
$this->assertTrue($result[0][0]->articles[1]->comments instanceof \Doctrine\ORM\PersistentCollection);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0][0]->articles[1]->comments);
$this->assertEquals(0, count($result[0][0]->articles[1]->comments));
$this->assertTrue($result[1][0]->articles[0]->comments instanceof \Doctrine\ORM\PersistentCollection);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[1][0]->articles[0]->comments);
$this->assertEquals(0, count($result[1][0]->articles[0]->comments));
$this->assertTrue($result[1][0]->articles[1]->comments instanceof \Doctrine\ORM\PersistentCollection);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[1][0]->articles[1]->comments);
$this->assertEquals(0, count($result[1][0]->articles[1]->comments));
}
@ -706,8 +706,8 @@ class ObjectHydratorTest extends HydrationTestCase
$result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true));
$this->assertEquals(2, count($result));
$this->assertTrue($result[0] instanceof \Doctrine\Tests\Models\Forum\ForumCategory);
$this->assertTrue($result[1] instanceof \Doctrine\Tests\Models\Forum\ForumCategory);
$this->assertInstanceOf('Doctrine\Tests\Models\Forum\ForumCategory', $result[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\Forum\ForumCategory', $result[1]);
$this->assertTrue($result[0] !== $result[1]);
$this->assertEquals(1, $result[0]->getId());
$this->assertEquals(2, $result[1]->getId());
@ -768,8 +768,8 @@ class ObjectHydratorTest extends HydrationTestCase
$result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true));
$this->assertEquals(2, count($result));
$this->assertTrue($result[0] instanceof CmsUser);
$this->assertTrue($result[1] instanceof CmsUser);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1]);
$this->assertEquals(0, $result[0]->articles->count());
$this->assertEquals(0, $result[1]->articles->count());
}
@ -826,19 +826,19 @@ class ObjectHydratorTest extends HydrationTestCase
$this->assertEquals(3, count($result));
$this->assertTrue($result[0][0] instanceof CmsUser); // User object
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][0]); // User object
$this->assertEquals(1, $result[0]['id']);
$this->assertEquals('The First', $result[0]['topic']);
$this->assertEquals(1, $result[0]['cid']);
$this->assertEquals('First Comment', $result[0]['ctopic']);
$this->assertTrue($result[1][0] instanceof CmsUser); // Same User object
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1][0]); // Same User object
$this->assertEquals(1, $result[1]['id']); // duplicated
$this->assertEquals('The First', $result[1]['topic']); // duplicated
$this->assertEquals(2, $result[1]['cid']);
$this->assertEquals('Second Comment', $result[1]['ctopic']);
$this->assertTrue($result[2][0] instanceof CmsUser); // Same User object
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[2][0]); // Same User object
$this->assertEquals(42, $result[2]['id']);
$this->assertEquals('The Answer', $result[2]['topic']);
$this->assertNull($result[2]['cid']);
@ -877,7 +877,7 @@ class ObjectHydratorTest extends HydrationTestCase
$rowNum = 0;
while (($row = $iterableResult->next()) !== false) {
$this->assertEquals(1, count($row));
$this->assertTrue($row[0] instanceof \Doctrine\Tests\Models\CMS\CmsUser);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $row[0]);
if ($rowNum == 0) {
$this->assertEquals(1, $row[0]->id);
$this->assertEquals('romanb', $row[0]->name);

View File

@ -186,6 +186,7 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
$this->assertFalse($class->associationMappings['phonenumbers']['isCascadeRefresh']);
$this->assertFalse($class->associationMappings['phonenumbers']['isCascadeDetach']);
$this->assertFalse($class->associationMappings['phonenumbers']['isCascadeMerge']);
$this->assertTrue($class->associationMappings['phonenumbers']['orphanRemoval']);
// Test Order By
$this->assertEquals(array('number' => 'ASC'), $class->associationMappings['phonenumbers']['orderBy']);
@ -267,10 +268,9 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
* @depends testColumnDefinition
* @param ClassMetadata $class
*/
public function testJoinColumnOnDeleteAndOnUpdate($class)
public function testJoinColumnOnDelete($class)
{
$this->assertEquals('CASCADE', $class->associationMappings['address']['joinColumns'][0]['onDelete']);
$this->assertEquals('CASCADE', $class->associationMappings['address']['joinColumns'][0]['onUpdate']);
return $class;
}
@ -324,12 +324,12 @@ class User
/**
* @OneToOne(targetEntity="Address", cascade={"remove"}, inversedBy="user")
* @JoinColumn(onDelete="CASCADE", onUpdate="CASCADE")
* @JoinColumn(onDelete="CASCADE")
*/
public $address;
/**
* @OneToMany(targetEntity="Phonenumber", mappedBy="user", cascade={"persist"})
* @OneToMany(targetEntity="Phonenumber", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
* @OrderBy({"number"="ASC"})
*/
public $phonenumbers;
@ -412,7 +412,6 @@ class User
'name' => 'address_id',
'referencedColumnName' => 'id',
'onDelete' => 'CASCADE',
'onUpdate' => 'CASCADE'
),
),
'orphanRemoval' => false,
@ -425,7 +424,7 @@ class User
1 => 'persist',
),
'mappedBy' => 'user',
'orphanRemoval' => false,
'orphanRemoval' => true,
'orderBy' =>
array(
'number' => 'ASC',

View File

@ -16,7 +16,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
// Test initial state
$this->assertTrue(count($cm->getReflectionProperties()) == 0);
$this->assertTrue($cm->reflClass instanceof \ReflectionClass);
$this->assertInstanceOf('ReflectionClass', $cm->reflClass);
$this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $cm->name);
$this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $cm->rootEntityName);
$this->assertEquals(array(), $cm->subClasses);
@ -40,7 +40,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
// Check state
$this->assertTrue(count($cm->getReflectionProperties()) > 0);
$this->assertEquals('Doctrine\Tests\Models\CMS', $cm->namespace);
$this->assertTrue($cm->reflClass instanceof \ReflectionClass);
$this->assertInstanceOf('ReflectionClass', $cm->reflClass);
$this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $cm->name);
$this->assertEquals('UserParent', $cm->rootEntityName);
$this->assertEquals(array('Doctrine\Tests\Models\CMS\One', 'Doctrine\Tests\Models\CMS\Two', 'Doctrine\Tests\Models\CMS\Three'), $cm->subClasses);
@ -105,7 +105,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
));
$assoc = $cm->associationMappings['groups'];
//$this->assertTrue($assoc instanceof \Doctrine\ORM\Mapping\ManyToManyMapping);
//$this->assertInstanceOf('Doctrine\ORM\Mapping\ManyToManyMapping', $assoc);
$this->assertEquals(array(
'name' => 'cmsuser_cmsgroup',
'joinColumns' => array(array('name' => 'cmsuser_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE')),

View File

@ -51,7 +51,6 @@ $metadata->mapOneToOne(array(
'name' => 'address_id',
'referencedColumnName' => 'id',
'onDelete' => 'CASCADE',
'onUpdate' => 'CASCADE'
),
),
'orphanRemoval' => false,
@ -64,7 +63,7 @@ $metadata->mapOneToMany(array(
1 => 'persist',
),
'mappedBy' => 'user',
'orphanRemoval' => false,
'orphanRemoval' => true,
'orderBy' =>
array(
'number' => 'ASC',

View File

@ -39,7 +39,7 @@
<join-column name="address_id" referenced-column-name="id" on-delete="CASCADE" on-update="CASCADE"/>
</one-to-one>
<one-to-many field="phonenumbers" target-entity="Phonenumber" mapped-by="user">
<one-to-many field="phonenumbers" target-entity="Phonenumber" mapped-by="user" index-by="number" orphan-removal="true">
<cascade>
<cascade-persist/>
</cascade>

View File

@ -30,11 +30,11 @@ Doctrine\Tests\ORM\Mapping\User:
name: address_id
referencedColumnName: id
onDelete: CASCADE
onUpdate: CASCADE
cascade: [ remove ]
oneToMany:
phonenumbers:
targetEntity: Phonenumber
orphanRemoval: true
mappedBy: user
orderBy:
number: ASC

View File

@ -39,7 +39,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
$query->setHint($name, $value);
}
parent::assertEquals($sqlToBeConfirmed, $query->getSql());
parent::assertEquals($sqlToBeConfirmed, $query->getSQL());
$query->free();
} catch (\Exception $e) {
$this->fail($e->getMessage() ."\n".$e->getTraceAsString());
@ -380,7 +380,15 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
{
$this->assertSqlGeneration(
"SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF Doctrine\Tests\Models\Company\CompanyEmployee",
"SELECT c0_.id AS id0, c0_.name AS name1, c0_.discr AS discr2 FROM company_persons c0_ WHERE c0_.discr = 'employee'"
"SELECT c0_.id AS id0, c0_.name AS name1, c0_.discr AS discr2 FROM company_persons c0_ WHERE c0_.discr IN ('employee')"
);
}
public function testSupportsInstanceOfExpressionInWherePartWithMultipleValues()
{
$this->assertSqlGeneration(
"SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF (Doctrine\Tests\Models\Company\CompanyEmployee, \Doctrine\Tests\Models\Company\CompanyManager)",
"SELECT c0_.id AS id0, c0_.name AS name1, c0_.discr AS discr2 FROM company_persons c0_ WHERE c0_.discr IN ('employee', 'manager')"
);
}
@ -391,7 +399,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
{
$this->assertSqlGeneration(
"SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF \Doctrine\Tests\Models\Company\CompanyEmployee",
"SELECT c0_.id AS id0, c0_.name AS name1, c0_.discr AS discr2 FROM company_persons c0_ WHERE c0_.discr = 'employee'"
"SELECT c0_.id AS id0, c0_.name AS name1, c0_.discr AS discr2 FROM company_persons c0_ WHERE c0_.discr IN ('employee')"
);
}
@ -410,7 +418,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
{
$this->assertSqlGeneration(
"SELECT u FROM Doctrine\Tests\Models\Company\CompanyEmployee u WHERE u INSTANCE OF Doctrine\Tests\Models\Company\CompanyManager",
"SELECT c0_.id AS id0, c0_.name AS name1, c1_.salary AS salary2, c1_.department AS department3, c0_.discr AS discr4 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id WHERE c0_.discr = 'manager'"
"SELECT c0_.id AS id0, c0_.name AS name1, c1_.salary AS salary2, c1_.department AS department3, c0_.discr AS discr4 FROM company_employees c1_ INNER JOIN company_persons c0_ ON c1_.id = c0_.id WHERE c0_.discr IN ('manager')"
);
}
@ -418,7 +426,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
{
$this->assertSqlGeneration(
"SELECT u FROM Doctrine\Tests\Models\Company\CompanyManager u WHERE u INSTANCE OF Doctrine\Tests\Models\Company\CompanyManager",
"SELECT c0_.id AS id0, c0_.name AS name1, c1_.salary AS salary2, c1_.department AS department3, c2_.title AS title4, c0_.discr AS discr5 FROM company_managers c2_ INNER JOIN company_employees c1_ ON c2_.id = c1_.id INNER JOIN company_persons c0_ ON c2_.id = c0_.id WHERE c0_.discr = 'manager'"
"SELECT c0_.id AS id0, c0_.name AS name1, c1_.salary AS salary2, c1_.department AS department3, c2_.title AS title4, c0_.discr AS discr5 FROM company_managers c2_ INNER JOIN company_employees c1_ ON c2_.id = c1_.id INNER JOIN company_persons c0_ ON c2_.id = c0_.id WHERE c0_.discr IN ('manager')"
);
}
@ -426,7 +434,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
{
$this->assertSqlGeneration(
"SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF ?1",
"SELECT c0_.id AS id0, c0_.name AS name1, c0_.discr AS discr2 FROM company_persons c0_ WHERE c0_.discr = 'employee'",
"SELECT c0_.id AS id0, c0_.name AS name1, c0_.discr AS discr2 FROM company_persons c0_ WHERE c0_.discr IN ('employee')",
array(), array(1 => $this->_em->getClassMetadata('Doctrine\Tests\Models\Company\CompanyEmployee'))
);
}
@ -678,6 +686,23 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
"SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, (SELECT COUNT(*) FROM cms_articles c1_ WHERE c1_.user_id = c0_.id) AS sclr4 FROM cms_users c0_ ORDER BY sclr4 ASC"
);
}
public function testOrderBySupportsSingleValuedPathExpressionOwningSide()
{
$this->assertSqlGeneration(
"select a from Doctrine\Tests\Models\CMS\CmsArticle a order by a.user",
"SELECT c0_.id AS id0, c0_.topic AS topic1, c0_.text AS text2, c0_.version AS version3 FROM cms_articles c0_ ORDER BY c0_.user_id ASC"
);
}
/**
* @expectedException Doctrine\ORM\Query\QueryException
*/
public function testOrderBySupportsSingleValuedPathExpressionInverseSide()
{
$q = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u order by u.address");
$q->getSQL();
}
public function testBooleanLiteralInWhereOnSqlite()
{
@ -965,6 +990,49 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
"SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, (SELECT c1_.name FROM cms_users c1_ WHERE c1_.id = c0_.id AND c1_.name IN (SELECT c2_.name FROM cms_users c2_)) AS sclr4 FROM cms_users c0_"
);
}
/**
* @group DDC-1298
*/
public function testSelectForeignKeyPKWithoutFields()
{
$this->assertSqlGeneration(
"SELECT t, s, l FROM Doctrine\Tests\Models\DDC117\DDC117Link l INNER JOIN l.target t INNER JOIN l.source s",
"SELECT d0_.article_id AS article_id0, d0_.title AS title1, d1_.article_id AS article_id2, d1_.title AS title3 FROM DDC117Link d2_ INNER JOIN DDC117Article d0_ ON d2_.target_id = d0_.article_id INNER JOIN DDC117Article d1_ ON d2_.source_id = d1_.article_id"
);
}
public function testGeneralCaseWithSingleWhenClause()
{
$this->assertSqlGeneration(
"SELECT g.id, CASE WHEN ((g.id / 2) > 18) THEN 1 ELSE 0 END AS test FROM Doctrine\Tests\Models\CMS\CmsGroup g",
"SELECT c0_.id AS id0, CASE WHEN (c0_.id / 2 > 18) THEN 1 ELSE 0 END AS sclr1 FROM cms_groups c0_"
);
}
public function testGeneralCaseWithMultipleWhenClause()
{
$this->assertSqlGeneration(
"SELECT g.id, CASE WHEN (g.id / 2 < 10) THEN 2 WHEN ((g.id / 2) > 20) THEN 1 ELSE 0 END AS test FROM Doctrine\Tests\Models\CMS\CmsGroup g",
"SELECT c0_.id AS id0, CASE WHEN (c0_.id / 2 < 10) THEN 2 WHEN (c0_.id / 2 > 20) THEN 1 ELSE 0 END AS sclr1 FROM cms_groups c0_"
);
}
public function testSimpleCaseWithSingleWhenClause()
{
$this->assertSqlGeneration(
"SELECT g FROM Doctrine\Tests\Models\CMS\CmsGroup g WHERE g.id = CASE g.name WHEN 'admin' THEN 1 ELSE 2 END",
"SELECT c0_.id AS id0, c0_.name AS name1 FROM cms_groups c0_ WHERE c0_.id = CASE c0_.name WHEN admin THEN 1 ELSE 2 END"
);
}
public function testSimpleCaseWithMultipleWhenClause()
{
$this->assertSqlGeneration(
"SELECT g FROM Doctrine\Tests\Models\CMS\CmsGroup g WHERE g.id = (CASE g.name WHEN 'admin' THEN 1 WHEN 'moderator' THEN 2 ELSE 3 END)",
"SELECT c0_.id AS id0, c0_.name AS name1 FROM cms_groups c0_ WHERE c0_.id = CASE c0_.name WHEN admin THEN 1 WHEN moderator THEN 2 ELSE 3 END"
);
}
}
@ -977,9 +1045,7 @@ class MyAbsFunction extends \Doctrine\ORM\Query\AST\Functions\FunctionNode
*/
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
return 'ABS(' . $sqlWalker->walkSimpleArithmeticExpression(
$this->simpleArithmeticExpression
) . ')';
return 'ABS(' . $sqlWalker->walkSimpleArithmeticExpression($this->simpleArithmeticExpression) . ')';
}
/**

View File

@ -212,12 +212,11 @@ abstract class AbstractClassMetadataExporterTest extends \Doctrine\Tests\OrmTest
public function testOneToOneAssociationsAreExported($class)
{
$this->assertTrue(isset($class->associationMappings['address']));
//$this->assertTrue($class->associationMappings['address'] instanceof \Doctrine\ORM\Mapping\OneToOneMapping);
//$this->assertInstanceOf('Doctrine\ORM\Mapping\OneToOneMapping', $class->associationMappings['address']);
$this->assertEquals('Doctrine\Tests\ORM\Tools\Export\Address', $class->associationMappings['address']['targetEntity']);
$this->assertEquals('address_id', $class->associationMappings['address']['joinColumns'][0]['name']);
$this->assertEquals('id', $class->associationMappings['address']['joinColumns'][0]['referencedColumnName']);
$this->assertEquals('CASCADE', $class->associationMappings['address']['joinColumns'][0]['onDelete']);
$this->assertEquals('CASCADE', $class->associationMappings['address']['joinColumns'][0]['onUpdate']);
$this->assertTrue($class->associationMappings['address']['isCascadeRemove']);
$this->assertFalse($class->associationMappings['address']['isCascadePersist']);
@ -235,7 +234,7 @@ abstract class AbstractClassMetadataExporterTest extends \Doctrine\Tests\OrmTest
public function testOneToManyAssociationsAreExported($class)
{
$this->assertTrue(isset($class->associationMappings['phonenumbers']));
//$this->assertTrue($class->associationMappings['phonenumbers'] instanceof \Doctrine\ORM\Mapping\OneToManyMapping);
//$this->assertInstanceOf('Doctrine\ORM\Mapping\OneToManyMapping', $class->associationMappings['phonenumbers']);
$this->assertEquals('Doctrine\Tests\ORM\Tools\Export\Phonenumber', $class->associationMappings['phonenumbers']['targetEntity']);
$this->assertEquals('user', $class->associationMappings['phonenumbers']['mappedBy']);
$this->assertEquals(array('number' => 'ASC'), $class->associationMappings['phonenumbers']['orderBy']);
@ -256,7 +255,7 @@ abstract class AbstractClassMetadataExporterTest extends \Doctrine\Tests\OrmTest
public function testManyToManyAssociationsAreExported($class)
{
$this->assertTrue(isset($class->associationMappings['groups']));
//$this->assertTrue($class->associationMappings['groups'] instanceof \Doctrine\ORM\Mapping\ManyToManyMapping);
//$this->assertInstanceOf('Doctrine\ORM\Mapping\ManyToManyMapping', $class->associationMappings['groups']);
$this->assertEquals('Doctrine\Tests\ORM\Tools\Export\Group', $class->associationMappings['groups']['targetEntity']);
$this->assertEquals('cms_users_groups', $class->associationMappings['groups']['joinTable']['name']);

View File

@ -24,7 +24,7 @@ class User
/**
* @OneToOne(targetEntity="Doctrine\Tests\ORM\Tools\Export\Address", cascade={"remove"}, inversedBy="user")
* @JoinColumn(name="address_id", onDelete="CASCADE", onUpdate="CASCADE")
* @JoinColumn(name="address_id", onDelete="CASCADE")
*/
public $address;

View File

@ -47,7 +47,6 @@ $metadata->mapOneToOne(array(
'name' => 'address_id',
'referencedColumnName' => 'id',
'onDelete' => 'CASCADE',
'onUpdate' => 'CASCADE'
),
),
'orphanRemoval' => false,

View File

@ -23,7 +23,6 @@ Doctrine\Tests\ORM\Tools\Export\User:
name: address_id
referencedColumnName: id
onDelete: CASCADE
onUpdate: CASCADE
cascade: [ remove ]
inversedBy: user
oneToMany:

View File

@ -24,6 +24,5 @@ Profile:
relations:
User:
onDelete: CASCADE
onUpdate: CASCADE
foreignType: one
type: one

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