Skip to content

Commit

Permalink
Merge pull request doctrine#984 from holtkamp/patch-1
Browse files Browse the repository at this point in the history
Use boolean values for 'unique' attribute
  • Loading branch information
beberlei committed Mar 23, 2014
2 parents 0621b5a + 6e651b1 commit fb2d2bc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public function exportClassMetadata(ClassMetadataInfo $metadata)
}

if (isset($field['unique']) && $field['unique']) {
$fieldXml->addAttribute('unique', $field['unique']);
$fieldXml->addAttribute('unique', $field['unique'] ? 'true' : 'false');
}

if (isset($field['options'])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,27 @@ public function testFieldsAreExported($class)
return $class;
}

/**
* @depends testExportDirectoryAndFilesAreCreated
*/
public function testFieldsAreProperlySerialized()
{
$type = $this->_getType();
if ($type == 'xml') {
$xml = simplexml_load_file(__DIR__ . '/export/'.$type.'/Doctrine.Tests.ORM.Tools.Export.ExportedUser.dcm.xml');

$xml->registerXPathNamespace("d", "http://doctrine-project.org/schemas/orm/doctrine-mapping");
$nodes = $xml->xpath("/d:doctrine-mapping/d:entity/d:field[@name='name' and @type='string' and @nullable='true']");
$this->assertEquals(1, count($nodes));

$nodes = $xml->xpath("/d:doctrine-mapping/d:entity/d:field[@name='name' and @type='string' and @unique='true']");
$this->assertEquals(1, count($nodes));
}
else {
$this->markTestSkipped('Test available only for '.$type.' driver');
}
}

/**
* @depends testFieldsAreExported
* @param ClassMetadataInfo $class
Expand Down

0 comments on commit fb2d2bc

Please sign in to comment.