Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #339 from FabioBatSilva/DDC-1784

Fix DDC-1784
  • Loading branch information...
commit d5d47222c1dc5ea97ebd8f4c68834fbe4abeb238 2 parents d95e96b + 9b02745
Guilherme Blanco authored
4  lib/Doctrine/ORM/Tools/EntityGenerator.php
@@ -1062,11 +1062,11 @@ private function _generateFieldMappingPropertyDocBlock(array $fieldMapping, Clas
1062 1062
                     }
1063 1063
 
1064 1064
                     if (isset($metadata->sequenceGeneratorDefinition['allocationSize'])) {
1065  
-                        $sequenceGenerator[] = 'allocationSize="' . $metadata->sequenceGeneratorDefinition['allocationSize'] . '"';
  1065
+                        $sequenceGenerator[] = 'allocationSize=' . $metadata->sequenceGeneratorDefinition['allocationSize'];
1066 1066
                     }
1067 1067
 
1068 1068
                     if (isset($metadata->sequenceGeneratorDefinition['initialValue'])) {
1069  
-                        $sequenceGenerator[] = 'initialValue="' . $metadata->sequenceGeneratorDefinition['initialValue'] . '"';
  1069
+                        $sequenceGenerator[] = 'initialValue=' . $metadata->sequenceGeneratorDefinition['initialValue'];
1070 1070
                     }
1071 1071
 
1072 1072
                     $lines[] = $this->_spaces . ' * @' . $this->_annotationsPrefix . 'SequenceGenerator(' . implode(', ', $sequenceGenerator) . ')';
33  tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php
@@ -222,6 +222,39 @@ public function testParseTokensInEntityFile($php, $classes)
222 222
         $this->assertEquals($classes, array_keys($p->getValue($this->_generator)));
223 223
     }
224 224
 
  225
+    /**
  226
+     * @group DDC-1784
  227
+     */
  228
+    public function testGenerateEntityWithSequenceGenerator()
  229
+    {
  230
+        $metadata               = new ClassMetadataInfo($this->_namespace . '\DDC1784Entity');
  231
+        $metadata->namespace    = $this->_namespace;
  232
+        $metadata->mapField(array('fieldName' => 'id', 'type' => 'integer', 'id' => true));
  233
+        $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE);
  234
+        $metadata->setSequenceGeneratorDefinition(array(
  235
+            'sequenceName'      => 'DDC1784_ID_SEQ',
  236
+            'allocationSize'    => 1,
  237
+            'initialValue'      => 2
  238
+        ));
  239
+        $this->_generator->writeEntityClass($metadata, $this->_tmpDir);
  240
+
  241
+        $filename = $this->_tmpDir . DIRECTORY_SEPARATOR
  242
+                  . $this->_namespace . DIRECTORY_SEPARATOR . 'DDC1784Entity.php';
  243
+        
  244
+        $this->assertFileExists($filename);
  245
+        require_once $filename;
  246
+
  247
+
  248
+        $reflection = new \ReflectionProperty($metadata->name, 'id');
  249
+        $docComment = $reflection->getDocComment();
  250
+
  251
+        $this->assertContains('@Id', $docComment);
  252
+        $this->assertContains('@Column(name="id", type="integer")', $docComment);
  253
+        $this->assertContains('@GeneratedValue(strategy="SEQUENCE")', $docComment);
  254
+        $this->assertContains('@SequenceGenerator(sequenceName="DDC1784_ID_SEQ", allocationSize=1, initialValue=2)', $docComment);
  255
+    }
  256
+
  257
+
225 258
     public function getParseTokensInEntityFileData()
226 259
     {
227 260
         return array(

0 notes on commit d5d4722

Please sign in to comment.
Something went wrong with that request. Please try again.