Commit 4a1c3785 authored by Benjamin Eberlei's avatar Benjamin Eberlei

Merge commit 'dc2master/master' into lock-support

parents a0b821cd cb616956
...@@ -46,7 +46,7 @@ Prefer PHP default values, if possible. ...@@ -46,7 +46,7 @@ Prefer PHP default values, if possible.
## Partial Objects ## Partial Objects
xxx [TBD: New syntax, results, etc.]
## XML Mapping Driver ## XML Mapping Driver
......
...@@ -2,12 +2,15 @@ ...@@ -2,12 +2,15 @@
require_once 'Doctrine/Common/ClassLoader.php'; require_once 'Doctrine/Common/ClassLoader.php';
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine'); $classLoader = new \Doctrine\Common\ClassLoader('Doctrine', __DIR__ . '/../lib');
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Symfony', __DIR__ . '/../lib/vendor');
$classLoader->register(); $classLoader->register();
$configFile = getcwd() . DIRECTORY_SEPARATOR . 'cli-config.php'; $configFile = getcwd() . DIRECTORY_SEPARATOR . 'cli-config.php';
$configuration = null; $helperSet = null;
if (file_exists($configFile)) { if (file_exists($configFile)) {
if ( ! is_readable($configFile)) { if ( ! is_readable($configFile)) {
trigger_error( trigger_error(
...@@ -17,15 +20,38 @@ if (file_exists($configFile)) { ...@@ -17,15 +20,38 @@ if (file_exists($configFile)) {
require $configFile; require $configFile;
foreach ($GLOBALS as $configCandidate) { foreach ($GLOBALS as $helperSetCandidate) {
if ($configCandidate instanceof \Doctrine\Common\CLI\Configuration) { if ($helperSetCandidate instanceof \Symfony\Components\Console\Helper\HelperSet) {
$configuration = $configCandidate; $helperSet = $helperSetCandidate;
break; break;
} }
} }
} }
$configuration = ($configuration) ?: new \Doctrine\Common\CLI\Configuration(); $helperSet = ($helperSet) ?: new \Symfony\Components\Console\Helper\HelperSet();
$cli = new \Doctrine\Common\CLI\CLIController($configuration); $cli = new \Symfony\Components\Console\Application('Doctrine Command Line Interface', Doctrine\Common\Version::VERSION);
$cli->run($_SERVER['argv']); $cli->setCatchExceptions(true);
\ No newline at end of file $cli->setHelperSet($helperSet);
$cli->addCommands(array(
// DBAL Commands
new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(),
new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(),
// ORM Commands
new \Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand(),
new \Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand(),
new \Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand(),
new \Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand(),
new \Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand(),
new \Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand(),
new \Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand(),
new \Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand(),
new \Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand(),
new \Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand(),
new \Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand(),
new \Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand(),
new \Doctrine\ORM\Tools\Console\Command\RunDqlCommand(),
));
$cli->run();
\ No newline at end of file
...@@ -217,7 +217,7 @@ ...@@ -217,7 +217,7 @@
</xs:complexType> </xs:complexType>
<xs:complexType name="order-by-field"> <xs:complexType name="order-by-field">
<xs:attribute name="field" type="XS:NMTOKEN" use="required" /> <xs:attribute name="name" type="xs:NMTOKEN" use="required" />
<xs:attribute name="direction" type="orm:order-by-direction" default="ASC" /> <xs:attribute name="direction" type="orm:order-by-direction" default="ASC" />
</xs:complexType> </xs:complexType>
...@@ -237,6 +237,7 @@ ...@@ -237,6 +237,7 @@
<xs:attribute name="target-entity" type="xs:NMTOKEN" use="required" /> <xs:attribute name="target-entity" type="xs:NMTOKEN" use="required" />
<xs:attribute name="field" type="xs:NMTOKEN" use="required" /> <xs:attribute name="field" type="xs:NMTOKEN" use="required" />
<xs:attribute name="mapped-by" type="xs:NMTOKEN" /> <xs:attribute name="mapped-by" type="xs:NMTOKEN" />
<xs:attribute name="inversed-by" type="xs:NMTOKEN" />
<xs:attribute name="fetch" type="orm:fetch-type" default="LAZY" /> <xs:attribute name="fetch" type="orm:fetch-type" default="LAZY" />
</xs:complexType> </xs:complexType>
...@@ -246,7 +247,7 @@ ...@@ -246,7 +247,7 @@
<xs:element name="order-by" type="orm:order-by" minOccurs="0" /> <xs:element name="order-by" type="orm:order-by" minOccurs="0" />
</xs:sequence> </xs:sequence>
<xs:attribute name="target-entity" type="xs:NMTOKEN" use="required" /> <xs:attribute name="target-entity" type="xs:NMTOKEN" use="required" />
<xs:attribute name="mapped-by" type="xs:NMTOKEN" /> <xs:attribute name="mapped-by" type="xs:NMTOKEN" use="required" />
<xs:attribute name="field" type="xs:NMTOKEN" use="required" /> <xs:attribute name="field" type="xs:NMTOKEN" use="required" />
<xs:attribute name="orphan-removal" type="xs:boolean" default="false" /> <xs:attribute name="orphan-removal" type="xs:boolean" default="false" />
<xs:attribute name="fetch" type="orm:fetch-type" default="LAZY" /> <xs:attribute name="fetch" type="orm:fetch-type" default="LAZY" />
...@@ -264,6 +265,7 @@ ...@@ -264,6 +265,7 @@
<xs:attribute name="field" type="xs:NMTOKEN" use="required" /> <xs:attribute name="field" type="xs:NMTOKEN" use="required" />
<xs:attribute name="orphan-removal" type="xs:boolean" default="false" /> <xs:attribute name="orphan-removal" type="xs:boolean" default="false" />
<xs:attribute name="fetch" type="orm:fetch-type" default="LAZY" /> <xs:attribute name="fetch" type="orm:fetch-type" default="LAZY" />
<xs:attribute name="inversed-by" type="xs:NMTOKEN" />
</xs:complexType> </xs:complexType>
<xs:complexType name="one-to-one"> <xs:complexType name="one-to-one">
...@@ -274,9 +276,10 @@ ...@@ -274,9 +276,10 @@
<xs:element name="join-columns" type="orm:join-columns"/> <xs:element name="join-columns" type="orm:join-columns"/>
</xs:choice> </xs:choice>
</xs:sequence> </xs:sequence>
<xs:attribute name="field" type="xs:NMTOKEN" use="required" />
<xs:attribute name="target-entity" type="xs:NMTOKEN" use="required" /> <xs:attribute name="target-entity" type="xs:NMTOKEN" use="required" />
<xs:attribute name="mapped-by" type="xs:NMTOKEN" /> <xs:attribute name="mapped-by" type="xs:NMTOKEN" />
<xs:attribute name="field" type="xs:NMTOKEN" use="required" /> <xs:attribute name="inversed-by" type="xs:NMTOKEN" />
<xs:attribute name="orphan-removal" type="xs:boolean" default="false" /> <xs:attribute name="orphan-removal" type="xs:boolean" default="false" />
<xs:attribute name="fetch" type="orm:fetch-type" default="LAZY" /> <xs:attribute name="fetch" type="orm:fetch-type" default="LAZY" />
</xs:complexType> </xs:complexType>
......
...@@ -26,7 +26,7 @@ namespace Doctrine\Common; ...@@ -26,7 +26,7 @@ namespace Doctrine\Common;
* *
* This class contains no event data. It is used by events that do not pass state * This class contains no event data. It is used by events that do not pass state
* information to an event handler when an event is raised. The single empty EventArgs * information to an event handler when an event is raised. The single empty EventArgs
* instance can be obtained through {@link getEmptyInstance()}. * instance can be obtained through {@link getEmptyInstance}.
* *
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org * @link www.doctrine-project.org
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* *
* This software consists of voluntary contributions made by many individuals * This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see * and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>. * <http://www.doctrine-project.org>.
*/ */
namespace Doctrine\Common; namespace Doctrine\Common;
...@@ -24,13 +24,12 @@ namespace Doctrine\Common; ...@@ -24,13 +24,12 @@ namespace Doctrine\Common;
/** /**
* An EventSubscriber knows himself what events he is interested in. * An EventSubscriber knows himself what events he is interested in.
* If an EventSubscriber is added to an EventManager, the manager invokes * If an EventSubscriber is added to an EventManager, the manager invokes
* getSubscribedEvents() and registers the subscriber as a listener for all * {@link getSubscribedEvents} and registers the subscriber as a listener for all
* returned events. * returned events.
* *
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org * @link www.doctrine-project.org
* @since 2.0 * @since 2.0
* @version $Revision: 3938 $
* @author Guilherme Blanco <guilhermeblanco@hotmail.com> * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Jonathan Wage <jonwage@gmail.com> * @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
...@@ -38,7 +37,7 @@ namespace Doctrine\Common; ...@@ -38,7 +37,7 @@ namespace Doctrine\Common;
interface EventSubscriber interface EventSubscriber
{ {
/** /**
* Returns an array of events that this subscriber listens * Returns an array of events this subscriber wants to listen to.
* *
* @return array * @return array
*/ */
......
...@@ -87,8 +87,8 @@ class ObjectHydrator extends AbstractHydrator ...@@ -87,8 +87,8 @@ class ObjectHydrator extends AbstractHydrator
if ($assoc->mappedBy) { if ($assoc->mappedBy) {
$this->_hints['fetched'][$className][$assoc->mappedBy] = true; $this->_hints['fetched'][$className][$assoc->mappedBy] = true;
} else { } else {
if (isset($class->inverseMappings[$sourceClassName][$assoc->sourceFieldName])) { if ($assoc->inversedBy) {
$inverseAssoc = $class->inverseMappings[$sourceClassName][$assoc->sourceFieldName]; $inverseAssoc = $class->associationMappings[$assoc->inversedBy];
if ($inverseAssoc->isOneToOne()) { if ($inverseAssoc->isOneToOne()) {
$this->_hints['fetched'][$className][$inverseAssoc->sourceFieldName] = true; $this->_hints['fetched'][$className][$inverseAssoc->sourceFieldName] = true;
if ($class->subClasses) { if ($class->subClasses) {
...@@ -346,9 +346,10 @@ class ObjectHydrator extends AbstractHydrator ...@@ -346,9 +346,10 @@ class ObjectHydrator extends AbstractHydrator
$this->_uow->setOriginalEntityProperty($oid, $relationField, $element); $this->_uow->setOriginalEntityProperty($oid, $relationField, $element);
$targetClass = $this->_ce[$relation->targetEntityName]; $targetClass = $this->_ce[$relation->targetEntityName];
if ($relation->isOwningSide) { if ($relation->isOwningSide) {
//TODO: Just check hints['fetched'] here?
// If there is an inverse mapping on the target class its bidirectional // If there is an inverse mapping on the target class its bidirectional
if (isset($targetClass->inverseMappings[$relation->sourceEntityName][$relationField])) { if ($relation->inversedBy) {
$inverseAssoc = $targetClass->inverseMappings[$relation->sourceEntityName][$relationField]; $inverseAssoc = $targetClass->associationMappings[$relation->inversedBy];
if ($inverseAssoc->isOneToOne()) { if ($inverseAssoc->isOneToOne()) {
$targetClass->reflFields[$inverseAssoc->sourceFieldName]->setValue($element, $parentObject); $targetClass->reflFields[$inverseAssoc->sourceFieldName]->setValue($element, $parentObject);
$this->_uow->setOriginalEntityProperty(spl_object_hash($element), $inverseAssoc->sourceFieldName, $parentObject); $this->_uow->setOriginalEntityProperty(spl_object_hash($element), $inverseAssoc->sourceFieldName, $parentObject);
......
...@@ -315,7 +315,6 @@ class ClassMetadata extends ClassMetadataInfo ...@@ -315,7 +315,6 @@ class ClassMetadata extends ClassMetadataInfo
'idGenerator', //TODO: Does not really need to be serialized. Could be moved to runtime. 'idGenerator', //TODO: Does not really need to be serialized. Could be moved to runtime.
'inheritanceType', 'inheritanceType',
'inheritedAssociationFields', 'inheritedAssociationFields',
'inverseMappings', //TODO: Remove! DDC-193
'isIdentifierComposite', 'isIdentifierComposite',
'isMappedSuperclass', 'isMappedSuperclass',
'isVersioned', 'isVersioned',
......
...@@ -127,9 +127,9 @@ class ClassMetadataInfo ...@@ -127,9 +127,9 @@ class ClassMetadataInfo
public $namespace; public $namespace;
/** /**
* READ-ONLY: The name of the entity class that is at the root of the entity inheritance * READ-ONLY: The name of the entity class that is at the root of the mapped entity inheritance
* hierarchy. If the entity is not part of an inheritance hierarchy this is the same * hierarchy. If the entity is not part of a mapped inheritance hierarchy this is the same
* as $_entityName. * as {@link $entityName}.
* *
* @var string * @var string
*/ */
...@@ -312,14 +312,6 @@ class ClassMetadataInfo ...@@ -312,14 +312,6 @@ class ClassMetadataInfo
*/ */
public $associationMappings = array(); public $associationMappings = array();
/**
* READ-ONLY: List of inverse association mappings, indexed by mappedBy field name.
*
* @var array
* @todo Remove! See http://www.doctrine-project.org/jira/browse/DDC-193
*/
public $inverseMappings = array();
/** /**
* READ-ONLY: Flag indicating whether the identifier/primary key of the class is composite. * READ-ONLY: Flag indicating whether the identifier/primary key of the class is composite.
* *
...@@ -531,34 +523,6 @@ class ClassMetadataInfo ...@@ -531,34 +523,6 @@ class ClassMetadataInfo
return $this->associationMappings[$fieldName]; return $this->associationMappings[$fieldName];
} }
/**
* Gets the inverse association mapping for the given target class name and
* owning fieldname.
*
* @param string $mappedByFieldName The field on the
* @return Doctrine\ORM\Mapping\AssociationMapping The mapping or NULL if there is no such
* inverse association mapping.
*/
public function getInverseAssociationMapping($targetClassName, $mappedByFieldName)
{
return isset($this->inverseMappings[$targetClassName][$mappedByFieldName]) ?
$this->inverseMappings[$targetClassName][$mappedByFieldName] : null;
}
/**
* Checks whether the class has an inverse association mapping that points to the
* specified class and ha the specified mappedBy field.
*
* @param string $targetClassName The name of the target class.
* @param string $mappedByFieldName The name of the mappedBy field that points to the field on
* the target class that owns the association.
* @return boolean
*/
public function hasInverseAssociationMapping($targetClassName, $mappedByFieldName)
{
return isset($this->inverseMappings[$targetClassName][$mappedByFieldName]);
}
/** /**
* Gets all association mappings of the class. * Gets all association mappings of the class.
* *
...@@ -1063,7 +1027,6 @@ class ClassMetadataInfo ...@@ -1063,7 +1027,6 @@ class ClassMetadataInfo
if ($owningClassName !== null) { if ($owningClassName !== null) {
$this->inheritedAssociationFields[$sourceFieldName] = $owningClassName; $this->inheritedAssociationFields[$sourceFieldName] = $owningClassName;
} }
$this->_registerMappingIfInverse($mapping);
} }
/** /**
...@@ -1093,20 +1056,6 @@ class ClassMetadataInfo ...@@ -1093,20 +1056,6 @@ class ClassMetadataInfo
$this->_storeAssociationMapping($oneToOneMapping); $this->_storeAssociationMapping($oneToOneMapping);
} }
/**
* Registers the mapping as an inverse mapping, if it is a mapping on the
* inverse side of an association mapping.
*
* @param AssociationMapping The mapping to register as inverse if it is a mapping
* for the inverse side of an association.
*/
private function _registerMappingIfInverse(AssociationMapping $assoc)
{
if ( ! $assoc->isOwningSide) {
$this->inverseMappings[$assoc->targetEntityName][$assoc->mappedBy] = $assoc;
}
}
/** /**
* Adds a one-to-many mapping. * Adds a one-to-many mapping.
* *
...@@ -1154,7 +1103,6 @@ class ClassMetadataInfo ...@@ -1154,7 +1103,6 @@ class ClassMetadataInfo
throw MappingException::duplicateFieldMapping($this->name, $sourceFieldName); throw MappingException::duplicateFieldMapping($this->name, $sourceFieldName);
} }
$this->associationMappings[$sourceFieldName] = $assocMapping; $this->associationMappings[$sourceFieldName] = $assocMapping;
$this->_registerMappingIfInverse($assocMapping);
} }
/** /**
......
...@@ -173,7 +173,7 @@ class AnnotationDriver implements Driver ...@@ -173,7 +173,7 @@ class AnnotationDriver implements Driver
// Evaluate InheritanceType annotation // Evaluate InheritanceType annotation
if (isset($classAnnotations['Doctrine\ORM\Mapping\InheritanceType'])) { if (isset($classAnnotations['Doctrine\ORM\Mapping\InheritanceType'])) {
$inheritanceTypeAnnot = $classAnnotations['Doctrine\ORM\Mapping\InheritanceType']; $inheritanceTypeAnnot = $classAnnotations['Doctrine\ORM\Mapping\InheritanceType'];
$metadata->setInheritanceType(constant('\Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceTypeAnnot->value)); $metadata->setInheritanceType(constant('Doctrine\ORM\Mapping\ClassMetadata::INHERITANCE_TYPE_' . $inheritanceTypeAnnot->value));
} }
// Evaluate DiscriminatorColumn annotation // Evaluate DiscriminatorColumn annotation
...@@ -195,7 +195,7 @@ class AnnotationDriver implements Driver ...@@ -195,7 +195,7 @@ class AnnotationDriver implements Driver
// Evaluate DoctrineChangeTrackingPolicy annotation // Evaluate DoctrineChangeTrackingPolicy annotation
if (isset($classAnnotations['Doctrine\ORM\Mapping\ChangeTrackingPolicy'])) { if (isset($classAnnotations['Doctrine\ORM\Mapping\ChangeTrackingPolicy'])) {
$changeTrackingAnnot = $classAnnotations['Doctrine\ORM\Mapping\ChangeTrackingPolicy']; $changeTrackingAnnot = $classAnnotations['Doctrine\ORM\Mapping\ChangeTrackingPolicy'];
$metadata->setChangeTrackingPolicy(constant('\Doctrine\ORM\Mapping\ClassMetadata::CHANGETRACKING_' . $changeTrackingAnnot->value)); $metadata->setChangeTrackingPolicy(constant('Doctrine\ORM\Mapping\ClassMetadata::CHANGETRACKING_' . $changeTrackingAnnot->value));
} }
// Evaluate annotations on properties/fields // Evaluate annotations on properties/fields
......
...@@ -29,7 +29,7 @@ use Doctrine\Common\Cache\ArrayCache, ...@@ -29,7 +29,7 @@ use Doctrine\Common\Cache\ArrayCache,
Doctrine\Common\Util\Inflector; Doctrine\Common\Util\Inflector;
/** /**
* The DatabaseDriver reverse engineers the mapping metadata from a database * The DatabaseDriver reverse engineers the mapping metadata from a database.
* *
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org * @link www.doctrine-project.org
...@@ -67,7 +67,7 @@ class DatabaseDriver implements Driver ...@@ -67,7 +67,7 @@ class DatabaseDriver implements Driver
$columns = $this->_sm->listTableColumns($tableName); $columns = $this->_sm->listTableColumns($tableName);
if($this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) { if ($this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) {
$foreignKeys = $this->_sm->listTableForeignKeys($tableName); $foreignKeys = $this->_sm->listTableForeignKeys($tableName);
} else { } else {
$foreignKeys = array(); $foreignKeys = array();
......
...@@ -37,7 +37,6 @@ final class DiscriminatorColumn extends Annotation { ...@@ -37,7 +37,6 @@ final class DiscriminatorColumn extends Annotation {
public $length; public $length;
} }
final class DiscriminatorMap extends Annotation {} final class DiscriminatorMap extends Annotation {}
/*final class SubClasses extends Annotation {}*/
final class Id extends Annotation {} final class Id extends Annotation {}
final class GeneratedValue extends Annotation { final class GeneratedValue extends Annotation {
public $strategy = 'AUTO'; public $strategy = 'AUTO';
...@@ -124,7 +123,6 @@ final class SequenceGenerator extends Annotation { ...@@ -124,7 +123,6 @@ final class SequenceGenerator extends Annotation {
public $initialValue = 1; public $initialValue = 1;
} }
final class ChangeTrackingPolicy extends Annotation {} final class ChangeTrackingPolicy extends Annotation {}
final class OrderBy extends Annotation {} final class OrderBy extends Annotation {}
/* Annotations for lifecycle callbacks */ /* Annotations for lifecycle callbacks */
......
...@@ -46,7 +46,7 @@ class DriverChain implements Driver ...@@ -46,7 +46,7 @@ class DriverChain implements Driver
private $_drivers = array(); private $_drivers = array();
/** /**
* Add a nested driver * Add a nested driver.
* *
* @param Driver $nestedDriver * @param Driver $nestedDriver
* @param string $namespace * @param string $namespace
...@@ -57,7 +57,7 @@ class DriverChain implements Driver ...@@ -57,7 +57,7 @@ class DriverChain implements Driver
} }
/** /**
* Get the array of nested drivers * Get the array of nested drivers.
* *
* @return array $drivers * @return array $drivers
*/ */
...@@ -74,7 +74,7 @@ class DriverChain implements Driver ...@@ -74,7 +74,7 @@ class DriverChain implements Driver
*/ */
public function loadMetadataForClass($className, ClassMetadataInfo $metadata) public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
{ {
foreach ($this->_drivers AS $namespace => $driver) { foreach ($this->_drivers as $namespace => $driver) {
if (strpos($className, $namespace) === 0) { if (strpos($className, $namespace) === 0) {
$driver->loadMetadataForClass($className, $metadata); $driver->loadMetadataForClass($className, $metadata);
return; return;
......
...@@ -49,7 +49,6 @@ class PhpDriver extends AbstractFileDriver ...@@ -49,7 +49,6 @@ class PhpDriver extends AbstractFileDriver
* {@inheritdoc} * {@inheritdoc}
*/ */
protected $_fileExtension = '.php'; protected $_fileExtension = '.php';
protected $_metadata; protected $_metadata;
/** /**
......
...@@ -21,7 +21,8 @@ ...@@ -21,7 +21,8 @@
namespace Doctrine\ORM\Mapping\Driver; namespace Doctrine\ORM\Mapping\Driver;
use Doctrine\ORM\Mapping\ClassMetadataInfo, use SimpleXMLElement,
Doctrine\ORM\Mapping\ClassMetadataInfo,
Doctrine\ORM\Mapping\MappingException; Doctrine\ORM\Mapping\MappingException;
/** /**
...@@ -226,6 +227,9 @@ class XmlDriver extends AbstractFileDriver ...@@ -226,6 +227,9 @@ class XmlDriver extends AbstractFileDriver
if (isset($oneToOneElement['mapped-by'])) { if (isset($oneToOneElement['mapped-by'])) {
$mapping['mappedBy'] = (string)$oneToOneElement['mapped-by']; $mapping['mappedBy'] = (string)$oneToOneElement['mapped-by'];
} else { } else {
if (isset($oneToOneElement['inversed-by'])) {
$mapping['inversedBy'] = (string)$oneToOneElement['inversed-by'];
}
$joinColumns = array(); $joinColumns = array();
if (isset($oneToOneElement->{'join-column'})) { if (isset($oneToOneElement->{'join-column'})) {
...@@ -296,6 +300,10 @@ class XmlDriver extends AbstractFileDriver ...@@ -296,6 +300,10 @@ class XmlDriver extends AbstractFileDriver
$mapping['fetch'] = constant('Doctrine\ORM\Mapping\AssociationMapping::FETCH_' . (string)$manyToOneElement['fetch']); $mapping['fetch'] = constant('Doctrine\ORM\Mapping\AssociationMapping::FETCH_' . (string)$manyToOneElement['fetch']);
} }
if (isset($manyToOneElement['inversed-by'])) {
$mapping['inversedBy'] = (string)$manyToOneElement['inversed-by'];
}
$joinColumns = array(); $joinColumns = array();
if (isset($manyToOneElement->{'join-column'})) { if (isset($manyToOneElement->{'join-column'})) {
...@@ -305,7 +313,6 @@ class XmlDriver extends AbstractFileDriver ...@@ -305,7 +313,6 @@ class XmlDriver extends AbstractFileDriver
if (!isset($joinColumnElement['name'])) { if (!isset($joinColumnElement['name'])) {
$joinColumnElement['name'] = $name; $joinColumnElement['name'] = $name;
} }
$joinColumns[] = $this->_getJoinColumnMapping($joinColumnElement); $joinColumns[] = $this->_getJoinColumnMapping($joinColumnElement);
} }
} }
...@@ -339,6 +346,10 @@ class XmlDriver extends AbstractFileDriver ...@@ -339,6 +346,10 @@ class XmlDriver extends AbstractFileDriver
if (isset($manyToManyElement['mapped-by'])) { if (isset($manyToManyElement['mapped-by'])) {
$mapping['mappedBy'] = (string)$manyToManyElement['mapped-by']; $mapping['mappedBy'] = (string)$manyToManyElement['mapped-by'];
} else if (isset($manyToManyElement->{'join-table'})) { } else if (isset($manyToManyElement->{'join-table'})) {
if (isset($manyToManyElement['inversed-by'])) {
$mapping['inversedBy'] = (string)$manyToManyElement['inversed-by'];
}
$joinTableElement = $manyToManyElement->{'join-table'}; $joinTableElement = $manyToManyElement->{'join-table'};
$joinTable = array( $joinTable = array(
'name' => (string)$joinTableElement['name'] 'name' => (string)$joinTableElement['name']
...@@ -382,7 +393,7 @@ class XmlDriver extends AbstractFileDriver ...@@ -382,7 +393,7 @@ class XmlDriver extends AbstractFileDriver
// Evaluate <lifecycle-callbacks...> // Evaluate <lifecycle-callbacks...>
if (isset($xmlRoot->{'lifecycle-callbacks'})) { if (isset($xmlRoot->{'lifecycle-callbacks'})) {
foreach ($xmlRoot->{'lifecycle-callbacks'}->{'lifecycle-callback'} as $lifecycleCallback) { foreach ($xmlRoot->{'lifecycle-callbacks'}->{'lifecycle-callback'} as $lifecycleCallback) {
$metadata->addLifecycleCallback((string)$lifecycleCallback['method'], constant('\Doctrine\ORM\Events::' . (string)$lifecycleCallback['type'])); $metadata->addLifecycleCallback((string)$lifecycleCallback['method'], constant('Doctrine\ORM\Events::' . (string)$lifecycleCallback['type']));
} }
} }
} }
...@@ -394,7 +405,7 @@ class XmlDriver extends AbstractFileDriver ...@@ -394,7 +405,7 @@ class XmlDriver extends AbstractFileDriver
* @param $joinColumnElement The XML element. * @param $joinColumnElement The XML element.
* @return array The mapping array. * @return array The mapping array.
*/ */
private function _getJoinColumnMapping(\SimpleXMLElement $joinColumnElement) private function _getJoinColumnMapping(SimpleXMLElement $joinColumnElement)
{ {
$joinColumn = array( $joinColumn = array(
'name' => (string)$joinColumnElement['name'], 'name' => (string)$joinColumnElement['name'],
......
...@@ -230,6 +230,10 @@ class YamlDriver extends AbstractFileDriver ...@@ -230,6 +230,10 @@ class YamlDriver extends AbstractFileDriver
if (isset($oneToOneElement['mappedBy'])) { if (isset($oneToOneElement['mappedBy'])) {
$mapping['mappedBy'] = $oneToOneElement['mappedBy']; $mapping['mappedBy'] = $oneToOneElement['mappedBy'];
} else { } else {
if (isset($oneToOneElement['inversedBy'])) {
$mapping['inversedBy'] = $oneToOneElement['inversedBy'];
}
$joinColumns = array(); $joinColumns = array();
if (isset($oneToOneElement['joinColumn'])) { if (isset($oneToOneElement['joinColumn'])) {
...@@ -292,6 +296,10 @@ class YamlDriver extends AbstractFileDriver ...@@ -292,6 +296,10 @@ class YamlDriver extends AbstractFileDriver
$mapping['fetch'] = constant('Doctrine\ORM\Mapping\AssociationMapping::FETCH_' . $manyToOneElement['fetch']); $mapping['fetch'] = constant('Doctrine\ORM\Mapping\AssociationMapping::FETCH_' . $manyToOneElement['fetch']);
} }
if (isset($manyToOneElement['inversedBy'])) {
$mapping['inversedBy'] = $manyToOneElement['inversedBy'];
}
$joinColumns = array(); $joinColumns = array();
if (isset($manyToOneElement['joinColumn'])) { if (isset($manyToOneElement['joinColumn'])) {
...@@ -331,6 +339,10 @@ class YamlDriver extends AbstractFileDriver ...@@ -331,6 +339,10 @@ class YamlDriver extends AbstractFileDriver
if (isset($manyToManyElement['mappedBy'])) { if (isset($manyToManyElement['mappedBy'])) {
$mapping['mappedBy'] = $manyToManyElement['mappedBy']; $mapping['mappedBy'] = $manyToManyElement['mappedBy'];
} else if (isset($manyToManyElement['joinTable'])) { } else if (isset($manyToManyElement['joinTable'])) {
if (isset($manyToManyElement['inversedBy'])) {
$mapping['inversedBy'] = $manyToManyElement['inversedBy'];
}
$joinTableElement = $manyToManyElement['joinTable']; $joinTableElement = $manyToManyElement['joinTable'];
$joinTable = array( $joinTable = array(
'name' => $joinTableElement['name'] 'name' => $joinTableElement['name']
...@@ -375,7 +387,7 @@ class YamlDriver extends AbstractFileDriver ...@@ -375,7 +387,7 @@ class YamlDriver extends AbstractFileDriver
if (isset($element['lifecycleCallbacks'])) { if (isset($element['lifecycleCallbacks'])) {
foreach ($element['lifecycleCallbacks'] as $type => $methods) { foreach ($element['lifecycleCallbacks'] as $type => $methods) {
foreach ($methods as $method) { foreach ($methods as $method) {
$metadata->addLifecycleCallback($method, constant('\Doctrine\ORM\Events::' . $type)); $metadata->addLifecycleCallback($method, constant('Doctrine\ORM\Events::' . $type));
} }
} }
} }
......
...@@ -70,10 +70,7 @@ class ManyToManyMapping extends AssociationMapping ...@@ -70,10 +70,7 @@ class ManyToManyMapping extends AssociationMapping
public $orderBy; public $orderBy;
/** /**
* Validates and completes the mapping. * {@inheritdoc}
*
* @param array $mapping
* @override
*/ */
protected function _validateAndCompleteMapping(array $mapping) protected function _validateAndCompleteMapping(array $mapping)
{ {
...@@ -89,13 +86,15 @@ class ManyToManyMapping extends AssociationMapping ...@@ -89,13 +86,15 @@ class ManyToManyMapping extends AssociationMapping
'joinColumns' => array( 'joinColumns' => array(
array( array(
'name' => $sourceShortName . '_id', 'name' => $sourceShortName . '_id',
'referencedColumnName' => 'id' 'referencedColumnName' => 'id',
'onDelete' => 'CASCADE'
) )
), ),
'inverseJoinColumns' => array( 'inverseJoinColumns' => array(
array( array(
'name' => $targetShortName . '_id', 'name' => $targetShortName . '_id',
'referencedColumnName' => 'id' 'referencedColumnName' => 'id',
'onDelete' => 'CASCADE'
) )
) )
); );
...@@ -178,6 +177,7 @@ class ManyToManyMapping extends AssociationMapping ...@@ -178,6 +177,7 @@ class ManyToManyMapping extends AssociationMapping
$persister->loadManyToManyCollection($this, $joinTableConditions, $targetCollection); $persister->loadManyToManyCollection($this, $joinTableConditions, $targetCollection);
} }
/** {@inheritdoc} */
public function isManyToMany() public function isManyToMany()
{ {
return true; return true;
......
...@@ -141,18 +141,14 @@ class OneToOneMapping extends AssociationMapping ...@@ -141,18 +141,14 @@ class OneToOneMapping extends AssociationMapping
$targetClass = $em->getClassMetadata($this->targetEntityName); $targetClass = $em->getClassMetadata($this->targetEntityName);
if ($this->isOwningSide) { if ($this->isOwningSide) {
$inverseField = isset($targetClass->inverseMappings[$this->sourceEntityName][$this->sourceFieldName]) ?
$targetClass->inverseMappings[$this->sourceEntityName][$this->sourceFieldName]->sourceFieldName
: false;
// Mark inverse side as fetched in the hints, otherwise the UoW would // Mark inverse side as fetched in the hints, otherwise the UoW would
// try to load it in a separate query (remember: to-one inverse sides can not be lazy). // try to load it in a separate query (remember: to-one inverse sides can not be lazy).
$hints = array(); $hints = array();
if ($inverseField) { if ($this->inversedBy) {
$hints['fetched'][$targetClass->name][$inverseField] = true; $hints['fetched'][$targetClass->name][$this->inversedBy] = true;
if ($targetClass->subClasses) { if ($targetClass->subClasses) {
foreach ($targetClass->subClasses as $targetSubclassName) { foreach ($targetClass->subClasses as $targetSubclassName) {
$hints['fetched'][$targetSubclassName][$inverseField] = true; $hints['fetched'][$targetSubclassName][$this->inversedBy] = true;
} }
} }
} }
...@@ -164,8 +160,8 @@ class OneToOneMapping extends AssociationMapping ...@@ -164,8 +160,8 @@ class OneToOneMapping extends AssociationMapping
$targetEntity = $em->getUnitOfWork()->getEntityPersister($this->targetEntityName)->load($joinColumnValues, $targetEntity, $this, $hints); $targetEntity = $em->getUnitOfWork()->getEntityPersister($this->targetEntityName)->load($joinColumnValues, $targetEntity, $this, $hints);
if ($targetEntity !== null && $inverseField && ! $targetClass->isCollectionValuedAssociation($inverseField)) { if ($targetEntity !== null && $this->inversedBy && ! $targetClass->isCollectionValuedAssociation($this->inversedBy)) {
$targetClass->reflFields[$inverseField]->setValue($targetEntity, $sourceEntity); $targetClass->reflFields[$this->inversedBy]->setValue($targetEntity, $sourceEntity);
} }
} else { } else {
$conditions = array(); $conditions = array();
......
...@@ -134,18 +134,7 @@ final class PersistentCollection implements Collection ...@@ -134,18 +134,7 @@ final class PersistentCollection implements Collection
{ {
$this->_owner = $entity; $this->_owner = $entity;
$this->_association = $assoc; $this->_association = $assoc;
$this->_backRefFieldName = $assoc->inversedBy ?: $assoc->mappedBy;
// Check for bidirectionality
//$this->_backRefFieldName = $assoc->inversedBy ?: $assoc->mappedBy;
if ( ! $assoc->isOwningSide) {
// For sure bi-directional
$this->_backRefFieldName = $assoc->mappedBy;
} else {
if (isset($this->_typeClass->inverseMappings[$assoc->sourceEntityName][$assoc->sourceFieldName])) {
// Bi-directional
$this->_backRefFieldName = $this->_typeClass->inverseMappings[$assoc->sourceEntityName][$assoc->sourceFieldName]->sourceFieldName;
}
}
} }
/** /**
...@@ -174,8 +163,8 @@ final class PersistentCollection implements Collection ...@@ -174,8 +163,8 @@ final class PersistentCollection implements Collection
public function hydrateAdd($element) public function hydrateAdd($element)
{ {
$this->_coll->add($element); $this->_coll->add($element);
// If _backRefFieldName is set, then the association is bidirectional // If _backRefFieldName is set and its a one-to-many association,
// and we need to set the back reference. // we need to set the back reference.
if ($this->_backRefFieldName && $this->_association->isOneToMany()) { if ($this->_backRefFieldName && $this->_association->isOneToMany()) {
// Set back reference to owner // Set back reference to owner
$this->_typeClass->reflFields[$this->_backRefFieldName] $this->_typeClass->reflFields[$this->_backRefFieldName]
......
...@@ -50,7 +50,7 @@ abstract class AbstractCollectionPersister ...@@ -50,7 +50,7 @@ abstract class AbstractCollectionPersister
protected $_uow; protected $_uow;
/** /**
* Initializes a new instance of a class derived from {@link AbstractCollectionPersister}. * Initializes a new instance of a class derived from AbstractCollectionPersister.
* *
* @param Doctrine\ORM\EntityManager $em * @param Doctrine\ORM\EntityManager $em
*/ */
......
...@@ -493,8 +493,8 @@ class StandardEntityPersister ...@@ -493,8 +493,8 @@ class StandardEntityPersister
if ($found = $this->_em->getUnitOfWork()->tryGetById($joinColumnValues, $targetClass->rootEntityName)) { if ($found = $this->_em->getUnitOfWork()->tryGetById($joinColumnValues, $targetClass->rootEntityName)) {
$this->_class->reflFields[$field]->setValue($entity, $found); $this->_class->reflFields[$field]->setValue($entity, $found);
// Complete inverse side, if necessary. // Complete inverse side, if necessary.
if (isset($targetClass->inverseMappings[$this->_class->name][$field])) { if ($assoc->inversedBy) {
$inverseAssoc = $targetClass->inverseMappings[$this->_class->name][$field]; $inverseAssoc = $targetClass->associationMappings[$assoc->inversedBy];
$targetClass->reflFields[$inverseAssoc->sourceFieldName]->setValue($found, $entity); $targetClass->reflFields[$inverseAssoc->sourceFieldName]->setValue($found, $entity);
} }
$newData[$field] = $found; $newData[$field] = $found;
......
...@@ -1359,7 +1359,7 @@ class UnitOfWork implements PropertyChangedListener ...@@ -1359,7 +1359,7 @@ class UnitOfWork implements PropertyChangedListener
$assoc2 = $class->associationMappings[$name]; $assoc2 = $class->associationMappings[$name];
if ($assoc2->isOneToOne()) { if ($assoc2->isOneToOne()) {
if ( ! $assoc2->isCascadeMerge) { if ( ! $assoc2->isCascadeMerge) {
$other = $class->reflFields[$name]->getValue($entity); $other = $class->reflFields[$name]->getValue($entity); //TODO: Just $prop->getValue($entity)?
if ($other !== null) { if ($other !== null) {
$targetClass = $this->_em->getClassMetadata($assoc2->targetEntityName); $targetClass = $this->_em->getClassMetadata($assoc2->targetEntityName);
$id = $targetClass->getIdentifierValues($other); $id = $targetClass->getIdentifierValues($other);
......
...@@ -29,7 +29,6 @@ class AllTests ...@@ -29,7 +29,6 @@ class AllTests
$suite->addTest(Collections\AllTests::suite()); $suite->addTest(Collections\AllTests::suite());
$suite->addTest(Annotations\AllTests::suite()); $suite->addTest(Annotations\AllTests::suite());
$suite->addTest(Cache\AllTests::suite()); $suite->addTest(Cache\AllTests::suite());
$suite->addTest(CLI\AllTests::suite());
return $suite; return $suite;
} }
......
<?php
namespace Doctrine\Tests\Common\CLI;
if (!defined('PHPUnit_MAIN_METHOD')) {
define('PHPUnit_MAIN_METHOD', 'Common_Cli_AllTests::main');
}
require_once __DIR__ . '/../../TestInit.php';
class AllTests
{
public static function main()
{
\PHPUnit_TextUI_TestRunner::run(self::suite());
}
public static function suite()
{
$suite = new \Doctrine\Tests\DoctrineTestSuite('Doctrine Common CLI Tests');
$suite->addTestSuite('Doctrine\Tests\Common\CLI\ConfigurationTest');
$suite->addTestSuite('Doctrine\Tests\Common\CLI\OptionTest');
$suite->addTestSuite('Doctrine\Tests\Common\CLI\OptionGroupTest');
$suite->addTestSuite('Doctrine\Tests\Common\CLI\StyleTest');
//$suite->addTestSuite('Doctrine\Tests\Common\CLI\CLIControllerTest');
return $suite;
}
}
if (PHPUnit_MAIN_METHOD == 'Common_CLI_AllTests::main') {
AllTests::main();
}
\ No newline at end of file
<?php
namespace Doctrine\Tests\Common\CLI;
use Doctrine\Tests\Mocks\TaskMock;
use Doctrine\Common\CLI\Configuration;
use Doctrine\Common\CLI\CliController;
require_once __DIR__ . '/../../TestInit.php';
/**
* @author Nils Adermann <naderman@naderman.de>
*/
class CLIControllerTest extends \Doctrine\Tests\DoctrineTestCase
{
private $cli;
/**
* Sets up a CLIController instance with a task referencing the TaskMock
* class. Instances of that class created by the CLIController can be
* inspected for correctness.
*/
function setUp()
{
$config = $this->getMock('\Doctrine\Common\CLI\Configuration');
$printer = $this->getMockForAbstractClass('\Doctrine\Common\CLI\Printers\AbstractPrinter');
$this->cli = new CLIController($config, $printer);
TaskMock::$instances = array();
$this->cli->addTask('task-mock', '\Doctrine\Tests\Mocks\TaskMock');
}
/**
* Data provider with a bunch of task-mock calls with different arguments
* and their expected parsed format.
*/
static public function dataCLIControllerArguments()
{
return array(
array(
array('doctrine', 'Core:task-mock', '--bool'),
array('bool' => true),
'Bool option'
),
array(
array('doctrine', 'Core:task-mock', '--option=value'),
array('option' => 'value'),
'Option with string value'
),
array(
array('doctrine', 'Core:task-mock', '--option=value, with additional, info'),
array('option' => 'value, with additional, info'),
'Option with string value containing space and comma'
),
array(
array('doctrine', 'Core:task-mock', '--option='),
array('option' => array()),
'Empty option value'
),
array(
array('doctrine', 'Core:task-mock', '--option=value1,value2,value3'),
array('option' => array('value1', 'value2', 'value3')),
'Option with list of string values'
),
);
}
/**
* Checks whether the arguments coming from the data provider are correctly
* parsed by the CLIController and passed to the task to be run.
*
* @dataProvider dataCLIControllerArguments
* @param array $rawArgs
* @param array $parsedArgs
* @param string $message
*/
public function testArgumentParsing($rawArgs, $parsedArgs, $message)
{
$this->cli->run($rawArgs);
$this->assertEquals(count(TaskMock::$instances), 1);
$task = TaskMock::$instances[0];
$this->assertEquals($task->getArguments(), $parsedArgs, $message);
}
/**
* Checks whether multiple tasks in one command are correctly run with
* their respective options.
*/
public function testMultipleTaskExecution()
{
$this->cli->run(array(
'doctrine',
'Core:task-mock',
'--option=',
'Core:task-mock',
'--bool'
));
$this->assertEquals(count(TaskMock::$instances), 2);
$task0 = TaskMock::$instances[0];
$task1 = TaskMock::$instances[1];
$this->assertEquals($task0->getRunCounter(), 1);
$this->assertEquals($task1->getRunCounter(), 1);
$this->assertEquals($task0->getArguments(), array('option' => array()));
$this->assertEquals($task1->getArguments(), array('bool' => true));
}
}
<?php
namespace Doctrine\Tests\Common\CLI;
use Doctrine\Common\CLI\Configuration;
require_once __DIR__ . '/../../TestInit.php';
class ConfigurationTest extends \Doctrine\Tests\DoctrineTestCase
{
public function testConfiguration()
{
$config = new Configuration();
$config->setAttribute('name', 'value');
$this->assertTrue($config->hasAttribute('name'));
$this->assertEquals('value', $config->hasAttribute('name'));
$config->setAttribute('name');
$this->assertFalse($config->hasAttribute('name'));
}
}
\ No newline at end of file
<?php
namespace Doctrine\Tests\Common\CLI;
use Doctrine\Common\CLI\Printers\NormalPrinter,
Doctrine\Common\CLI\OptionGroup,
Doctrine\Common\CLI\Option;
require_once __DIR__ . '/../../TestInit.php';
class OptionGroupTest extends \Doctrine\Tests\DoctrineTestCase
{
private $_options = array();
public function setUp()
{
$this->_printer = new NormalPrinter();
$this->_options[0] = new Option('name', null, 'First option description');
$this->_options[1] = new Option('another-name', 'value', 'Second option description');
$this->_options[2] = new Option('third-name', array('value1', 'value2'), 'Third option description');
}
public function testCommonFunctionality()
{
$optionGroup = new OptionGroup(OptionGroup::CARDINALITY_0_N, $this->_options);
$this->assertEquals(3, count($optionGroup->getOptions()));
$this->assertEquals(
'--name First option description' . PHP_EOL . PHP_EOL .
'--another-name=value Second option description' . PHP_EOL . PHP_EOL .
'--third-name=value1,value2 Third option description' . PHP_EOL . PHP_EOL,
$optionGroup->formatWithDescription($this->_printer)
);
$optionGroup->clear();
$this->assertEquals(0, count($optionGroup->getOptions()));
$this->assertEquals('', $optionGroup->formatPlain($this->_printer));
$this->assertEquals(
'No available options' . PHP_EOL . PHP_EOL,
$optionGroup->formatWithDescription($this->_printer)
);
$optionGroup->addOption($this->_options[0]);
$optionGroup->addOption($this->_options[1]);
$this->assertEquals(2, count($optionGroup->getOptions()));
}
public function testCardinality0toN()
{
$optionGroup = new OptionGroup(OptionGroup::CARDINALITY_0_N, $this->_options);
$this->assertEquals(OptionGroup::CARDINALITY_0_N, $optionGroup->getCardinality());
$this->assertEquals(
'[--name] [--another-name=value] [--third-name=value1,value2]',
$optionGroup->formatPlain($this->_printer)
);
}
public function testCardinality0to1()
{
$optionGroup = new OptionGroup(OptionGroup::CARDINALITY_0_1, $this->_options);
$this->assertEquals(OptionGroup::CARDINALITY_0_1, $optionGroup->getCardinality());
$this->assertEquals(
'[--name | --another-name=value | --third-name=value1,value2]',
$optionGroup->formatPlain($this->_printer)
);
}
public function testCardinality1to1()
{
$optionGroup = new OptionGroup(OptionGroup::CARDINALITY_1_1, $this->_options);
$this->assertEquals(OptionGroup::CARDINALITY_1_1, $optionGroup->getCardinality());
$this->assertEquals(
'(--name | --another-name=value | --third-name=value1,value2)',
$optionGroup->formatPlain($this->_printer)
);
}
public function testCardinality1toN()
{
$optionGroup = new OptionGroup(OptionGroup::CARDINALITY_1_N, $this->_options);
$this->assertEquals(OptionGroup::CARDINALITY_1_N, $optionGroup->getCardinality());
$this->assertEquals(
'(--name --another-name=value --third-name=value1,value2)',
$optionGroup->formatPlain($this->_printer)
);
}
public function testCardinalityNtoN()
{
$optionGroup = new OptionGroup(OptionGroup::CARDINALITY_N_N, $this->_options);
$this->assertEquals(OptionGroup::CARDINALITY_N_N, $optionGroup->getCardinality());
$this->assertEquals(
'--name --another-name=value --third-name=value1,value2',
$optionGroup->formatPlain($this->_printer)
);
}
public function testCardinalityMtoN()
{
$optionGroup = new OptionGroup(OptionGroup::CARDINALITY_M_N, $this->_options);
$this->assertEquals(OptionGroup::CARDINALITY_M_N, $optionGroup->getCardinality());
$this->assertEquals(
'--name --another-name=value --third-name=value1,value2',
$optionGroup->formatPlain($this->_printer)
);
}
}
\ No newline at end of file
<?php
namespace Doctrine\Tests\Common\CLI;
use Doctrine\Common\CLI\Option;
require_once __DIR__ . '/../../TestInit.php';
class OptionTest extends \Doctrine\Tests\DoctrineTestCase
{
public function testGetMethods()
{
$option = new Option('name', 'value', 'Description');
$this->assertEquals('name', $option->getName());
$this->assertEquals('value', $option->getDefaultValue());
$this->assertEquals('Description', $option->getDescription());
}
public function testStringCastWithDefaultValue()
{
$option = new Option('name', 'value', 'Description');
$this->assertEquals('--name=value', (string) $option);
}
public function testStringCastWithoutDefaultValue()
{
$option = new Option('name', null, 'Description');
$this->assertEquals('--name', (string) $option);
}
public function testStringCastWithArrayDefaultValue()
{
$option = new Option('name', array('value1', 'value2'), 'Description');
$this->assertEquals('--name=value1,value2', (string) $option);
}
}
\ No newline at end of file
<?php
namespace Doctrine\Tests\Common\CLI;
use Doctrine\Common\CLI\Style;
require_once __DIR__ . '/../../TestInit.php';
class StyleTest extends \Doctrine\Tests\DoctrineTestCase
{
public function testGetMethods()
{
$style = new Style('BLACK', 'WHITE', array('BOLD' => true));
$this->assertEquals('BLACK', $style->getForeground());
$this->assertEquals('WHITE', $style->getBackground());
$this->assertEquals(array('BOLD' => true), $style->getOptions());
}
}
\ No newline at end of file
...@@ -13,23 +13,22 @@ class CmsAddress ...@@ -13,23 +13,22 @@ class CmsAddress
{ {
/** /**
* @Column(type="integer") * @Column(type="integer")
* @Id * @Id @GeneratedValue
* @GeneratedValue(strategy="AUTO")
*/ */
public $id; public $id;
/** /**
* @Column(type="string", length=50) * @Column(length=50)
*/ */
public $country; public $country;
/** /**
* @Column(type="string", length=50) * @Column(length=50)
*/ */
public $zip; public $zip;
/** /**
* @Column(type="string", length=50) * @Column(length=50)
*/ */
public $city; public $city;
...@@ -39,8 +38,7 @@ class CmsAddress ...@@ -39,8 +38,7 @@ class CmsAddress
public $street; public $street;
/** /**
* @OneToOne(targetEntity="CmsUser") * @OneToOne(targetEntity="CmsUser", inversedBy="address")
// * @JoinColumn(name="user_id", referencedColumnName="id")
*/ */
public $user; public $user;
......
...@@ -23,7 +23,7 @@ class CmsArticle ...@@ -23,7 +23,7 @@ class CmsArticle
*/ */
public $text; public $text;
/** /**
* @ManyToOne(targetEntity="CmsUser") * @ManyToOne(targetEntity="CmsUser", inversedBy="articles")
* @JoinColumn(name="user_id", referencedColumnName="id") * @JoinColumn(name="user_id", referencedColumnName="id")
*/ */
public $user; public $user;
......
...@@ -23,7 +23,7 @@ class CmsComment ...@@ -23,7 +23,7 @@ class CmsComment
*/ */
public $text; public $text;
/** /**
* @ManyToOne(targetEntity="CmsArticle") * @ManyToOne(targetEntity="CmsArticle", inversedBy="comments")
* @JoinColumn(name="article_id", referencedColumnName="id") * @JoinColumn(name="article_id", referencedColumnName="id")
*/ */
public $article; public $article;
......
...@@ -14,12 +14,12 @@ class CmsEmployee ...@@ -14,12 +14,12 @@ class CmsEmployee
/** /**
* @Id * @Id
* @Column(type="integer") * @Column(type="integer")
* @GeneratedValue(strategy="AUTO") * @GeneratedValue
*/ */
private $id; private $id;
/** /**
* @Column(type="string") * @Column
*/ */
private $name; private $name;
......
...@@ -18,11 +18,11 @@ class CmsGroup ...@@ -18,11 +18,11 @@ class CmsGroup
/** /**
* @Id * @Id
* @Column(type="integer") * @Column(type="integer")
* @GeneratedValue(strategy="AUTO") * @GeneratedValue
*/ */
public $id; public $id;
/** /**
* @Column(type="string", length=50) * @Column(length=50)
*/ */
public $name; public $name;
/** /**
......
...@@ -9,11 +9,11 @@ namespace Doctrine\Tests\Models\CMS; ...@@ -9,11 +9,11 @@ namespace Doctrine\Tests\Models\CMS;
class CmsPhonenumber class CmsPhonenumber
{ {
/** /**
* @Id @Column(type="string", length=50) * @Id @Column(length=50)
*/ */
public $phonenumber; public $phonenumber;
/** /**
* @ManyToOne(targetEntity="CmsUser") * @ManyToOne(targetEntity="CmsUser", inversedBy="phonenumbers")
* @JoinColumn(name="user_id", referencedColumnName="id") * @JoinColumn(name="user_id", referencedColumnName="id")
*/ */
public $user; public $user;
......
...@@ -40,7 +40,7 @@ class CmsUser ...@@ -40,7 +40,7 @@ class CmsUser
*/ */
public $address; public $address;
/** /**
* @ManyToMany(targetEntity="CmsGroup", cascade={"persist"}) * @ManyToMany(targetEntity="CmsGroup", inversedBy="users", cascade={"persist"})
* @JoinTable(name="cms_users_groups", * @JoinTable(name="cms_users_groups",
* joinColumns={@JoinColumn(name="user_id", referencedColumnName="id")}, * joinColumns={@JoinColumn(name="user_id", referencedColumnName="id")},
* inverseJoinColumns={@JoinColumn(name="group_id", referencedColumnName="id")} * inverseJoinColumns={@JoinColumn(name="group_id", referencedColumnName="id")}
......
...@@ -11,12 +11,12 @@ namespace Doctrine\Tests\Models\Company; ...@@ -11,12 +11,12 @@ namespace Doctrine\Tests\Models\Company;
class CompanyEvent { class CompanyEvent {
/** /**
* @Id @Column(type="integer") * @Id @Column(type="integer")
* @GeneratedValue(strategy="AUTO") * @GeneratedValue
*/ */
private $id; private $id;
/** /**
* @ManyToOne(targetEntity="CompanyOrganization",cascade={"persist"}) * @ManyToOne(targetEntity="CompanyOrganization", inversedBy="events", cascade={"persist"})
* @JoinColumn(name="org_id", referencedColumnName="id") * @JoinColumn(name="org_id", referencedColumnName="id")
*/ */
private $organization; private $organization;
......
...@@ -20,11 +20,11 @@ class CompanyPerson ...@@ -20,11 +20,11 @@ class CompanyPerson
/** /**
* @Id * @Id
* @Column(type="integer") * @Column(type="integer")
* @GeneratedValue(strategy="AUTO") * @GeneratedValue
*/ */
private $id; private $id;
/** /**
* @Column(type="string") * @Column
*/ */
private $name; private $name;
/** /**
......
...@@ -4,7 +4,7 @@ namespace Doctrine\Tests\Models\Company; ...@@ -4,7 +4,7 @@ namespace Doctrine\Tests\Models\Company;
/** @Entity @Table(name="company_raffles") */ /** @Entity @Table(name="company_raffles") */
class CompanyRaffle extends CompanyEvent { class CompanyRaffle extends CompanyEvent {
/** @Column(type="string") */ /** @Column */
private $data; private $data;
public function setData($data) { public function setData($data) {
......
...@@ -17,17 +17,17 @@ class ECommerceCart ...@@ -17,17 +17,17 @@ class ECommerceCart
/** /**
* @Column(type="integer") * @Column(type="integer")
* @Id * @Id
* @GeneratedValue(strategy="AUTO") * @GeneratedValue
*/ */
private $id; private $id;
/** /**
* @Column(type="string", length=50, nullable=true) * @Column(length=50, nullable=true)
*/ */
private $payment; private $payment;
/** /**
* @OneToOne(targetEntity="ECommerceCustomer") * @OneToOne(targetEntity="ECommerceCustomer", inversedBy="cart")
* @JoinColumn(name="customer_id", referencedColumnName="id") * @JoinColumn(name="customer_id", referencedColumnName="id")
*/ */
private $customer; private $customer;
......
...@@ -36,7 +36,7 @@ class ECommerceCategory ...@@ -36,7 +36,7 @@ class ECommerceCategory
private $children; private $children;
/** /**
* @ManyToOne(targetEntity="ECommerceCategory") * @ManyToOne(targetEntity="ECommerceCategory", inversedBy="children")
* @JoinColumn(name="parent_id", referencedColumnName="id") * @JoinColumn(name="parent_id", referencedColumnName="id")
*/ */
private $parent; private $parent;
......
...@@ -14,17 +14,17 @@ class ECommerceFeature ...@@ -14,17 +14,17 @@ class ECommerceFeature
/** /**
* @Column(type="integer") * @Column(type="integer")
* @Id * @Id
* @GeneratedValue(strategy="AUTO") * @GeneratedValue
*/ */
private $id; private $id;
/** /**
* @Column(type="string", length=50) * @Column(length=50)
*/ */
private $description; private $description;
/** /**
* @ManyToOne(targetEntity="ECommerceProduct") * @ManyToOne(targetEntity="ECommerceProduct", inversedBy="features")
* @JoinColumn(name="product_id", referencedColumnName="id") * @JoinColumn(name="product_id", referencedColumnName="id")
*/ */
private $product; private $product;
......
...@@ -10,14 +10,14 @@ use Doctrine\Common\Collections\ArrayCollection; ...@@ -10,14 +10,14 @@ use Doctrine\Common\Collections\ArrayCollection;
* *
* @author Giorgio Sironi * @author Giorgio Sironi
* @Entity * @Entity
* @Table(name="ecommerce_products",indexes={@index(name="name_idx", columns={"name"})}) * @Table(name="ecommerce_products",indexes={@Index(name="name_idx", columns={"name"})})
*/ */
class ECommerceProduct class ECommerceProduct
{ {
/** /**
* @Column(type="integer") * @Column(type="integer")
* @Id * @Id
* @GeneratedValue(strategy="AUTO") * @GeneratedValue
*/ */
private $id; private $id;
...@@ -38,7 +38,7 @@ class ECommerceProduct ...@@ -38,7 +38,7 @@ class ECommerceProduct
private $features; private $features;
/** /**
* @ManyToMany(targetEntity="ECommerceCategory", cascade={"persist"}) * @ManyToMany(targetEntity="ECommerceCategory", cascade={"persist"}, inversedBy="products")
* @JoinTable(name="ecommerce_products_categories", * @JoinTable(name="ecommerce_products_categories",
* joinColumns={@JoinColumn(name="product_id", referencedColumnName="id")}, * joinColumns={@JoinColumn(name="product_id", referencedColumnName="id")},
* inverseJoinColumns={@JoinColumn(name="category_id", referencedColumnName="id")}) * inverseJoinColumns={@JoinColumn(name="category_id", referencedColumnName="id")})
...@@ -50,8 +50,8 @@ class ECommerceProduct ...@@ -50,8 +50,8 @@ class ECommerceProduct
* simplicity. * simplicity.
* @ManyToMany(targetEntity="ECommerceProduct", cascade={"persist"}) * @ManyToMany(targetEntity="ECommerceProduct", cascade={"persist"})
* @JoinTable(name="ecommerce_products_related", * @JoinTable(name="ecommerce_products_related",
joinColumns={@JoinColumn(name="product_id", referencedColumnName="id")}, * joinColumns={@JoinColumn(name="product_id", referencedColumnName="id")},
inverseJoinColumns={@JoinColumn(name="related_id", referencedColumnName="id")}) * inverseJoinColumns={@JoinColumn(name="related_id", referencedColumnName="id")})
*/ */
private $related; private $related;
......
...@@ -14,7 +14,7 @@ class ECommerceShipping ...@@ -14,7 +14,7 @@ class ECommerceShipping
{ {
/** /**
* @Id @Column(type="integer") * @Id @Column(type="integer")
* @GeneratedValue(strategy="AUTO") * @GeneratedValue
*/ */
private $id; private $id;
......
...@@ -21,7 +21,7 @@ class ForumBoard ...@@ -21,7 +21,7 @@ class ForumBoard
*/ */
public $position; public $position;
/** /**
* @ManyToOne(targetEntity="ForumCategory") * @ManyToOne(targetEntity="ForumCategory", inversedBy="boards")
* @JoinColumn(name="category_id", referencedColumnName="id") * @JoinColumn(name="category_id", referencedColumnName="id")
*/ */
public $category; public $category;
......
...@@ -10,8 +10,7 @@ class ForumUser ...@@ -10,8 +10,7 @@ class ForumUser
{ {
/** /**
* @Column(type="integer") * @Column(type="integer")
* @Id * @Id @GeneratedValue
* @GeneratedValue(strategy="AUTO")
*/ */
public $id; public $id;
/** /**
......
...@@ -10,7 +10,7 @@ class DateTimeModel ...@@ -10,7 +10,7 @@ class DateTimeModel
{ {
/** /**
* @Id @Column(type="integer") * @Id @Column(type="integer")
* @GeneratedValue(strategy="AUTO") * @GeneratedValue
*/ */
public $id; public $id;
/** /**
......
...@@ -8,20 +8,19 @@ namespace Doctrine\Tests\Models\Routing; ...@@ -8,20 +8,19 @@ namespace Doctrine\Tests\Models\Routing;
class RoutingLeg class RoutingLeg
{ {
/** /**
* @Id * @Id @generatedValue
* @generatedValue(strategy="AUTO")
* @column(type="integer") * @column(type="integer")
*/ */
public $id; public $id;
/** /**
* @ManyToOne(targetEntity="Doctrine\Tests\Models\Routing\RoutingLocation") * @ManyToOne(targetEntity="RoutingLocation")
* @JoinColumn(name="from_id", referencedColumnName="id") * @JoinColumn(name="from_id", referencedColumnName="id")
*/ */
public $fromLocation; public $fromLocation;
/** /**
* @ManyToOne(targetEntity="Doctrine\Tests\Models\Routing\RoutingLocation") * @ManyToOne(targetEntity="RoutingLocation")
* @JoinColumn(name="to_id", referencedColumnName="id") * @JoinColumn(name="to_id", referencedColumnName="id")
*/ */
public $toLocation; public $toLocation;
......
...@@ -8,8 +8,7 @@ namespace Doctrine\Tests\Models\Routing; ...@@ -8,8 +8,7 @@ namespace Doctrine\Tests\Models\Routing;
class RoutingLocation class RoutingLocation
{ {
/** /**
* @Id * @Id @GeneratedValue
* @generatedValue(strategy="AUTO")
* @Column(type="integer") * @Column(type="integer")
*/ */
public $id; public $id;
......
...@@ -11,7 +11,7 @@ class RoutingRoute ...@@ -11,7 +11,7 @@ class RoutingRoute
{ {
/** /**
* @Id * @Id
* @generatedValue(strategy="AUTO") * @GeneratedValue
* @column(type="integer") * @column(type="integer")
*/ */
public $id; public $id;
......
...@@ -10,12 +10,12 @@ class RoutingRouteBooking ...@@ -10,12 +10,12 @@ class RoutingRouteBooking
/** /**
* @Id * @Id
* @Column(type="integer") * @Column(type="integer")
* @generatedValue(strategy="AUTO") * @GeneratedValue
*/ */
public $id; public $id;
/** /**
* @ManyToOne(targetEntity="RoutingRoute") * @ManyToOne(targetEntity="RoutingRoute", inversedBy="bookings")
* @JoinColumn(name="route_id", referencedColumnName="id") * @JoinColumn(name="route_id", referencedColumnName="id")
*/ */
public $route; public $route;
......
...@@ -43,21 +43,21 @@ class DDC144Test extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -43,21 +43,21 @@ class DDC144Test extends \Doctrine\Tests\OrmFunctionalTestCase
*/ */
class DDC144FlowElement { class DDC144FlowElement {
/** /**
* @Id @Column(type="integer") @GeneratedValue(strategy="AUTO") * @Id @Column(type="integer") @GeneratedValue
* @var integer * @var integer
*/ */
public $id; public $id;
/** @Column(type="string") */ /** @Column */
public $property; public $property;
} }
// /** @Entity @Table(name="ddc144_expressions") */
abstract class DDC144Expression extends DDC144FlowElement { abstract class DDC144Expression extends DDC144FlowElement {
abstract function method(); abstract function method();
} }
/** @Entity @Table(name="ddc144_operands") */ /** @Entity @Table(name="ddc144_operands") */
class DDC144Operand extends DDC144Expression { class DDC144Operand extends DDC144Expression {
/** @Column(type="string") */ /** @Column */
public $operandProperty; public $operandProperty;
function method() {} function method() {}
} }
......
...@@ -79,7 +79,7 @@ class DDC199ParentClass ...@@ -79,7 +79,7 @@ class DDC199ParentClass
class DDC199ChildClass extends DDC199ParentClass class DDC199ChildClass extends DDC199ParentClass
{ {
/** /**
* @Column(type="string") * @Column
*/ */
public $childData; public $childData;
} }
...@@ -87,13 +87,13 @@ class DDC199ChildClass extends DDC199ParentClass ...@@ -87,13 +87,13 @@ class DDC199ChildClass extends DDC199ParentClass
/** @Entity @Table(name="ddc199_relatedclass") */ /** @Entity @Table(name="ddc199_relatedclass") */
class DDC199RelatedClass class DDC199RelatedClass
{ {
/** @Id @Column(type="integer") @GeneratedValue(strategy="AUTO") */ /** @Id @Column(type="integer") @GeneratedValue */
public $id; public $id;
/** @Column(type="string") */ /** @Column */
public $relatedData; public $relatedData;
/** /**
* @ManyToOne(targetEntity="DDC199ParentClass") * @ManyToOne(targetEntity="DDC199ParentClass", inversedBy="relatedEntities")
* @JoinColumn(name="parent_id", referencedColumnName="id") * @JoinColumn(name="parent_id", referencedColumnName="id")
*/ */
public $parent; public $parent;
......
...@@ -65,7 +65,7 @@ class DDC211User ...@@ -65,7 +65,7 @@ class DDC211User
protected $name; protected $name;
/** /**
* @ManyToMany(targetEntity="DDC211Group") * @ManyToMany(targetEntity="DDC211Group", inversedBy="users")
* @JoinTable(name="user_groups", * @JoinTable(name="user_groups",
* joinColumns={@JoinColumn(name="user_id", referencedColumnName="id")}, * joinColumns={@JoinColumn(name="user_id", referencedColumnName="id")},
* inverseJoinColumns={@JoinColumn(name="group_id", referencedColumnName="id")} * inverseJoinColumns={@JoinColumn(name="group_id", referencedColumnName="id")}
......
...@@ -68,7 +68,7 @@ class DDC237Test extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -68,7 +68,7 @@ class DDC237Test extends \Doctrine\Tests\OrmFunctionalTestCase
class DDC237EntityX class DDC237EntityX
{ {
/** /**
* @Id @Column(type="integer") @GeneratedValue(strategy="AUTO") * @Id @Column(type="integer") @GeneratedValue
*/ */
public $id; public $id;
/** /**
...@@ -87,7 +87,7 @@ class DDC237EntityX ...@@ -87,7 +87,7 @@ class DDC237EntityX
class DDC237EntityY class DDC237EntityY
{ {
/** /**
* @Id @Column(type="integer") @GeneratedValue(strategy="AUTO") * @Id @Column(type="integer") @GeneratedValue
*/ */
public $id; public $id;
/** /**
...@@ -99,7 +99,7 @@ class DDC237EntityY ...@@ -99,7 +99,7 @@ class DDC237EntityY
/** @Entity @Table(name="ddc237_z") */ /** @Entity @Table(name="ddc237_z") */
class DDC237EntityZ class DDC237EntityZ
{ {
/** @Id @Column(type="integer") @GeneratedValue(strategy="AUTO") */ /** @Id @Column(type="integer") @GeneratedValue */
public $id; public $id;
/** @Column(type="string") */ /** @Column(type="string") */
public $data; public $data;
......
...@@ -68,7 +68,7 @@ abstract class DDC279EntityXAbstract ...@@ -68,7 +68,7 @@ abstract class DDC279EntityXAbstract
{ {
/** /**
* @Id * @Id
* @generatedValue(strategy="AUTO") * @GeneratedValue
* @Column(name="id", type="integer") * @Column(name="id", type="integer")
*/ */
public $id; public $id;
...@@ -98,8 +98,7 @@ class DDC279EntityX extends DDC279EntityXAbstract ...@@ -98,8 +98,7 @@ class DDC279EntityX extends DDC279EntityXAbstract
class DDC279EntityY class DDC279EntityY
{ {
/** /**
* @Id * @Id @GeneratedValue
* @generatedValue(strategy="AUTO")
* @Column(name="id", type="integer") * @Column(name="id", type="integer")
*/ */
public $id; public $id;
...@@ -122,8 +121,7 @@ class DDC279EntityY ...@@ -122,8 +121,7 @@ class DDC279EntityY
class DDC279EntityZ class DDC279EntityZ
{ {
/** /**
* @Id * @Id @GeneratedValue
* @generatedValue(strategy="AUTO")
* @Column(name="id", type="integer") * @Column(name="id", type="integer")
*/ */
public $id; public $id;
......
...@@ -54,7 +54,7 @@ class DDC309Country ...@@ -54,7 +54,7 @@ class DDC309Country
/** /**
* @Id * @Id
* @Column(name="id", type="integer") * @Column(name="id", type="integer")
* @GeneratedValue(strategy="AUTO") * @GeneratedValue
*/ */
public $id; public $id;
} }
...@@ -67,7 +67,7 @@ class DDC309User ...@@ -67,7 +67,7 @@ class DDC309User
/** /**
* @Id * @Id
* @Column(name="id", type="integer") * @Column(name="id", type="integer")
* @GeneratedValue(strategy="AUTO") * @GeneratedValue
*/ */
public $id; public $id;
} }
...@@ -118,13 +118,13 @@ class DDC345Membership ...@@ -118,13 +118,13 @@ class DDC345Membership
public $id; public $id;
/** /**
* @OneToOne(targetEntity="DDC345User") * @OneToOne(targetEntity="DDC345User", inversedBy="Memberships")
* @JoinColumn(name="user_id", referencedColumnName="id", nullable=false) * @JoinColumn(name="user_id", referencedColumnName="id", nullable=false)
*/ */
public $user; public $user;
/** /**
* @OneToOne(targetEntity="DDC345Group") * @OneToOne(targetEntity="DDC345Group", inversedBy="Memberships")
* @JoinColumn(name="group_id", referencedColumnName="id", nullable=false) * @JoinColumn(name="group_id", referencedColumnName="id", nullable=false)
*/ */
public $group; public $group;
......
...@@ -78,8 +78,7 @@ class DDC353Picture ...@@ -78,8 +78,7 @@ class DDC353Picture
{ {
/** /**
* @Column(name="picture_id", type="integer") * @Column(name="picture_id", type="integer")
* @Id * @Id @GeneratedValue
* @GeneratedValue(strategy="AUTO")
*/ */
private $pictureId; private $pictureId;
......
...@@ -53,7 +53,7 @@ class DDC371Child { ...@@ -53,7 +53,7 @@ class DDC371Child {
private $id; private $id;
/** @Column(type="string") */ /** @Column(type="string") */
public $data; public $data;
/** @ManyToOne(targetEntity="DDC371Parent") @JoinColumn(name="parentId") */ /** @ManyToOne(targetEntity="DDC371Parent", inversedBy="children") @JoinColumn(name="parentId") */
public $parent; public $parent;
} }
......
...@@ -47,7 +47,7 @@ class DDC381Test extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -47,7 +47,7 @@ class DDC381Test extends \Doctrine\Tests\OrmFunctionalTestCase
class DDC381Entity class DDC381Entity
{ {
/** /**
* @Id @Column(type="integer") @generatedValue * @Id @Column(type="integer") @GeneratedValue
*/ */
protected $id; protected $id;
......
...@@ -212,7 +212,7 @@ class Relation { ...@@ -212,7 +212,7 @@ class Relation {
/** /**
* @var Lemma * @var Lemma
* @ManyToOne(targetEntity="Lemma") * @ManyToOne(targetEntity="Lemma", inversedBy="relations")
* @JoinColumn(name="relation_parent_id", referencedColumnName="lemma_id") * @JoinColumn(name="relation_parent_id", referencedColumnName="lemma_id")
*/ */
private $parent; private $parent;
...@@ -226,7 +226,7 @@ class Relation { ...@@ -226,7 +226,7 @@ class Relation {
/** /**
* @var RelationType * @var RelationType
* @ManyToOne(targetEntity="RelationType") * @ManyToOne(targetEntity="RelationType", inversedBy="relations")
* @JoinColumn(name="relation_type_id", referencedColumnName="relation_type_id") * @JoinColumn(name="relation_type_id", referencedColumnName="relation_type_id")
*/ */
private $type; private $type;
......
...@@ -73,7 +73,6 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase ...@@ -73,7 +73,6 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
public function testAssocations($class) public function testAssocations($class)
{ {
$this->assertEquals(3, count($class->associationMappings)); $this->assertEquals(3, count($class->associationMappings));
$this->assertEquals(1, count($class->inverseMappings));
return $class; return $class;
} }
...@@ -87,6 +86,7 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase ...@@ -87,6 +86,7 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
$this->assertTrue($class->associationMappings['address'] instanceof \Doctrine\ORM\Mapping\OneToOneMapping); $this->assertTrue($class->associationMappings['address'] instanceof \Doctrine\ORM\Mapping\OneToOneMapping);
$this->assertTrue(isset($class->associationMappings['address'])); $this->assertTrue(isset($class->associationMappings['address']));
$this->assertTrue($class->associationMappings['address']->isOwningSide); $this->assertTrue($class->associationMappings['address']->isOwningSide);
$this->assertEquals('user', $class->associationMappings['address']->inversedBy);
// Check cascading // Check cascading
$this->assertTrue($class->associationMappings['address']->isCascadeRemove); $this->assertTrue($class->associationMappings['address']->isCascadeRemove);
$this->assertFalse($class->associationMappings['address']->isCascadePersist); $this->assertFalse($class->associationMappings['address']->isCascadePersist);
...@@ -223,13 +223,12 @@ class User ...@@ -223,13 +223,12 @@ class User
public $email; public $email;
/** /**
* @OneToOne(targetEntity="Address", cascade={"remove"}) * @OneToOne(targetEntity="Address", cascade={"remove"}, inversedBy="user")
* @JoinColumn(onDelete="CASCADE", onUpdate="CASCADE") * @JoinColumn(onDelete="CASCADE", onUpdate="CASCADE")
*/ */
public $address; public $address;
/** /**
*
* @OneToMany(targetEntity="Phonenumber", mappedBy="user", cascade={"persist"}) * @OneToMany(targetEntity="Phonenumber", mappedBy="user", cascade={"persist"})
* @OrderBy({"number"="ASC"}) * @OrderBy({"number"="ASC"})
*/ */
......
...@@ -100,8 +100,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase ...@@ -100,8 +100,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
$this->assertTrue($assoc instanceof \Doctrine\ORM\Mapping\ManyToManyMapping); $this->assertTrue($assoc instanceof \Doctrine\ORM\Mapping\ManyToManyMapping);
$this->assertEquals(array( $this->assertEquals(array(
'name' => 'CmsUser_CmsGroup', 'name' => 'CmsUser_CmsGroup',
'joinColumns' => array(array('name' => 'CmsUser_id', 'referencedColumnName' => 'id')), 'joinColumns' => array(array('name' => 'CmsUser_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE')),
'inverseJoinColumns' => array(array('name' => 'CmsGroup_id', 'referencedColumnName' => 'id')) 'inverseJoinColumns' => array(array('name' => 'CmsGroup_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE'))
), $assoc->joinTable); ), $assoc->joinTable);
} }
......
...@@ -39,6 +39,7 @@ $metadata->mapOneToOne(array( ...@@ -39,6 +39,7 @@ $metadata->mapOneToOne(array(
0 => 'remove', 0 => 'remove',
), ),
'mappedBy' => NULL, 'mappedBy' => NULL,
'inversedBy' => 'user',
'joinColumns' => 'joinColumns' =>
array( array(
0 => 0 =>
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<field name="name" column="name" type="string" length="50" nullable="true" unique="true" /> <field name="name" column="name" type="string" length="50" nullable="true" unique="true" />
<field name="email" column="user_email" type="string" column-definition="CHAR(32) NOT NULL" /> <field name="email" column="user_email" type="string" column-definition="CHAR(32) NOT NULL" />
<one-to-one field="address" target-entity="Address"> <one-to-one field="address" target-entity="Address" inversed-by="user">
<cascade><cascade-remove /></cascade> <cascade><cascade-remove /></cascade>
<join-column name="address_id" referenced-column-name="id" on-delete="CASCADE" on-update="CASCADE"/> <join-column name="address_id" referenced-column-name="id" on-delete="CASCADE" on-update="CASCADE"/>
</one-to-one> </one-to-one>
......
...@@ -19,6 +19,7 @@ Doctrine\Tests\ORM\Mapping\User: ...@@ -19,6 +19,7 @@ Doctrine\Tests\ORM\Mapping\User:
oneToOne: oneToOne:
address: address:
targetEntity: Address targetEntity: Address
inversedBy: user
joinColumn: joinColumn:
name: address_id name: address_id
referencedColumnName: id referencedColumnName: id
......
...@@ -13,6 +13,9 @@ require_once __DIR__ . '/../../../lib/Doctrine/Common/ClassLoader.php'; ...@@ -13,6 +13,9 @@ require_once __DIR__ . '/../../../lib/Doctrine/Common/ClassLoader.php';
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine'); $classLoader = new \Doctrine\Common\ClassLoader('Doctrine');
$classLoader->register(); $classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Symfony', __DIR__ . "/../../../lib/vendor");
$classLoader->register();
if (!file_exists(__DIR__."/Proxies")) { if (!file_exists(__DIR__."/Proxies")) {
if (!mkdir(__DIR__."/Proxies")) { if (!mkdir(__DIR__."/Proxies")) {
throw new Exception("Could not create " . __DIR__."/Proxies Folder."); throw new Exception("Could not create " . __DIR__."/Proxies Folder.");
...@@ -24,15 +27,6 @@ if (!file_exists(__DIR__."/ORM/Proxy/generated")) { ...@@ -24,15 +27,6 @@ if (!file_exists(__DIR__."/ORM/Proxy/generated")) {
} }
} }
spl_autoload_register(function($class) {
if (strpos($class, 'Symfony') === 0) {
$file = str_replace("\\", "/", $class);
if (@fopen($class, "r")) {
require_once ($file);
}
}
});
set_include_path( set_include_path(
__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'lib' __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'lib'
. PATH_SEPARATOR . . PATH_SEPARATOR .
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment