1
0
mirror of synced 2025-02-07 07:49:27 +03:00

Remove trailing whitespaces and fix brace locations

This commit is contained in:
Vitali Yakavenka 2011-11-30 00:20:00 +03:00
parent f13f44a2fc
commit 353ba4dfd1
6 changed files with 58 additions and 46 deletions

View File

@ -273,7 +273,7 @@
<xs:attribute name="initial-value" type="xs:integer" use="optional" default="1" /> <xs:attribute name="initial-value" type="xs:integer" use="optional" default="1" />
<xs:anyAttribute namespace="##other"/> <xs:anyAttribute namespace="##other"/>
</xs:complexType> </xs:complexType>
<xs:complexType name="custom-id-generator"> <xs:complexType name="custom-id-generator">
<xs:sequence> <xs:sequence>
<xs:element name="args" minOccurs="0" maxOccurs="1"> <xs:element name="args" minOccurs="0" maxOccurs="1">

View File

@ -181,7 +181,7 @@ class ClassMetadataInfo implements ClassMetadata
public $rootEntityName; public $rootEntityName;
/** /**
* READ-ONLY: The definition of custom generator. Only used for CUSTOM * READ-ONLY: The definition of custom generator. Only used for CUSTOM
* generator type * generator type
* *
* The definition has the following structure: * The definition has the following structure:
@ -1828,12 +1828,13 @@ class ClassMetadataInfo implements ClassMetadata
{ {
$this->idGenerator = $generator; $this->idGenerator = $generator;
} }
/** /**
* Sets definition * Sets definition
* @param array $definition * @param array $definition
*/ */
public function setCustomGeneratorDefinition(array $definition) { public function setCustomGeneratorDefinition(array $definition)
{
$this->customGeneratorDefinition = $definition; $this->customGeneratorDefinition = $definition;
} }

View File

