From 9b02745cd855898bdec34bedb47806c6a5296bf1 Mon Sep 17 00:00:00 2001
From: "Fabio B. Silva" <fabio.bat.silva@gmail.com>
Date: Wed, 18 Apr 2012 20:39:21 -0300
Subject: [PATCH] Fix DDC-1784

---
 lib/Doctrine/ORM/Tools/EntityGenerator.php    |  4 +--
 .../Tests/ORM/Tools/EntityGeneratorTest.php   | 33 +++++++++++++++++++
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/lib/Doctrine/ORM/Tools/EntityGenerator.php b/lib/Doctrine/ORM/Tools/EntityGenerator.php
index 82ab5fe56..561f41076 100644
--- a/lib/Doctrine/ORM/Tools/EntityGenerator.php
+++ b/lib/Doctrine/ORM/Tools/EntityGenerator.php
@@ -1062,11 +1062,11 @@ public function <methodName>()
                     }
 
                     if (isset($metadata->sequenceGeneratorDefinition['allocationSize'])) {
-                        $sequenceGenerator[] = 'allocationSize="' . $metadata->sequenceGeneratorDefinition['allocationSize'] . '"';
+                        $sequenceGenerator[] = 'allocationSize=' . $metadata->sequenceGeneratorDefinition['allocationSize'];
                     }
 
                     if (isset($metadata->sequenceGeneratorDefinition['initialValue'])) {
-                        $sequenceGenerator[] = 'initialValue="' . $metadata->sequenceGeneratorDefinition['initialValue'] . '"';
+                        $sequenceGenerator[] = 'initialValue=' . $metadata->sequenceGeneratorDefinition['initialValue'];
                     }
 
                     $lines[] = $this->_spaces . ' * @' . $this->_annotationsPrefix . 'SequenceGenerator(' . implode(', ', $sequenceGenerator) . ')';
diff --git a/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php b/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php
index 9a239d1f4..bf8d72bd6 100644
--- a/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php
+++ b/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php
@@ -222,6 +222,39 @@ class EntityGeneratorTest extends \Doctrine\Tests\OrmTestCase
         $this->assertEquals($classes, array_keys($p->getValue($this->_generator)));
     }
 
+    /**
+     * @group DDC-1784
+     */
+    public function testGenerateEntityWithSequenceGenerator()
+    {
+        $metadata               = new ClassMetadataInfo($this->_namespace . '\DDC1784Entity');
+        $metadata->namespace    = $this->_namespace;
+        $metadata->mapField(array('fieldName' => 'id', 'type' => 'integer', 'id' => true));
+        $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE);
+        $metadata->setSequenceGeneratorDefinition(array(
+            'sequenceName'      => 'DDC1784_ID_SEQ',
+            'allocationSize'    => 1,
+            'initialValue'      => 2
+        ));
+        $this->_generator->writeEntityClass($metadata, $this->_tmpDir);
+
+        $filename = $this->_tmpDir . DIRECTORY_SEPARATOR
+                  . $this->_namespace . DIRECTORY_SEPARATOR . 'DDC1784Entity.php';
+        
+        $this->assertFileExists($filename);
+        require_once $filename;
+
+
+        $reflection = new \ReflectionProperty($metadata->name, 'id');
+        $docComment = $reflection->getDocComment();
+
+        $this->assertContains('@Id', $docComment);
+        $this->assertContains('@Column(name="id", type="integer")', $docComment);
+        $this->assertContains('@GeneratedValue(strategy="SEQUENCE")', $docComment);
+        $this->assertContains('@SequenceGenerator(sequenceName="DDC1784_ID_SEQ", allocationSize=1, initialValue=2)', $docComment);
+    }
+
+
     public function getParseTokensInEntityFileData()
     {
         return array(