Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #339 from FabioBatSilva/DDC-1784

Fix DDC-1784
  • Loading branch information...
commit d5d47222c1dc5ea97ebd8f4c68834fbe4abeb238 2 parents d95e96b + 9b02745
@guilhermeblanco guilhermeblanco authored
View
4 lib/Doctrine/ORM/Tools/EntityGenerator.php
@@ -1062,11 +1062,11 @@ private function _generateFieldMappingPropertyDocBlock(array $fieldMapping, Clas
}
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) . ')';
View
33 tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php
@@ -222,6 +222,39 @@ public function testParseTokensInEntityFile($php, $classes)
$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(
Please sign in to comment.
Something went wrong with that request. Please try again.