@ -23,7 +23,8 @@ namespace Doctrine\ORM\Mapping;
* @Annotation * @Annotation
* @Target("PROPERTY") * @Target("PROPERTY")
*/ */
final class CustomIdGenerator implements Annotation { final class CustomIdGenerator implements Annotation
{
/** @var string */ /** @var string */
public $class; public $class;
/** @var array */ /** @var array */

View File

@ -192,11 +192,11 @@ class YamlDriver extends AbstractFileDriver
if (isset($idElement['sequenceGenerator'])) { if (isset($idElement['sequenceGenerator'])) {
$metadata->setSequenceGeneratorDefinition($idElement['sequenceGenerator']); $metadata->setSequenceGeneratorDefinition($idElement['sequenceGenerator']);
} else if (isset($idElement['customIdGenerator'])) { } else if (isset($idElement['customIdGenerator'])) {
$customGenerator = $idElement['customIdGenerator']; $customGenerator = $idElement['customIdGenerator'];
$metadata->setCustomGeneratorDefinition(array( $metadata->setCustomGeneratorDefinition(array(
'class' => (string) $customGenerator['class'], 'class' => (string) $customGenerator['class'],
'args' => $customGenerator['args'] 'args' => $customGenerator['args']
)); ));
} else if (isset($idElement['tableGenerator'])) { } else if (isset($idElement['tableGenerator'])) {
throw MappingException::tableIdGeneratorNotImplemented($className); throw MappingException::tableIdGeneratorNotImplemented($className);
} }

View File

@ -88,12 +88,12 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
$class->sequenceGeneratorDefinition $class->sequenceGeneratorDefinition
); );
} }
public function testEntityCustomGenerator() public function testEntityCustomGenerator()
{ {
$class = $this->createClassMetadata('Doctrine\Tests\ORM\Mapping\Animal'); $class = $this->createClassMetadata('Doctrine\Tests\ORM\Mapping\Animal');
$this->assertEquals(ClassMetadata::GENERATOR_TYPE_CUSTOM, $this->assertEquals(ClassMetadata::GENERATOR_TYPE_CUSTOM,
$class->generatorType, "Generator Type"); $class->generatorType, "Generator Type");
$this->assertEquals( $this->assertEquals(
array("class" => "stdClass", "args" => array("par1", "par2")), array("class" => "stdClass", "args" => array("par1", "par2")),

View File

@ -48,23 +48,25 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase
$this->assertEquals(ClassMetadata::GENERATOR_TYPE_SEQUENCE, $cm1->generatorType); $this->assertEquals(ClassMetadata::GENERATOR_TYPE_SEQUENCE, $cm1->generatorType);
} }
public function testGetMetadataFor_ReturnsLoadedCustomIdGenerator() { public function testGetMetadataFor_ReturnsLoadedCustomIdGenerator()
{
$cm1 = $this->_createValidClassMetadata(); $cm1 = $this->_createValidClassMetadata();
$cm1->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_CUSTOM); $cm1->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_CUSTOM);
$cm1->customGeneratorDefinition = array( $cm1->customGeneratorDefinition = array(
"class" => "Doctrine\Tests\ORM\Mapping\CustomIdGenerator"); "class" => "Doctrine\Tests\ORM\Mapping\CustomIdGenerator");
$cmf = $this->_createTestFactory(); $cmf = $this->_createTestFactory();
$cmf->setMetadataForClass($cm1->name, $cm1); $cmf->setMetadataForClass($cm1->name, $cm1);
$actual = $cmf->getMetadataFor($cm1->name); $actual = $cmf->getMetadataFor($cm1->name);
$this->assertEquals(ClassMetadata::GENERATOR_TYPE_CUSTOM, $this->assertEquals(ClassMetadata::GENERATOR_TYPE_CUSTOM,
$actual->generatorType); $actual->generatorType);
$this->assertInstanceOf("Doctrine\Tests\ORM\Mapping\CustomIdGenerator", $this->assertInstanceOf("Doctrine\Tests\ORM\Mapping\CustomIdGenerator",
$actual->idGenerator); $actual->idGenerator);
} }
public function testGetMetadataFor_PasesArgumentsToGeneratorsConstructor() { public function testGetMetadataFor_PasesArgumentsToGeneratorsConstructor()
{
$cm1 = $this->_createValidClassMetadata(); $cm1 = $this->_createValidClassMetadata();
$cm1->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_CUSTOM); $cm1->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_CUSTOM);
$cm1->customGeneratorDefinition = array( $cm1->customGeneratorDefinition = array(
@ -73,39 +75,41 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase
$cmf = $this->_createTestFactory(); $cmf = $this->_createTestFactory();
$cmf->setMetadataForClass($cm1->name, $cm1); $cmf->setMetadataForClass($cm1->name, $cm1);
$expected = new CustomIdGenerator("parameter"); $expected = new CustomIdGenerator("parameter");
$actual = $cmf->getMetadataFor($cm1->name); $actual = $cmf->getMetadataFor($cm1->name);
$this->assertEquals(ClassMetadata::GENERATOR_TYPE_CUSTOM, $this->assertEquals(ClassMetadata::GENERATOR_TYPE_CUSTOM,
$actual->generatorType); $actual->generatorType);
$this->assertEquals($expected, $actual->idGenerator); $this->assertEquals($expected, $actual->idGenerator);
} }
public function testGetMetadataFor_ThrowsExceptionOnUnknownCustomGeneratorClass() { public function testGetMetadataFor_ThrowsExceptionOnUnknownCustomGeneratorClass()
{
$cm1 = $this->_createValidClassMetadata(); $cm1 = $this->_createValidClassMetadata();
$cm1->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_CUSTOM); $cm1->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_CUSTOM);
$cm1->customGeneratorDefinition = array("class" => "NotExistingGenerator"); $cm1->customGeneratorDefinition = array("class" => "NotExistingGenerator");
$cmf = $this->_createTestFactory(); $cmf = $this->_createTestFactory();
$cmf->setMetadataForClass($cm1->name, $cm1); $cmf->setMetadataForClass($cm1->name, $cm1);
$this->setExpectedException("Doctrine\ORM\ORMException"); $this->setExpectedException("Doctrine\ORM\ORMException");
$actual = $cmf->getMetadataFor($cm1->name); $actual = $cmf->getMetadataFor($cm1->name);
} }
public function testGetMetadataFor_ThrowsExceptionOnMissingCustomGeneratorDefinition() { public function testGetMetadataFor_ThrowsExceptionOnMissingCustomGeneratorDefinition()
{
$cm1 = $this->_createValidClassMetadata(); $cm1 = $this->_createValidClassMetadata();
$cm1->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_CUSTOM); $cm1->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_CUSTOM);
$cmf = $this->_createTestFactory(); $cmf = $this->_createTestFactory();
$cmf->setMetadataForClass($cm1->name, $cm1); $cmf->setMetadataForClass($cm1->name, $cm1);
$this->setExpectedException("Doctrine\ORM\ORMException"); $this->setExpectedException("Doctrine\ORM\ORMException");
$actual = $cmf->getMetadataFor($cm1->name); $actual = $cmf->getMetadataFor($cm1->name);
} }
public function testHasGetMetadata_NamespaceSeperatorIsNotNormalized() public function testHasGetMetadata_NamespaceSeperatorIsNotNormalized()
{ {
require_once __DIR__."/../../Models/Global/GlobalNamespaceModel.php"; require_once __DIR__."/../../Models/Global/GlobalNamespaceModel.php";
$metadataDriver = $this->createAnnotationDriver(array(__DIR__ . '/../../Models/Global/')); $metadataDriver = $this->createAnnotationDriver(array(__DIR__ . '/../../Models/Global/'));
$entityManager = $this->_createEntityManager($metadataDriver); $entityManager = $this->_createEntityManager($metadataDriver);
@ -120,7 +124,7 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase
$this->assertFalse($h2); $this->assertFalse($h2);
$this->assertTrue($h1); $this->assertTrue($h1);
} }
/** /**
* @group DDC-1512 * @group DDC-1512
*/ */
@ -136,13 +140,13 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase
->method('isTransient') ->method('isTransient')
->with($this->equalTo('Doctrine\Tests\Models\CMS\CmsArticle')) ->with($this->equalTo('Doctrine\Tests\Models\CMS\CmsArticle'))
->will($this->returnValue(false)); ->will($this->returnValue(false));
$em = $this->_createEntityManager($driver); $em = $this->_createEntityManager($driver);
$this->assertTrue($em->getMetadataFactory()->isTransient('Doctrine\Tests\Models\CMS\CmsUser')); $this->assertTrue($em->getMetadataFactory()->isTransient('Doctrine\Tests\Models\CMS\CmsUser'));
$this->assertFalse($em->getMetadataFactory()->isTransient('Doctrine\Tests\Models\CMS\CmsArticle')); $this->assertFalse($em->getMetadataFactory()->isTransient('Doctrine\Tests\Models\CMS\CmsArticle'));
} }
/** /**
* @group DDC-1512 * @group DDC-1512
*/ */
@ -158,10 +162,10 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase
->method('isTransient') ->method('isTransient')
->with($this->equalTo('Doctrine\Tests\Models\CMS\CmsArticle')) ->with($this->equalTo('Doctrine\Tests\Models\CMS\CmsArticle'))
->will($this->returnValue(false)); ->will($this->returnValue(false));
$em = $this->_createEntityManager($driver); $em = $this->_createEntityManager($driver);
$em->getConfiguration()->addEntityNamespace('CMS', 'Doctrine\Tests\Models\CMS'); $em->getConfiguration()->addEntityNamespace('CMS', 'Doctrine\Tests\Models\CMS');
$this->assertTrue($em->getMetadataFactory()->isTransient('CMS:CmsUser')); $this->assertTrue($em->getMetadataFactory()->isTransient('CMS:CmsUser'));
$this->assertFalse($em->getMetadataFactory()->isTransient('CMS:CmsArticle')); $this->assertFalse($em->getMetadataFactory()->isTransient('CMS:CmsArticle'));
} }
@ -179,23 +183,25 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase
return EntityManagerMock::create($conn, $config, $eventManager); return EntityManagerMock::create($conn, $config, $eventManager);
} }
/** /**
* @return ClassMetadataFactoryTestSubject * @return ClassMetadataFactoryTestSubject
*/ */
protected function _createTestFactory() { protected function _createTestFactory()
{
$mockDriver = new MetadataDriverMock(); $mockDriver = new MetadataDriverMock();
$entityManager = $this->_createEntityManager($mockDriver); $entityManager = $this->_createEntityManager($mockDriver);
$cmf = new ClassMetadataFactoryTestSubject(); $cmf = new ClassMetadataFactoryTestSubject();
$cmf->setEntityManager($entityManager); $cmf->setEntityManager($entityManager);
return $cmf; return $cmf;
} }
/** /**
* @param string $class * @param string $class
* @return ClassMetadata * @return ClassMetadata
*/ */
protected function _createValidClassMetadata() { protected function _createValidClassMetadata()
{
$cm1 = new ClassMetadata('Doctrine\Tests\ORM\Mapping\TestEntity1'); $cm1 = new ClassMetadata('Doctrine\Tests\ORM\Mapping\TestEntity1');
$cm1->setPrimaryTable(array('name' => '`group`')); $cm1->setPrimaryTable(array('name' => '`group`'));
// Add a mapped field // Add a mapped field
@ -250,10 +256,14 @@ class TestEntity1
private $association; private $association;
} }
class CustomIdGenerator extends \Doctrine\ORM\Id\AbstractIdGenerator { class CustomIdGenerator extends \Doctrine\ORM\Id\AbstractIdGenerator
{
public $parameter; public $parameter;
public function __construct($parameter = null) { public function __construct($parameter = null)
{
$this->parameter = $parameter; $this->parameter = $parameter;
} }
public function generate(\Doctrine\ORM\EntityManager $em, $entity) {} public function generate(\Doctrine\ORM\EntityManager $em, $entity)
{
}
} }