Merge master into DDC-117
This commit is contained in:
commit
5bd8ffa53c
@ -21,16 +21,16 @@ if (file_exists($configFile)) {
|
||||
require $configFile;
|
||||
|
||||
foreach ($GLOBALS as $helperSetCandidate) {
|
||||
if ($helperSetCandidate instanceof \Symfony\Components\Console\Helper\HelperSet) {
|
||||
if ($helperSetCandidate instanceof \Symfony\Component\Console\Helper\HelperSet) {
|
||||
$helperSet = $helperSetCandidate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$helperSet = ($helperSet) ?: new \Symfony\Components\Console\Helper\HelperSet();
|
||||
$helperSet = ($helperSet) ?: new \Symfony\Component\Console\Helper\HelperSet();
|
||||
|
||||
$cli = new \Symfony\Components\Console\Application('Doctrine Command Line Interface', Doctrine\ORM\Version::VERSION);
|
||||
$cli = new \Symfony\Component\Console\Application('Doctrine Command Line Interface', Doctrine\ORM\Version::VERSION);
|
||||
$cli->setCatchExceptions(true);
|
||||
$cli->setHelperSet($helperSet);
|
||||
$cli->addCommands(array(
|
||||
|
@ -138,10 +138,16 @@ abstract class AbstractQuery
|
||||
|
||||
/**
|
||||
* Frees the resources used by the query object.
|
||||
*
|
||||
* Resets Parameters, Parameter Types and Query Hints.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function free()
|
||||
{
|
||||
$this->_params = array();
|
||||
$this->_paramTypes = array();
|
||||
$this->_hints = array();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -569,4 +575,14 @@ abstract class AbstractQuery
|
||||
* @return Doctrine\DBAL\Driver\Statement The executed database statement that holds the results.
|
||||
*/
|
||||
abstract protected function _doExecute();
|
||||
|
||||
/**
|
||||
* Cleanup Query resource when clone is called.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
$this->free();
|
||||
}
|
||||
}
|
||||
|
@ -38,17 +38,40 @@ use ReflectionException,
|
||||
*/
|
||||
class ClassMetadataFactory
|
||||
{
|
||||
private $_em;
|
||||
/** The targeted database platform. */
|
||||
private $_targetPlatform;
|
||||
/** The used metadata driver. */
|
||||
private $_driver;
|
||||
/** The event manager instance */
|
||||
private $_evm;
|
||||
/** The used cache driver. */
|
||||
private $_cacheDriver;
|
||||
private $_loadedMetadata = array();
|
||||
private $_initialized = false;
|
||||
/**
|
||||
* @var EntityManager
|
||||
*/
|
||||
private $em;
|
||||
|
||||
/**
|
||||
* @var AbstractPlatform
|
||||
*/
|
||||
private $targetPlatform;
|
||||
|
||||
/**
|
||||
* @var Driver\Driver
|
||||
*/
|
||||
private $driver;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\Common\EventManager
|
||||
*/
|
||||
private $evm;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\Common\Cache\Cache
|
||||
*/
|
||||
private $cacheDriver;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $loadedMetadata = array();
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $initialized = false;
|
||||
|
||||
/**
|
||||
* Creates a new factory instance that uses the given metadata driver implementation.
|
||||
@ -57,7 +80,7 @@ class ClassMetadataFactory
|
||||
*/
|
||||
public function __construct(EntityManager $em)
|
||||
{
|
||||
$this->_em = $em;
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -67,7 +90,7 @@ class ClassMetadataFactory
|
||||
*/
|
||||
public function setCacheDriver($cacheDriver)
|
||||
{
|
||||
$this->_cacheDriver = $cacheDriver;
|
||||
$this->cacheDriver = $cacheDriver;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -77,12 +100,12 @@ class ClassMetadataFactory
|
||||
*/
|
||||
public function getCacheDriver()
|
||||
{
|
||||
return $this->_cacheDriver;
|
||||
return $this->cacheDriver;
|
||||
}
|
||||
|
||||
public function getLoadedMetadata()
|
||||
{
|
||||
return $this->_loadedMetadata;
|
||||
return $this->loadedMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -93,12 +116,12 @@ class ClassMetadataFactory
|
||||
*/
|
||||
public function getAllMetadata()
|
||||
{
|
||||
if ( ! $this->_initialized) {
|
||||
$this->_initialize();
|
||||
if ( ! $this->initialized) {
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
$metadata = array();
|
||||
foreach ($this->_driver->getAllClassNames() as $className) {
|
||||
foreach ($this->driver->getAllClassNames() as $className) {
|
||||
$metadata[] = $this->getMetadataFor($className);
|
||||
}
|
||||
|
||||
@ -109,12 +132,12 @@ class ClassMetadataFactory
|
||||
* Lazy initialization of this stuff, especially the metadata driver,
|
||||
* since these are not needed at all when a metadata cache is active.
|
||||
*/
|
||||
private function _initialize()
|
||||
private function initialize()
|
||||
{
|
||||
$this->_driver = $this->_em->getConfiguration()->getMetadataDriverImpl();
|
||||
$this->_targetPlatform = $this->_em->getConnection()->getDatabasePlatform();
|
||||
$this->_evm = $this->_em->getEventManager();
|
||||
$this->_initialized = true;
|
||||
$this->driver = $this->em->getConfiguration()->getMetadataDriverImpl();
|
||||
$this->targetPlatform = $this->em->getConnection()->getDatabasePlatform();
|
||||
$this->evm = $this->em->getEventManager();
|
||||
$this->initialized = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -125,43 +148,43 @@ class ClassMetadataFactory
|
||||
*/
|
||||
public function getMetadataFor($className)
|
||||
{
|
||||
if ( ! isset($this->_loadedMetadata[$className])) {
|
||||
if ( ! isset($this->loadedMetadata[$className])) {
|
||||
$realClassName = $className;
|
||||
|
||||
// Check for namespace alias
|
||||
if (strpos($className, ':') !== false) {
|
||||
list($namespaceAlias, $simpleClassName) = explode(':', $className);
|
||||
$realClassName = $this->_em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName;
|
||||
$realClassName = $this->em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName;
|
||||
|
||||
if (isset($this->_loadedMetadata[$realClassName])) {
|
||||
if (isset($this->loadedMetadata[$realClassName])) {
|
||||
// We do not have the alias name in the map, include it
|
||||
$this->_loadedMetadata[$className] = $this->_loadedMetadata[$realClassName];
|
||||
$this->loadedMetadata[$className] = $this->loadedMetadata[$realClassName];
|
||||
|
||||
return $this->_loadedMetadata[$realClassName];
|
||||
return $this->loadedMetadata[$realClassName];
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->_cacheDriver) {
|
||||
if (($cached = $this->_cacheDriver->fetch("$realClassName\$CLASSMETADATA")) !== false) {
|
||||
$this->_loadedMetadata[$realClassName] = $cached;
|
||||
if ($this->cacheDriver) {
|
||||
if (($cached = $this->cacheDriver->fetch("$realClassName\$CLASSMETADATA")) !== false) {
|
||||
$this->loadedMetadata[$realClassName] = $cached;
|
||||
} else {
|
||||
foreach ($this->_loadMetadata($realClassName) as $loadedClassName) {
|
||||
$this->_cacheDriver->save(
|
||||
"$loadedClassName\$CLASSMETADATA", $this->_loadedMetadata[$loadedClassName], null
|
||||
foreach ($this->loadMetadata($realClassName) as $loadedClassName) {
|
||||
$this->cacheDriver->save(
|
||||
"$loadedClassName\$CLASSMETADATA", $this->loadedMetadata[$loadedClassName], null
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->_loadMetadata($realClassName);
|
||||
$this->loadMetadata($realClassName);
|
||||
}
|
||||
|
||||
if ($className != $realClassName) {
|
||||
// We do not have the alias name in the map, include it
|
||||
$this->_loadedMetadata[$className] = $this->_loadedMetadata[$realClassName];
|
||||
$this->loadedMetadata[$className] = $this->loadedMetadata[$realClassName];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_loadedMetadata[$className];
|
||||
return $this->loadedMetadata[$className];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -172,7 +195,7 @@ class ClassMetadataFactory
|
||||
*/
|
||||
public function hasMetadataFor($className)
|
||||
{
|
||||
return isset($this->_loadedMetadata[$className]);
|
||||
return isset($this->loadedMetadata[$className]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -185,7 +208,7 @@ class ClassMetadataFactory
|
||||
*/
|
||||
public function setMetadataFor($className, $class)
|
||||
{
|
||||
$this->_loadedMetadata[$className] = $class;
|
||||
$this->loadedMetadata[$className] = $class;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -194,12 +217,12 @@ class ClassMetadataFactory
|
||||
* @param string $name
|
||||
* @return array $parentClasses
|
||||
*/
|
||||
protected function _getParentClasses($name)
|
||||
protected function getParentClasses($name)
|
||||
{
|
||||
// Collect parent classes, ignoring transient (not-mapped) classes.
|
||||
$parentClasses = array();
|
||||
foreach (array_reverse(class_parents($name)) as $parentClass) {
|
||||
if ( ! $this->_driver->isTransient($parentClass)) {
|
||||
if ( ! $this->driver->isTransient($parentClass)) {
|
||||
$parentClasses[] = $parentClass;
|
||||
}
|
||||
}
|
||||
@ -213,37 +236,37 @@ class ClassMetadataFactory
|
||||
* @param string $name The name of the class for which the metadata should get loaded.
|
||||
* @param array $tables The metadata collection to which the loaded metadata is added.
|
||||
*/
|
||||
protected function _loadMetadata($name)
|
||||
protected function loadMetadata($name)
|
||||
{
|
||||
if ( ! $this->_initialized) {
|
||||
$this->_initialize();
|
||||
if ( ! $this->initialized) {
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
$loaded = array();
|
||||
|
||||
$parentClasses = $this->_getParentClasses($name);
|
||||
$parentClasses = $this->getParentClasses($name);
|
||||
$parentClasses[] = $name;
|
||||
|
||||
// Move down the hierarchy of parent classes, starting from the topmost class
|
||||
$parent = null;
|
||||
$visited = array();
|
||||
foreach ($parentClasses as $className) {
|
||||
if (isset($this->_loadedMetadata[$className])) {
|
||||
$parent = $this->_loadedMetadata[$className];
|
||||
if (isset($this->loadedMetadata[$className])) {
|
||||
$parent = $this->loadedMetadata[$className];
|
||||
if ( ! $parent->isMappedSuperclass) {
|
||||
array_unshift($visited, $className);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$class = $this->_newClassMetadataInstance($className);
|
||||
$class = $this->newClassMetadataInstance($className);
|
||||
|
||||
if ($parent) {
|
||||
$class->setInheritanceType($parent->inheritanceType);
|
||||
$class->setDiscriminatorColumn($parent->discriminatorColumn);
|
||||
$class->setIdGeneratorType($parent->generatorType);
|
||||
$this->_addInheritedFields($class, $parent);
|
||||
$this->_addInheritedRelations($class, $parent);
|
||||
$this->addInheritedFields($class, $parent);
|
||||
$this->addInheritedRelations($class, $parent);
|
||||
$class->setIdentifier($parent->identifier);
|
||||
$class->setVersioned($parent->isVersioned);
|
||||
$class->setVersionField($parent->versionField);
|
||||
@ -254,7 +277,7 @@ class ClassMetadataFactory
|
||||
|
||||
// Invoke driver
|
||||
try {
|
||||
$this->_driver->loadMetadataForClass($className, $class);
|
||||
$this->driver->loadMetadataForClass($className, $class);
|
||||
} catch (ReflectionException $e) {
|
||||
throw MappingException::reflectionFailure($className, $e);
|
||||
}
|
||||
@ -276,7 +299,17 @@ class ClassMetadataFactory
|
||||
$class->setIdGenerator($parent->idGenerator);
|
||||
}
|
||||
} else {
|
||||
$this->_completeIdGeneratorMapping($class);
|
||||
$this->completeIdGeneratorMapping($class);
|
||||
}
|
||||
|
||||
// verify inheritance
|
||||
if (!$parent && !$class->isMappedSuperclass && !$class->isInheritanceTypeNone()) {
|
||||
if (count($class->discriminatorMap) == 0) {
|
||||
throw MappingException::missingDiscriminatorMap($class->name);
|
||||
}
|
||||
if (!$class->discriminatorColumn) {
|
||||
throw MappingException::missingDiscriminatorColumn($class->name);
|
||||
}
|
||||
}
|
||||
|
||||
if ($parent && $parent->isInheritanceTypeSingleTable()) {
|
||||
@ -285,12 +318,12 @@ class ClassMetadataFactory
|
||||
|
||||
$class->setParentClasses($visited);
|
||||
|
||||
if ($this->_evm->hasListeners(Events::loadClassMetadata)) {
|
||||
if ($this->evm->hasListeners(Events::loadClassMetadata)) {
|
||||
$eventArgs = new \Doctrine\ORM\Event\LoadClassMetadataEventArgs($class);
|
||||
$this->_evm->dispatchEvent(Events::loadClassMetadata, $eventArgs);
|
||||
$this->evm->dispatchEvent(Events::loadClassMetadata, $eventArgs);
|
||||
}
|
||||
|
||||
$this->_loadedMetadata[$className] = $class;
|
||||
$this->loadedMetadata[$className] = $class;
|
||||
|
||||
$parent = $class;
|
||||
|
||||
@ -310,7 +343,7 @@ class ClassMetadataFactory
|
||||
* @param string $className
|
||||
* @return Doctrine\ORM\Mapping\ClassMetadata
|
||||
*/
|
||||
protected function _newClassMetadataInstance($className)
|
||||
protected function newClassMetadataInstance($className)
|
||||
{
|
||||
return new ClassMetadata($className);
|
||||
}
|
||||
@ -321,7 +354,7 @@ class ClassMetadataFactory
|
||||
* @param Doctrine\ORM\Mapping\ClassMetadata $subClass
|
||||
* @param Doctrine\ORM\Mapping\ClassMetadata $parentClass
|
||||
*/
|
||||
private function _addInheritedFields(ClassMetadata $subClass, ClassMetadata $parentClass)
|
||||
private function addInheritedFields(ClassMetadata $subClass, ClassMetadata $parentClass)
|
||||
{
|
||||
foreach ($parentClass->fieldMappings as $fieldName => $mapping) {
|
||||
if ( ! isset($mapping['inherited']) && ! $parentClass->isMappedSuperclass) {
|
||||
@ -343,7 +376,7 @@ class ClassMetadataFactory
|
||||
* @param Doctrine\ORM\Mapping\ClassMetadata $subClass
|
||||
* @param Doctrine\ORM\Mapping\ClassMetadata $parentClass
|
||||
*/
|
||||
private function _addInheritedRelations(ClassMetadata $subClass, ClassMetadata $parentClass)
|
||||
private function addInheritedRelations(ClassMetadata $subClass, ClassMetadata $parentClass)
|
||||
{
|
||||
foreach ($parentClass->associationMappings as $field => $mapping) {
|
||||
//$subclassMapping = $mapping;
|
||||
@ -363,13 +396,13 @@ class ClassMetadataFactory
|
||||
*
|
||||
* @param Doctrine\ORM\Mapping\ClassMetadata $class
|
||||
*/
|
||||
private function _completeIdGeneratorMapping(ClassMetadataInfo $class)
|
||||
private function completeIdGeneratorMapping(ClassMetadataInfo $class)
|
||||
{
|
||||
$idGenType = $class->generatorType;
|
||||
if ($idGenType == ClassMetadata::GENERATOR_TYPE_AUTO) {
|
||||
if ($this->_targetPlatform->prefersSequences()) {
|
||||
if ($this->targetPlatform->prefersSequences()) {
|
||||
$class->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_SEQUENCE);
|
||||
} else if ($this->_targetPlatform->prefersIdentityColumns()) {
|
||||
} else if ($this->targetPlatform->prefersIdentityColumns()) {
|
||||
$class->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_IDENTITY);
|
||||
} else {
|
||||
$class->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_TABLE);
|
||||
@ -382,7 +415,7 @@ class ClassMetadataFactory
|
||||
// For PostgreSQL IDENTITY (SERIAL) we need a sequence name. It defaults to
|
||||
// <table>_<column>_seq in PostgreSQL for SERIAL columns.
|
||||
// Not pretty but necessary and the simplest solution that currently works.
|
||||
$seqName = $this->_targetPlatform instanceof Platforms\PostgreSQLPlatform ?
|
||||
$seqName = $this->targetPlatform instanceof Platforms\PostgreSQLPlatform ?
|
||||
$class->table['name'] . '_' . $class->columnNames[$class->identifier[0]] . '_seq' :
|
||||
null;
|
||||
$class->setIdGenerator(new \Doctrine\ORM\Id\IdentityGenerator($seqName));
|
||||
@ -392,7 +425,7 @@ class ClassMetadataFactory
|
||||
$definition = $class->sequenceGeneratorDefinition;
|
||||
if ( ! $definition) {
|
||||
$sequenceName = $class->getTableName() . '_' . $class->getSingleIdentifierColumnName() . '_seq';
|
||||
$definition['sequenceName'] = $this->_targetPlatform->fixSchemaElementName($sequenceName);
|
||||
$definition['sequenceName'] = $this->targetPlatform->fixSchemaElementName($sequenceName);
|
||||
$definition['allocationSize'] = 1;
|
||||
$definition['initialValue'] = 1;
|
||||
$class->setSequenceGeneratorDefinition($definition);
|
||||
|
@ -680,9 +680,11 @@ class ClassMetadataInfo
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates & completes the mapping. Mapping defaults are applied here.
|
||||
* Validates & completes the basic mapping information that is common to all
|
||||
* association mappings (one-to-one, many-ot-one, one-to-many, many-to-many).
|
||||
*
|
||||
* @param array $mapping
|
||||
* @param array $mapping The mapping.
|
||||
* @return array The updated mapping.
|
||||
* @throws MappingException If something is wrong with the mapping.
|
||||
*/
|
||||
protected function _validateAndCompleteAssociationMapping(array $mapping)
|
||||
@ -693,10 +695,13 @@ class ClassMetadataInfo
|
||||
if ( ! isset($mapping['inversedBy'])) {
|
||||
$mapping['inversedBy'] = null;
|
||||
}
|
||||
$mapping['isOwningSide'] = true;
|
||||
$mapping['isOwningSide'] = true; // assume owning side until we hit mappedBy
|
||||
|
||||
// If targetEntity is unqualified, assume it is in the same namespace as
|
||||
// the sourceEntity.
|
||||
$mapping['sourceEntity'] = $this->name;
|
||||
if (isset($mapping['targetEntity']) && strpos($mapping['targetEntity'], '\\') === false && strlen($this->namespace) > 0) {
|
||||
if (isset($mapping['targetEntity']) && strpos($mapping['targetEntity'], '\\') === false
|
||||
&& strlen($this->namespace) > 0) {
|
||||
$mapping['targetEntity'] = $this->namespace . '\\' . $mapping['targetEntity'];
|
||||
}
|
||||
|
||||
@ -712,23 +717,18 @@ class ClassMetadataInfo
|
||||
}
|
||||
|
||||
// Mandatory attributes for both sides
|
||||
// Mandatory: fieldName, targetEntity
|
||||
if ( ! isset($mapping['fieldName'])) {
|
||||
throw MappingException::missingFieldName();
|
||||
}
|
||||
|
||||
if ( ! isset($mapping['sourceEntity'])) {
|
||||
throw MappingException::missingSourceEntity($mapping['fieldName']);
|
||||
}
|
||||
|
||||
if ( ! isset($mapping['targetEntity'])) {
|
||||
throw MappingException::missingTargetEntity($mapping['fieldName']);
|
||||
}
|
||||
|
||||
// Mandatory and optional attributes for either side
|
||||
if ( ! isset($mapping['mappedBy'])) {
|
||||
// Optional
|
||||
if ( ! $mapping['mappedBy']) {
|
||||
if (isset($mapping['joinTable']) && $mapping['joinTable']) {
|
||||
if ($mapping['joinTable']['name'][0] == '`') {
|
||||
if (isset($mapping['joinTable']['name']) && $mapping['joinTable']['name'][0] == '`') {
|
||||
$mapping['joinTable']['name'] = trim($mapping['joinTable']['name'], '`');
|
||||
$mapping['joinTable']['quoted'] = true;
|
||||
}
|
||||
@ -737,12 +737,13 @@ class ClassMetadataInfo
|
||||
$mapping['isOwningSide'] = false;
|
||||
}
|
||||
|
||||
// Optional attributes for both sides
|
||||
// Fetch mode. Default fetch mode to LAZY, if not set.
|
||||
if ( ! isset($mapping['fetch'])) {
|
||||
$mapping['fetch'] = self::FETCH_LAZY;
|
||||
}
|
||||
$cascades = isset($mapping['cascade']) ? $mapping['cascade'] : array();
|
||||
|
||||
// Cascades
|
||||
$cascades = isset($mapping['cascade']) ? $mapping['cascade'] : array();
|
||||
if (in_array('all', $cascades)) {
|
||||
$cascades = array(
|
||||
'remove',
|
||||
@ -763,7 +764,7 @@ class ClassMetadataInfo
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* Validates & completes a one-to-one association mapping.
|
||||
*
|
||||
* @param array $mapping The mapping to validate & complete.
|
||||
* @return array The validated & completed mapping.
|
||||
@ -785,11 +786,16 @@ class ClassMetadataInfo
|
||||
'referencedColumnName' => 'id'
|
||||
));
|
||||
}
|
||||
foreach ($mapping['joinColumns'] AS $key => $joinColumn) {
|
||||
if ($mapping['type'] == self::ONE_TO_ONE) {
|
||||
$mapping['joinColumns'][$key]['unique'] = true;
|
||||
foreach ($mapping['joinColumns'] as $key => &$joinColumn) {
|
||||
if ($mapping['type'] === self::ONE_TO_ONE) {
|
||||
$joinColumn['unique'] = true;
|
||||
}
|
||||
if (empty($joinColumn['name'])) {
|
||||
$joinColumn['name'] = $mapping['fieldName'] . '_id';
|
||||
}
|
||||
if (empty($joinColumn['referencedColumnName'])) {
|
||||
$joinColumn['referencedColumnName'] = 'id';
|
||||
}
|
||||
|
||||
$mapping['sourceToTargetKeyColumns'][$joinColumn['name']] = $joinColumn['referencedColumnName'];
|
||||
$mapping['joinColumnFieldNames'][$joinColumn['name']] = isset($joinColumn['fieldName'])
|
||||
? $joinColumn['fieldName'] : $joinColumn['name'];
|
||||
@ -837,58 +843,49 @@ class ClassMetadataInfo
|
||||
{
|
||||
$mapping = $this->_validateAndCompleteAssociationMapping($mapping);
|
||||
if ($mapping['isOwningSide']) {
|
||||
$sourceShortName = strtolower(substr($mapping['sourceEntity'], strrpos($mapping['sourceEntity'], '\\') + 1));
|
||||
$targetShortName = strtolower(substr($mapping['targetEntity'], strrpos($mapping['targetEntity'], '\\') + 1));
|
||||
// owning side MUST have a join table
|
||||
if ( ! isset($mapping['joinTable']) || ! $mapping['joinTable']) {
|
||||
// Apply default join table
|
||||
$sourceShortName = substr($mapping['sourceEntity'], strrpos($mapping['sourceEntity'], '\\') + 1);
|
||||
$targetShortName = substr($mapping['targetEntity'], strrpos($mapping['targetEntity'], '\\') + 1);
|
||||
$mapping['joinTable'] = array(
|
||||
'name' => $sourceShortName .'_' . $targetShortName,
|
||||
'joinColumns' => array(
|
||||
array(
|
||||
if ( ! isset($mapping['joinTable']['name'])) {
|
||||
$mapping['joinTable']['name'] = $sourceShortName .'_' . $targetShortName;
|
||||
}
|
||||
if ( ! isset($mapping['joinTable']['joinColumns'])) {
|
||||
$mapping['joinTable']['joinColumns'] = array(array(
|
||||
'name' => $sourceShortName . '_id',
|
||||
'referencedColumnName' => 'id',
|
||||
'onDelete' => 'CASCADE'
|
||||
)
|
||||
),
|
||||
'inverseJoinColumns' => array(
|
||||
array(
|
||||
'onDelete' => 'CASCADE'));
|
||||
}
|
||||
if ( ! isset($mapping['joinTable']['inverseJoinColumns'])) {
|
||||
$mapping['joinTable']['inverseJoinColumns'] = array(array(
|
||||
'name' => $targetShortName . '_id',
|
||||
'referencedColumnName' => 'id',
|
||||
'onDelete' => 'CASCADE'
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
// owning side MUST specify joinColumns
|
||||
else if ( ! isset($mapping['joinTable']['joinColumns'])) {
|
||||
throw MappingException::missingRequiredOption(
|
||||
$mapping['fieldName'], 'joinColumns',
|
||||
'Did you think of case sensitivity / plural s?'
|
||||
);
|
||||
}
|
||||
// owning side MUST specify inverseJoinColumns
|
||||
else if ( ! isset($mapping['joinTable']['inverseJoinColumns'])) {
|
||||
throw MappingException::missingRequiredOption(
|
||||
$mapping['fieldName'], 'inverseJoinColumns',
|
||||
'Did you think of case sensitivity / plural s?'
|
||||
);
|
||||
'onDelete' => 'CASCADE'));
|
||||
}
|
||||
|
||||
foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) {
|
||||
foreach ($mapping['joinTable']['joinColumns'] as &$joinColumn) {
|
||||
if (empty($joinColumn['name'])) {
|
||||
$joinColumn['name'] = $sourceShortName . '_id';
|
||||
}
|
||||
if (empty($joinColumn['referencedColumnName'])) {
|
||||
$joinColumn['referencedColumnName'] = 'id';
|
||||
}
|
||||
if (isset($joinColumn['onDelete']) && strtolower($joinColumn['onDelete']) == 'cascade') {
|
||||
$mapping['isOnDeleteCascade'] = true;
|
||||
}
|
||||
|
||||
$mapping['relationToSourceKeyColumns'][$joinColumn['name']] = $joinColumn['referencedColumnName'];
|
||||
$mapping['joinTableColumns'][] = $joinColumn['name'];
|
||||
}
|
||||
|
||||
foreach ($mapping['joinTable']['inverseJoinColumns'] as $inverseJoinColumn) {
|
||||
foreach ($mapping['joinTable']['inverseJoinColumns'] as &$inverseJoinColumn) {
|
||||
if (empty($inverseJoinColumn['name'])) {
|
||||
$inverseJoinColumn['name'] = $targetShortName . '_id';
|
||||
}
|
||||
if (empty($inverseJoinColumn['referencedColumnName'])) {
|
||||
$inverseJoinColumn['referencedColumnName'] = 'id';
|
||||
}
|
||||
if (isset($inverseJoinColumn['onDelete']) && strtolower($inverseJoinColumn['onDelete']) == 'cascade') {
|
||||
$mapping['isOnDeleteCascade'] = true;
|
||||
}
|
||||
|
||||
$mapping['relationToTargetKeyColumns'][$inverseJoinColumn['name']] = $inverseJoinColumn['referencedColumnName'];
|
||||
$mapping['joinTableColumns'][] = $inverseJoinColumn['name'];
|
||||
}
|
||||
@ -1226,22 +1223,33 @@ class ClassMetadataInfo
|
||||
* indexes => array of indexes (optional)
|
||||
* uniqueConstraints => array of constraints (optional)
|
||||
*
|
||||
* @param array $table
|
||||
* If a key is omitted, the current value is kept.
|
||||
*
|
||||
* @param array $table The table description.
|
||||
*/
|
||||
public function setPrimaryTable(array $table)
|
||||
{
|
||||
if (isset($table['name']) && $table['name'][0] == '`') {
|
||||
$table['name'] = trim($table['name'], '`');
|
||||
$table['quoted'] = true;
|
||||
if (isset($table['name'])) {
|
||||
if ($table['name'][0] == '`') {
|
||||
$this->table['name'] = trim($table['name'], '`');
|
||||
$this->table['quoted'] = true;
|
||||
} else {
|
||||
$this->table['name'] = $table['name'];
|
||||
}
|
||||
}
|
||||
if (isset($table['indexes'])) {
|
||||
$this->table['indexes'] = $table['indexes'];
|
||||
}
|
||||
if (isset($table['uniqueConstraints'])) {
|
||||
$this->table['uniqueConstraints'] = $table['uniqueConstraints'];
|
||||
}
|
||||
$this->table = $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given type identifies an inheritance type.
|
||||
*
|
||||
* @param string $type
|
||||
* @return boolean
|
||||
* @param integer $type
|
||||
* @return boolean TRUE if the given type identifies an inheritance type, FALSe otherwise.
|
||||
*/
|
||||
private function _isInheritanceType($type)
|
||||
{
|
||||
|
@ -179,16 +179,12 @@ class AnnotationDriver implements Driver
|
||||
'type' => $discrColumnAnnot->type,
|
||||
'length' => $discrColumnAnnot->length
|
||||
));
|
||||
} else {
|
||||
throw MappingException::missingDiscriminatorColumn($className);
|
||||
}
|
||||
|
||||
// Evaluate DiscriminatorMap annotation
|
||||
if (isset($classAnnotations['Doctrine\ORM\Mapping\DiscriminatorMap'])) {
|
||||
$discrMapAnnot = $classAnnotations['Doctrine\ORM\Mapping\DiscriminatorMap'];
|
||||
$metadata->setDiscriminatorMap($discrMapAnnot->value);
|
||||
} else {
|
||||
throw MappingException::missingDiscriminatorMap($className);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -87,8 +87,6 @@ class XmlDriver extends AbstractFileDriver
|
||||
'type' => (string)$discrColumn['type'],
|
||||
'length' => (string)$discrColumn['length']
|
||||
));
|
||||
} else {
|
||||
throw MappingException::missingDiscriminatorColumn($className);
|
||||
}
|
||||
|
||||
// Evaluate <discriminator-map...>
|
||||
@ -98,8 +96,6 @@ class XmlDriver extends AbstractFileDriver
|
||||
$map[(string)$discrMapElement['value']] = (string)$discrMapElement['class'];
|
||||
}
|
||||
$metadata->setDiscriminatorMap($map);
|
||||
} else {
|
||||
throw MappingException::missingDiscriminatorMap($className);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -79,15 +79,11 @@ class YamlDriver extends AbstractFileDriver
|
||||
'type' => $discrColumn['type'],
|
||||
'length' => $discrColumn['length']
|
||||
));
|
||||
} else {
|
||||
throw MappingException::missingDiscriminatorColumn($className);
|
||||
}
|
||||
|
||||
// Evaluate discriminatorMap
|
||||
if (isset($element['discriminatorMap'])) {
|
||||
$metadata->setDiscriminatorMap($element['discriminatorMap']);
|
||||
} else {
|
||||
throw MappingException::missingDiscriminatorMap($className);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -452,6 +448,6 @@ class YamlDriver extends AbstractFileDriver
|
||||
*/
|
||||
protected function _loadMappingFile($file)
|
||||
{
|
||||
return \Symfony\Components\Yaml\Yaml::load($file);
|
||||
return \Symfony\Component\Yaml\Yaml::load($file);
|
||||
}
|
||||
}
|
||||
|
@ -661,4 +661,21 @@ final class PersistentCollection implements Collection
|
||||
{
|
||||
return $this->coll;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract a slice of $length elements starting at position $offset from the Collection.
|
||||
*
|
||||
* If $length is null it returns all elements from $offset to the end of the Collection.
|
||||
* Keys have to be preserved by this method. Calling this method will only return the
|
||||
* selected slice and NOT change the elements contained in the collection slice is called on.
|
||||
*
|
||||
* @param int $offset
|
||||
* @param int $length
|
||||
* @return array
|
||||
*/
|
||||
public function slice($offset, $length = null)
|
||||
{
|
||||
$this->initialize();
|
||||
return $this->coll->slice($offset, $length);
|
||||
}
|
||||
}
|
||||
|
@ -425,15 +425,11 @@ class Parser
|
||||
/**
|
||||
* Checks if the given token indicates a mathematical operator.
|
||||
*
|
||||
* @return boolean TRUE is the token is a mathematical operator, FALSE otherwise.
|
||||
* @return boolean TRUE if the token is a mathematical operator, FALSE otherwise.
|
||||
*/
|
||||
private function _isMathOperator($token)
|
||||
{
|
||||
if (in_array($token['value'], array("+", "-", "/", "*"))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return in_array($token['value'], array("+", "-", "/", "*"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,9 +21,9 @@
|
||||
|
||||
namespace Doctrine\ORM\Tools\Console\Command\ClearCache;
|
||||
|
||||
use Symfony\Components\Console\Input\InputArgument,
|
||||
Symfony\Components\Console\Input\InputOption,
|
||||
Symfony\Components\Console;
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console;
|
||||
|
||||
/**
|
||||
* Command to clear the metadata cache of the various cache drivers.
|
||||
|
@ -21,9 +21,9 @@
|
||||
|
||||
namespace Doctrine\ORM\Tools\Console\Command\ClearCache;
|
||||
|
||||
use Symfony\Components\Console\Input\InputArgument,
|
||||
Symfony\Components\Console\Input\InputOption,
|
||||
Symfony\Components\Console;
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console;
|
||||
|
||||
/**
|
||||
* Command to clear the query cache of the various cache drivers.
|
||||
|
@ -21,9 +21,9 @@
|
||||
|
||||
namespace Doctrine\ORM\Tools\Console\Command\ClearCache;
|
||||
|
||||
use Symfony\Components\Console\Input\InputArgument,
|
||||
Symfony\Components\Console\Input\InputOption,
|
||||
Symfony\Components\Console;
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console;
|
||||
|
||||
/**
|
||||
* Command to clear the result cache of the various cache drivers.
|
||||
|
@ -21,9 +21,9 @@
|
||||
|
||||
namespace Doctrine\ORM\Tools\Console\Command;
|
||||
|
||||
use Symfony\Components\Console\Input\InputArgument,
|
||||
Symfony\Components\Console\Input\InputOption,
|
||||
Symfony\Components\Console,
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console,
|
||||
Doctrine\ORM\Tools\Export\ClassMetadataExporter,
|
||||
Doctrine\ORM\Tools\ConvertDoctrine1Schema,
|
||||
Doctrine\ORM\Tools\EntityGenerator;
|
||||
|
@ -21,9 +21,9 @@
|
||||
|
||||
namespace Doctrine\ORM\Tools\Console\Command;
|
||||
|
||||
use Symfony\Components\Console\Input\InputArgument,
|
||||
Symfony\Components\Console\Input\InputOption,
|
||||
Symfony\Components\Console,
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console,
|
||||
Doctrine\ORM\Tools\Console\MetadataFilter,
|
||||
Doctrine\ORM\Tools\Export\ClassMetadataExporter,
|
||||
Doctrine\ORM\Tools\EntityGenerator,
|
||||
|
@ -21,9 +21,9 @@
|
||||
|
||||
namespace Doctrine\ORM\Tools\Console\Command;
|
||||
|
||||
use Symfony\Components\Console\Input\InputArgument,
|
||||
Symfony\Components\Console\Input\InputOption,
|
||||
Symfony\Components\Console;
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console;
|
||||
|
||||
/**
|
||||
* Command to ensure that Doctrine is properly configured for a production environment.
|
||||
|
@ -21,9 +21,9 @@
|
||||
|
||||
namespace Doctrine\ORM\Tools\Console\Command;
|
||||
|
||||
use Symfony\Components\Console\Input\InputArgument,
|
||||
Symfony\Components\Console\Input\InputOption,
|
||||
Symfony\Components\Console,
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console,
|
||||
Doctrine\ORM\Tools\Console\MetadataFilter,
|
||||
Doctrine\ORM\Tools\EntityGenerator,
|
||||
Doctrine\ORM\Tools\DisconnectedClassMetadataFactory;
|
||||
|
@ -21,9 +21,9 @@
|
||||
|
||||
namespace Doctrine\ORM\Tools\Console\Command;
|
||||
|
||||
use Symfony\Components\Console\Input\InputArgument,
|
||||
Symfony\Components\Console\Input\InputOption,
|
||||
Symfony\Components\Console,
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console,
|
||||
Doctrine\ORM\Tools\Console\MetadataFilter;
|
||||
|
||||
/**
|
||||
|
@ -21,9 +21,9 @@
|
||||
|
||||
namespace Doctrine\ORM\Tools\Console\Command;
|
||||
|
||||
use Symfony\Components\Console\Input\InputArgument,
|
||||
Symfony\Components\Console\Input\InputOption,
|
||||
Symfony\Components\Console,
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console,
|
||||
Doctrine\ORM\Tools\Console\MetadataFilter,
|
||||
Doctrine\ORM\Tools\EntityRepositoryGenerator;
|
||||
|
||||
|
@ -21,9 +21,9 @@
|
||||
|
||||
namespace Doctrine\ORM\Tools\Console\Command;
|
||||
|
||||
use Symfony\Components\Console\Input\InputArgument,
|
||||
Symfony\Components\Console\Input\InputOption,
|
||||
Symfony\Components\Console;
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console;
|
||||
|
||||
/**
|
||||
* Command to execute DQL queries in a given EntityManager.
|
||||
|
@ -21,11 +21,11 @@
|
||||
|
||||
namespace Doctrine\ORM\Tools\Console\Command\SchemaTool;
|
||||
|
||||
use Symfony\Components\Console\Input\InputArgument,
|
||||
Symfony\Components\Console\Input\InputOption,
|
||||
Symfony\Components\Console\Input\InputInterface,
|
||||
Symfony\Components\Console\Output\OutputInterface,
|
||||
Symfony\Components\Console\Command\Command,
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console\Input\InputInterface,
|
||||
Symfony\Component\Console\Output\OutputInterface,
|
||||
Symfony\Component\Console\Command\Command,
|
||||
Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper,
|
||||
Doctrine\ORM\Tools\SchemaTool,
|
||||
Doctrine\ORM\Mapping\Driver\AbstractFileDriver;
|
||||
|
@ -21,10 +21,10 @@
|
||||
|
||||
namespace Doctrine\ORM\Tools\Console\Command\SchemaTool;
|
||||
|
||||
use Symfony\Components\Console\Input\InputArgument,
|
||||
Symfony\Components\Console\Input\InputOption,
|
||||
Symfony\Components\Console\Input\InputInterface,
|
||||
Symfony\Components\Console\Output\OutputInterface,
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console\Input\InputInterface,
|
||||
Symfony\Component\Console\Output\OutputInterface,
|
||||
Doctrine\ORM\Tools\SchemaTool;
|
||||
|
||||
/**
|
||||
|
@ -21,10 +21,10 @@
|
||||
|
||||
namespace Doctrine\ORM\Tools\Console\Command\SchemaTool;
|
||||
|
||||
use Symfony\Components\Console\Input\InputArgument,
|
||||
Symfony\Components\Console\Input\InputOption,
|
||||
Symfony\Components\Console\Input\InputInterface,
|
||||
Symfony\Components\Console\Output\OutputInterface,
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console\Input\InputInterface,
|
||||
Symfony\Component\Console\Output\OutputInterface,
|
||||
Doctrine\ORM\Tools\SchemaTool;
|
||||
|
||||
/**
|
||||
|
@ -21,10 +21,10 @@
|
||||
|
||||
namespace Doctrine\ORM\Tools\Console\Command\SchemaTool;
|
||||
|
||||
use Symfony\Components\Console\Input\InputArgument,
|
||||
Symfony\Components\Console\Input\InputOption,
|
||||
Symfony\Components\Console\Input\InputInterface,
|
||||
Symfony\Components\Console\Output\OutputInterface,
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console\Input\InputInterface,
|
||||
Symfony\Component\Console\Output\OutputInterface,
|
||||
Doctrine\ORM\Tools\SchemaTool;
|
||||
|
||||
/**
|
||||
|
@ -21,9 +21,9 @@
|
||||
|
||||
namespace Doctrine\ORM\Tools\Console\Command;
|
||||
|
||||
use Symfony\Components\Console\Input\InputArgument,
|
||||
Symfony\Components\Console\Input\InputOption,
|
||||
Symfony\Components\Console;
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console;
|
||||
|
||||
/**
|
||||
* Validate that the current mapping is valid
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
namespace Doctrine\ORM\Tools\Console\Helper;
|
||||
|
||||
use Symfony\Components\Console\Helper\Helper,
|
||||
use Symfony\Component\Console\Helper\Helper,
|
||||
Doctrine\ORM\EntityManager;
|
||||
|
||||
/**
|
||||
|
@ -70,10 +70,10 @@ class ConvertDoctrine1Schema
|
||||
if (is_dir($path)) {
|
||||
$files = glob($path . '/*.yml');
|
||||
foreach ($files as $file) {
|
||||
$schema = array_merge($schema, (array) \Symfony\Components\Yaml\Yaml::load($file));
|
||||
$schema = array_merge($schema, (array) \Symfony\Component\Yaml\Yaml::load($file));
|
||||
}
|
||||
} else {
|
||||
$schema = array_merge($schema, (array) \Symfony\Components\Yaml\Yaml::load($path));
|
||||
$schema = array_merge($schema, (array) \Symfony\Component\Yaml\Yaml::load($path));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ class DisconnectedClassMetadataFactory extends ClassMetadataFactory
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
protected function _newClassMetadataInstance($className)
|
||||
protected function newClassMetadataInstance($className)
|
||||
{
|
||||
return new ClassMetadataInfo($className);
|
||||
}
|
||||
@ -52,7 +52,7 @@ class DisconnectedClassMetadataFactory extends ClassMetadataFactory
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
protected function _getParentClasses($name)
|
||||
protected function getParentClasses($name)
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
@ -198,6 +198,6 @@ class YamlExporter extends AbstractExporter
|
||||
$array['lifecycleCallbacks'] = $metadata->lifecycleCallbacks;
|
||||
}
|
||||
|
||||
return \Symfony\Components\Yaml\Yaml::dump(array($metadata->name => $array), 10);
|
||||
return \Symfony\Component\Yaml\Yaml::dump(array($metadata->name => $array), 10);
|
||||
}
|
||||
}
|
@ -1,22 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Console;
|
||||
namespace Symfony\Component\Console;
|
||||
|
||||
use Symfony\Components\Console\Input\InputInterface;
|
||||
use Symfony\Components\Console\Input\ArgvInput;
|
||||
use Symfony\Components\Console\Input\ArrayInput;
|
||||
use Symfony\Components\Console\Input\InputDefinition;
|
||||
use Symfony\Components\Console\Input\InputOption;
|
||||
use Symfony\Components\Console\Input\InputArgument;
|
||||
use Symfony\Components\Console\Output\OutputInterface;
|
||||
use Symfony\Components\Console\Output\Output;
|
||||
use Symfony\Components\Console\Output\ConsoleOutput;
|
||||
use Symfony\Components\Console\Command\Command;
|
||||
use Symfony\Components\Console\Command\HelpCommand;
|
||||
use Symfony\Components\Console\Command\ListCommand;
|
||||
use Symfony\Components\Console\Helper\HelperSet;
|
||||
use Symfony\Components\Console\Helper\FormatterHelper;
|
||||
use Symfony\Components\Console\Helper\DialogHelper;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Input\InputDefinition;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Output\Output;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Command\HelpCommand;
|
||||
use Symfony\Component\Console\Command\ListCommand;
|
||||
use Symfony\Component\Console\Helper\HelperSet;
|
||||
use Symfony\Component\Console\Helper\FormatterHelper;
|
||||
use Symfony\Component\Console\Helper\DialogHelper;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony framework.
|
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Console\Command;
|
||||
namespace Symfony\Component\Console\Command;
|
||||
|
||||
use Symfony\Components\Console\Input\InputDefinition;
|
||||
use Symfony\Components\Console\Input\InputOption;
|
||||
use Symfony\Components\Console\Input\InputArgument;
|
||||
use Symfony\Components\Console\Input\InputInterface;
|
||||
use Symfony\Components\Console\Output\OutputInterface;
|
||||
use Symfony\Components\Console\Application;
|
||||
use Symfony\Component\Console\Input\InputDefinition;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Application;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony framework.
|
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Console\Command;
|
||||
namespace Symfony\Component\Console\Command;
|
||||
|
||||
use Symfony\Components\Console\Input\InputArgument;
|
||||
use Symfony\Components\Console\Input\InputOption;
|
||||
use Symfony\Components\Console\Input\InputInterface;
|
||||
use Symfony\Components\Console\Output\OutputInterface;
|
||||
use Symfony\Components\Console\Output\Output;
|
||||
use Symfony\Components\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Output\Output;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony framework.
|
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Console\Command;
|
||||
namespace Symfony\Component\Console\Command;
|
||||
|
||||
use Symfony\Components\Console\Input\InputArgument;
|
||||
use Symfony\Components\Console\Input\InputOption;
|
||||
use Symfony\Components\Console\Input\InputInterface;
|
||||
use Symfony\Components\Console\Output\OutputInterface;
|
||||
use Symfony\Components\Console\Output\Output;
|
||||
use Symfony\Components\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Output\Output;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony framework.
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Console\Helper;
|
||||
namespace Symfony\Component\Console\Helper;
|
||||
|
||||
use Symfony\Components\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony framework.
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Console\Helper;
|
||||
namespace Symfony\Component\Console\Helper;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony framework.
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Console\Helper;
|
||||
namespace Symfony\Component\Console\Helper;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony framework.
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Console\Helper;
|
||||
namespace Symfony\Component\Console\Helper;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony framework.
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Console\Helper;
|
||||
namespace Symfony\Component\Console\Helper;
|
||||
|
||||
use Symfony\Components\Console\Command\Command;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony framework.
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Console\Input;
|
||||
namespace Symfony\Component\Console\Input;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony framework.
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Console\Input;
|
||||
namespace Symfony\Component\Console\Input;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony framework.
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Console\Input;
|
||||
namespace Symfony\Component\Console\Input;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony framework.
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Console\Input;
|
||||
namespace Symfony\Component\Console\Input;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony framework.
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Console\Input;
|
||||
namespace Symfony\Component\Console\Input;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony framework.
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Console\Input;
|
||||
namespace Symfony\Component\Console\Input;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony framework.
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Console\Input;
|
||||
namespace Symfony\Component\Console\Input;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony framework.
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Console\Input;
|
||||
namespace Symfony\Component\Console\Input;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony framework.
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Console\Output;
|
||||
namespace Symfony\Component\Console\Output;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony framework.
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Console\Output;
|
||||
namespace Symfony\Component\Console\Output;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony framework.
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Console\Output;
|
||||
namespace Symfony\Component\Console\Output;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony framework.
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Console\Output;
|
||||
namespace Symfony\Component\Console\Output;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony framework.
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Console\Output;
|
||||
namespace Symfony\Component\Console\Output;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony framework.
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Console;
|
||||
namespace Symfony\Component\Console;
|
||||
|
||||
use Symfony\Components\Console\Application;
|
||||
use Symfony\Components\Console\Input\StringInput;
|
||||
use Symfony\Components\Console\Output\ConsoleOutput;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Input\StringInput;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony framework.
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Console\Tester;
|
||||
namespace Symfony\Component\Console\Tester;
|
||||
|
||||
use Symfony\Components\Console\Application;
|
||||
use Symfony\Components\Console\Input\ArrayInput;
|
||||
use Symfony\Components\Console\Output\StreamOutput;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Output\StreamOutput;
|
||||
|
||||
class ApplicationTester
|
||||
{
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Console\Tester;
|
||||
namespace Symfony\Component\Console\Tester;
|
||||
|
||||
use Symfony\Components\Console\Command\Command;
|
||||
use Symfony\Components\Console\Input\ArrayInput;
|
||||
use Symfony\Components\Console\Output\StreamOutput;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Output\StreamOutput;
|
||||
|
||||
class CommandTester
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Yaml;
|
||||
namespace Symfony\Component\Yaml;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony package.
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Yaml;
|
||||
namespace Symfony\Component\Yaml;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony package.
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Yaml;
|
||||
namespace Symfony\Component\Yaml;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony package.
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Yaml;
|
||||
namespace Symfony\Component\Yaml;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony package.
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Yaml;
|
||||
namespace Symfony\Component\Yaml;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony package.
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Components\Yaml;
|
||||
namespace Symfony\Component\Yaml;
|
||||
|
||||
/*
|
||||
* This file is part of the symfony package.
|
@ -39,6 +39,7 @@ class CmsAddress
|
||||
|
||||
/**
|
||||
* @OneToOne(targetEntity="CmsUser", inversedBy="address")
|
||||
* @JoinColumn(referencedColumnName="id")
|
||||
*/
|
||||
public $user;
|
||||
|
||||
|
@ -20,28 +20,6 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Doctrine\ORM\Query\QueryException
|
||||
*/
|
||||
public function testParameterIndexZeroThrowsException()
|
||||
{
|
||||
$query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1");
|
||||
$query->execute(array(42)); // same as array(0 => 42), 0 is invalid parameter position
|
||||
}
|
||||
|
||||
public function testGetParameters()
|
||||
{
|
||||
$query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1");
|
||||
$this->assertEquals(array(), $query->getParameters());
|
||||
}
|
||||
|
||||
public function testGetParameters_HasSomeAlready()
|
||||
{
|
||||
$query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1");
|
||||
$query->setParameter(2, 84);
|
||||
$this->assertEquals(array(2 => 84), $query->getParameters());
|
||||
}
|
||||
|
||||
public function testSimpleQueries()
|
||||
{
|
||||
$user = new CmsUser;
|
||||
|
@ -19,7 +19,7 @@ class PostgreSqlSchemaToolTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
public function testPostgresMetadataSequenceIncrementedBy10()
|
||||
{
|
||||
$address = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress');
|
||||
$this->assertEquals(10, $address->sequenceGeneratorDefinition['allocationSize']);
|
||||
$this->assertEquals(1, $address->sequenceGeneratorDefinition['allocationSize']);
|
||||
}
|
||||
|
||||
public function testGetCreateSchemaSql()
|
||||
@ -39,8 +39,8 @@ class PostgreSqlSchemaToolTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->assertEquals("CREATE UNIQUE INDEX cms_users_username_uniq ON cms_users (username)", $sql[3]);
|
||||
$this->assertEquals("CREATE TABLE cms_users_groups (user_id INT NOT NULL, group_id INT NOT NULL, PRIMARY KEY(user_id, group_id))", $sql[4]);
|
||||
$this->assertEquals("CREATE TABLE cms_phonenumbers (phonenumber VARCHAR(50) NOT NULL, user_id INT DEFAULT NULL, PRIMARY KEY(phonenumber))", $sql[5]);
|
||||
$this->assertEquals("CREATE SEQUENCE cms_addresses_id_seq INCREMENT BY 10 MINVALUE 1 START 1", $sql[6]);
|
||||
$this->assertEquals("CREATE SEQUENCE cms_users_id_seq INCREMENT BY 10 MINVALUE 1 START 1", $sql[7]);
|
||||
$this->assertEquals("CREATE SEQUENCE cms_addresses_id_seq INCREMENT BY 1 MINVALUE 1 START 1", $sql[6]);
|
||||
$this->assertEquals("CREATE SEQUENCE cms_users_id_seq INCREMENT BY 1 MINVALUE 1 START 1", $sql[7]);
|
||||
$this->assertEquals("ALTER TABLE cms_addresses ADD FOREIGN KEY (user_id) REFERENCES cms_users(id) NOT DEFERRABLE INITIALLY IMMEDIATE", $sql[8]);
|
||||
$this->assertEquals("ALTER TABLE cms_users_groups ADD FOREIGN KEY (user_id) REFERENCES cms_users(id) NOT DEFERRABLE INITIALLY IMMEDIATE", $sql[9]);
|
||||
$this->assertEquals("ALTER TABLE cms_users_groups ADD FOREIGN KEY (group_id) REFERENCES cms_groups(id) NOT DEFERRABLE INITIALLY IMMEDIATE", $sql[10]);
|
||||
@ -61,7 +61,7 @@ class PostgreSqlSchemaToolTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->assertEquals(2, count($sql));
|
||||
|
||||
$this->assertEquals('CREATE TABLE decimal_model (id INT NOT NULL, "decimal" NUMERIC(5, 2) NOT NULL, "high_scale" NUMERIC(14, 4) NOT NULL, PRIMARY KEY(id))', $sql[0]);
|
||||
$this->assertEquals("CREATE SEQUENCE decimal_model_id_seq INCREMENT BY 10 MINVALUE 1 START 1", $sql[1]);
|
||||
$this->assertEquals("CREATE SEQUENCE decimal_model_id_seq INCREMENT BY 1 MINVALUE 1 START 1", $sql[1]);
|
||||
}
|
||||
|
||||
public function testGetCreateSchemaSql3()
|
||||
@ -75,6 +75,6 @@ class PostgreSqlSchemaToolTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
|
||||
$this->assertEquals(2, count($sql));
|
||||
$this->assertEquals("CREATE TABLE boolean_model (id INT NOT NULL, booleanField BOOLEAN NOT NULL, PRIMARY KEY(id))", $sql[0]);
|
||||
$this->assertEquals("CREATE SEQUENCE boolean_model_id_seq INCREMENT BY 10 MINVALUE 1 START 1", $sql[1]);
|
||||
$this->assertEquals("CREATE SEQUENCE boolean_model_id_seq INCREMENT BY 1 MINVALUE 1 START 1", $sql[1]);
|
||||
}
|
||||
}
|
||||
|
@ -90,24 +90,6 @@ class AnnotationDriverTest extends AbstractMappingDriverTest
|
||||
$this->assertNotContains($extraneousClassName, $classes);
|
||||
}
|
||||
|
||||
public function testInheritenceWithoutDiscriminatorMap()
|
||||
{
|
||||
$cm = new ClassMetadata('Doctrine\Tests\ORM\Mapping\ClassWithoutDiscriminatorMap');
|
||||
$annotationDriver = $this->_loadDriver();
|
||||
|
||||
$this->setExpectedException("Doctrine\ORM\Mapping\MappingException");
|
||||
$annotationDriver->loadMetadataForClass($cm->name, $cm);
|
||||
}
|
||||
|
||||
public function testInheritenceWithoutDiscriminatorColumn()
|
||||
{
|
||||
$cm = new ClassMetadata('Doctrine\Tests\ORM\Mapping\ClassWithoutDiscriminatorColumn');
|
||||
$annotationDriver = $this->_loadDriver();
|
||||
|
||||
$this->setExpectedException("Doctrine\ORM\Mapping\MappingException");
|
||||
$annotationDriver->loadMetadataForClass($cm->name, $cm);
|
||||
}
|
||||
|
||||
protected function _loadDriverForCMSModels()
|
||||
{
|
||||
$annotationDriver = $this->_loadDriver();
|
||||
@ -137,25 +119,3 @@ class ColumnWithoutType
|
||||
/** @Id @Column */
|
||||
public $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @InheritanceType("SINGLE_TABLE")
|
||||
* @DiscriminatorMap({"a" = "ClassWithoutDiscriminatorColumn"})
|
||||
*/
|
||||
class ClassWithoutDiscriminatorColumn
|
||||
{
|
||||
/** @Id @Column */
|
||||
public $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @InheritanceType("SINGLE_TABLE")
|
||||
* @DiscriminatorColumn(name="discr", type="string")
|
||||
*/
|
||||
class ClassWithoutDiscriminatorMap
|
||||
{
|
||||
/** @Id @Column */
|
||||
public $id;
|
||||
}
|
@ -102,27 +102,27 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase
|
||||
/* Test subject class with overriden factory method for mocking purposes */
|
||||
class ClassMetadataFactoryTestSubject extends \Doctrine\ORM\Mapping\ClassMetadataFactory
|
||||
{
|
||||
private $_mockMetadata = array();
|
||||
private $_requestedClasses = array();
|
||||
private $mockMetadata = array();
|
||||
private $requestedClasses = array();
|
||||
|
||||
/** @override */
|
||||
protected function _newClassMetadataInstance($className)
|
||||
protected function newClassMetadataInstance($className)
|
||||
{
|
||||
$this->_requestedClasses[] = $className;
|
||||
if ( ! isset($this->_mockMetadata[$className])) {
|
||||
$this->requestedClasses[] = $className;
|
||||
if ( ! isset($this->mockMetadata[$className])) {
|
||||
throw new InvalidArgumentException("No mock metadata found for class $className.");
|
||||
}
|
||||
return $this->_mockMetadata[$className];
|
||||
return $this->mockMetadata[$className];
|
||||
}
|
||||
|
||||
public function setMetadataForClass($className, $metadata)
|
||||
{
|
||||
$this->_mockMetadata[$className] = $metadata;
|
||||
$this->mockMetadata[$className] = $metadata;
|
||||
}
|
||||
|
||||
public function getRequestedClasses()
|
||||
{
|
||||
return $this->_requestedClasses;
|
||||
return $this->requestedClasses;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,9 +102,9 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
||||
$assoc = $cm->associationMappings['groups'];
|
||||
//$this->assertTrue($assoc instanceof \Doctrine\ORM\Mapping\ManyToManyMapping);
|
||||
$this->assertEquals(array(
|
||||
'name' => 'CmsUser_CmsGroup',
|
||||
'joinColumns' => array(array('name' => 'CmsUser_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE')),
|
||||
'inverseJoinColumns' => array(array('name' => 'CmsGroup_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE'))
|
||||
'name' => 'cmsuser_cmsgroup',
|
||||
'joinColumns' => array(array('name' => 'cmsuser_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE')),
|
||||
'inverseJoinColumns' => array(array('name' => 'cmsgroup_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE'))
|
||||
), $assoc['joinTable']);
|
||||
$this->assertTrue($assoc['isOnDeleteCascade']);
|
||||
}
|
||||
@ -231,4 +231,49 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
||||
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException');
|
||||
$cm->mapField(array('fieldName' => 'name', 'columnName' => 'name'));
|
||||
}
|
||||
|
||||
public function testDefaultTableName()
|
||||
{
|
||||
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
||||
|
||||
// When table's name is not given
|
||||
$primaryTable = array();
|
||||
$cm->setPrimaryTable($primaryTable);
|
||||
|
||||
$this->assertEquals('CmsUser', $cm->getTableName());
|
||||
$this->assertEquals('CmsUser', $cm->table['name']);
|
||||
|
||||
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress');
|
||||
// When joinTable's name is not given
|
||||
$cm->mapManyToMany(array(
|
||||
'fieldName' => 'user',
|
||||
'targetEntity' => 'CmsUser',
|
||||
'inversedBy' => 'users',
|
||||
'joinTable' => array('joinColumns' => array(array('referencedColumnName' => 'id')),
|
||||
'inverseJoinColumns' => array(array('referencedColumnName' => 'id')))));
|
||||
$this->assertEquals('cmsaddress_cmsuser', $cm->associationMappings['user']['joinTable']['name']);
|
||||
}
|
||||
|
||||
public function testDefaultJoinColumnName()
|
||||
{
|
||||
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress');
|
||||
// this is really dirty, but it's the simpliest way to test whether
|
||||
// joinColumn's name will be automatically set to user_id
|
||||
$cm->mapOneToOne(array(
|
||||
'fieldName' => 'user',
|
||||
'targetEntity' => 'CmsUser',
|
||||
'joinColumns' => array(array('referencedColumnName' => 'id'))));
|
||||
$this->assertEquals('user_id', $cm->associationMappings['user']['joinColumns'][0]['name']);
|
||||
|
||||
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress');
|
||||
$cm->mapManyToMany(array(
|
||||
'fieldName' => 'user',
|
||||
'targetEntity' => 'CmsUser',
|
||||
'inversedBy' => 'users',
|
||||
'joinTable' => array('name' => 'user_CmsUser',
|
||||
'joinColumns' => array(array('referencedColumnName' => 'id')),
|
||||
'inverseJoinColumns' => array(array('referencedColumnName' => 'id')))));
|
||||
$this->assertEquals('cmsaddress_id', $cm->associationMappings['user']['joinTable']['joinColumns'][0]['name']);
|
||||
$this->assertEquals('cmsuser_id', $cm->associationMappings['user']['joinTable']['inverseJoinColumns'][0]['name']);
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ class YamlMappingDriverTest extends AbstractMappingDriverTest
|
||||
{
|
||||
protected function _loadDriver()
|
||||
{
|
||||
if (!class_exists('Symfony\Components\Yaml\Yaml', true)) {
|
||||
if (!class_exists('Symfony\Component\Yaml\Yaml', true)) {
|
||||
$this->markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.');
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ class AllTests
|
||||
$suite->addTestSuite('Doctrine\Tests\ORM\Query\UpdateSqlGenerationTest');
|
||||
$suite->addTestSuite('Doctrine\Tests\ORM\Query\ExprTest');
|
||||
$suite->addTestSuite('Doctrine\Tests\ORM\Query\ParserResultTest');
|
||||
$suite->addTestSuite('Doctrine\Tests\ORM\Query\QueryTest');
|
||||
|
||||
return $suite;
|
||||
}
|
||||
|
47
tests/Doctrine/Tests/ORM/Query/QueryTest.php
Normal file
47
tests/Doctrine/Tests/ORM/Query/QueryTest.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\ORM\Query;
|
||||
|
||||
require_once __DIR__ . '/../../TestInit.php';
|
||||
|
||||
class QueryTest extends \Doctrine\Tests\OrmTestCase
|
||||
{
|
||||
protected $_em = null;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->_em = $this->_getTestEntityManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Doctrine\ORM\Query\QueryException
|
||||
*/
|
||||
public function testParameterIndexZeroThrowsException()
|
||||
{
|
||||
$query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1");
|
||||
$query->execute(array(42)); // same as array(0 => 42), 0 is invalid parameter position
|
||||
}
|
||||
|
||||
public function testGetParameters()
|
||||
{
|
||||
$query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1");
|
||||
$this->assertEquals(array(), $query->getParameters());
|
||||
}
|
||||
|
||||
public function testGetParameters_HasSomeAlready()
|
||||
{
|
||||
$query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1");
|
||||
$query->setParameter(2, 84);
|
||||
$this->assertEquals(array(2 => 84), $query->getParameters());
|
||||
}
|
||||
|
||||
public function testFree()
|
||||
{
|
||||
$query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1");
|
||||
$query->setParameter(2, 84, \PDO::PARAM_INT);
|
||||
|
||||
$query->free();
|
||||
|
||||
$this->assertEquals(array(), $query->getParameters());
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ class ConvertDoctrine1SchemaCommandTest extends \Doctrine\Tests\OrmTestCase
|
||||
$command = new ConvertDoctrine1SchemaCommand();
|
||||
$command->setEntityGenerator($entityGenerator);
|
||||
|
||||
$output = $this->getMock('Symfony\Components\Console\Output\OutputInterface');
|
||||
$output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
|
||||
$output->expects($this->once())
|
||||
->method('write')
|
||||
->with($this->equalTo('No Metadata Classes to process.' . PHP_EOL));
|
||||
|
@ -61,7 +61,7 @@ class ConvertDoctrine1SchemaTest extends \Doctrine\Tests\OrmTestCase
|
||||
|
||||
public function testTest()
|
||||
{
|
||||
if ( ! class_exists('Symfony\Components\Yaml\Yaml', true)) {
|
||||
if ( ! class_exists('Symfony\Component\Yaml\Yaml', true)) {
|
||||
$this->markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.');
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ class YamlClassMetadataExporterTest extends AbstractClassMetadataExporterTest
|
||||
{
|
||||
protected function _getType()
|
||||
{
|
||||
if (!class_exists('Symfony\Components\Yaml\Yaml', true)) {
|
||||
if (!class_exists('Symfony\Component\Yaml\Yaml', true)) {
|
||||
$this->markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.');
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ $classLoader->register();
|
||||
// Variable $helperSet is defined inside cli-config.php
|
||||
require __DIR__ . '/cli-config.php';
|
||||
|
||||
$cli = new \Symfony\Components\Console\Application('Doctrine Command Line Interface', Doctrine\Common\Version::VERSION);
|
||||
$cli = new \Symfony\Component\Console\Application('Doctrine Command Line Interface', Doctrine\Common\Version::VERSION);
|
||||
$cli->setCatchExceptions(true);
|
||||
$helperSet = $cli->getHelperSet();
|
||||
foreach ($helpers as $name => $helper) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user