Merge pull request #6130 from kalimatas/fix-xml-option-boolean
#6129 Added unit test for boolean option values.
This commit is contained in:
commit
f1bf045af3
@ -661,10 +661,13 @@ class XmlDriver extends FileDriver
|
||||
$value = (string) $option;
|
||||
}
|
||||
|
||||
$attr = $option->attributes();
|
||||
$attributes = $option->attributes();
|
||||
|
||||
if (isset($attr->name)) {
|
||||
$array[(string) $attr->name] = $value;
|
||||
if (isset($attributes->name)) {
|
||||
$nameAttribute = (string) $attributes->name;
|
||||
$array[$nameAttribute] = in_array($nameAttribute, ['unsigned', 'fixed'])
|
||||
? $this->evaluateBoolean($value)
|
||||
: $value;
|
||||
} else {
|
||||
$array[] = $value;
|
||||
}
|
||||
|
@ -210,11 +210,14 @@ abstract class AbstractMappingDriverTest extends OrmTestCase
|
||||
|
||||
/**
|
||||
* @depends testEntityTableNameAndInheritance
|
||||
*
|
||||
* @param ClassMetadata $class
|
||||
*
|
||||
* @return ClassMetadata
|
||||
*/
|
||||
public function testFieldOptions($class)
|
||||
public function testFieldOptions(ClassMetadata $class)
|
||||
{
|
||||
$expected = array('foo' => 'bar', 'baz' => array('key' => 'val'));
|
||||
$expected = ['foo' => 'bar', 'baz' => ['key' => 'val'], 'fixed' => false];
|
||||
$this->assertEquals($expected, $class->fieldMappings['name']['options']);
|
||||
|
||||
return $class;
|
||||
@ -226,7 +229,7 @@ abstract class AbstractMappingDriverTest extends OrmTestCase
|
||||
*/
|
||||
public function testIdFieldOptions($class)
|
||||
{
|
||||
$this->assertEquals(array('foo' => 'bar'), $class->fieldMappings['id']['options']);
|
||||
$this->assertEquals(['foo' => 'bar', 'unsigned' => false], $class->fieldMappings['id']['options']);
|
||||
|
||||
return $class;
|
||||
}
|
||||
@ -244,6 +247,26 @@ abstract class AbstractMappingDriverTest extends OrmTestCase
|
||||
return $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @group #6129
|
||||
*
|
||||
* @depends testLoadMapping
|
||||
*
|
||||
* @param ClassMetadata $class
|
||||
*
|
||||
* @return ClassMetadata
|
||||
*/
|
||||
public function testBooleanValuesForOptionIsSetCorrectly(ClassMetadata $class)
|
||||
{
|
||||
$this->assertInternalType('bool', $class->fieldMappings['id']['options']['unsigned']);
|
||||
$this->assertFalse($class->fieldMappings['id']['options']['unsigned']);
|
||||
|
||||
$this->assertInternalType('bool', $class->fieldMappings['name']['options']['fixed']);
|
||||
$this->assertFalse($class->fieldMappings['name']['options']['fixed']);
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testIdentifier
|
||||
* @param ClassMetadata $class
|
||||
@ -1048,14 +1071,14 @@ class User
|
||||
{
|
||||
/**
|
||||
* @Id
|
||||
* @Column(type="integer", options={"foo": "bar"})
|
||||
* @Column(type="integer", options={"foo": "bar", "unsigned": false})
|
||||
* @generatedValue(strategy="AUTO")
|
||||
* @SequenceGenerator(sequenceName="tablename_seq", initialValue=1, allocationSize=100)
|
||||
**/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @Column(length=50, nullable=true, unique=true, options={"foo": "bar", "baz": {"key": "val"}})
|
||||
* @Column(length=50, nullable=true, unique=true, options={"foo": "bar", "baz": {"key": "val"}, "fixed": false})
|
||||
*/
|
||||
public $name;
|
||||
|
||||
@ -1129,7 +1152,7 @@ class User
|
||||
'fieldName' => 'id',
|
||||
'type' => 'integer',
|
||||
'columnName' => 'id',
|
||||
'options' => array('foo' => 'bar'),
|
||||
'options' => array('foo' => 'bar', 'unsigned' => false),
|
||||
));
|
||||
$metadata->mapField(array(
|
||||
'fieldName' => 'name',
|
||||
@ -1138,7 +1161,7 @@ class User
|
||||
'unique' => true,
|
||||
'nullable' => true,
|
||||
'columnName' => 'name',
|
||||
'options' => array('foo' => 'bar', 'baz' => array('key' => 'val')),
|
||||
'options' => array('foo' => 'bar', 'baz' => array('key' => 'val'), 'fixed' => false),
|
||||
));
|
||||
$metadata->mapField(array(
|
||||
'fieldName' => 'email',
|
||||
@ -1474,4 +1497,4 @@ class SingleTableEntityIncompleteDiscriminatorColumnMapping
|
||||
class SingleTableEntityIncompleteDiscriminatorColumnMappingSub1
|
||||
extends SingleTableEntityIncompleteDiscriminatorColumnMapping {}
|
||||
class SingleTableEntityIncompleteDiscriminatorColumnMappingSub2
|
||||
extends SingleTableEntityIncompleteDiscriminatorColumnMapping {}
|
||||
extends SingleTableEntityIncompleteDiscriminatorColumnMapping {}
|
||||
|
@ -34,7 +34,7 @@ class XmlMappingDriverTest extends AbstractMappingDriverTest
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Doctrine\ORM\Cache\CacheException
|
||||
* @expectedException \Doctrine\ORM\Cache\CacheException
|
||||
* @expectedExceptionMessage Entity association field "Doctrine\Tests\ORM\Mapping\XMLSLC#foo" not configured as part of the second-level cache.
|
||||
*/
|
||||
public function testFailingSecondLevelCacheAssociation()
|
||||
@ -132,7 +132,7 @@ class XmlMappingDriverTest extends AbstractMappingDriverTest
|
||||
/**
|
||||
* @group DDC-1468
|
||||
*
|
||||
* @expectedException Doctrine\Common\Persistence\Mapping\MappingException
|
||||
* @expectedException \Doctrine\Common\Persistence\Mapping\MappingException
|
||||
* @expectedExceptionMessage Invalid mapping file 'Doctrine.Tests.Models.Generic.SerializationModel.dcm.xml' for class 'Doctrine\Tests\Models\Generic\SerializationModel'.
|
||||
*/
|
||||
public function testInvalidMappingFileException()
|
||||
|
@ -19,7 +19,7 @@ $metadata->mapField(array(
|
||||
'fieldName' => 'id',
|
||||
'type' => 'integer',
|
||||
'columnName' => 'id',
|
||||
'options' => array('foo' => 'bar'),
|
||||
'options' => array('foo' => 'bar', 'unsigned' => false),
|
||||
));
|
||||
$metadata->mapField(array(
|
||||
'fieldName' => 'name',
|
||||
@ -28,7 +28,7 @@ $metadata->mapField(array(
|
||||
'unique' => true,
|
||||
'nullable' => true,
|
||||
'columnName' => 'name',
|
||||
'options' => array('foo' => 'bar', 'baz' => array('key' => 'val')),
|
||||
'options' => array('foo' => 'bar', 'baz' => array('key' => 'val'), 'fixed' => false),
|
||||
));
|
||||
$metadata->mapField(array(
|
||||
'fieldName' => 'email',
|
||||
|
@ -41,6 +41,7 @@
|
||||
<sequence-generator sequence-name="tablename_seq" allocation-size="100" initial-value="1" />
|
||||
<options>
|
||||
<option name="foo">bar</option>
|
||||
<option name="unsigned">false</option>
|
||||
</options>
|
||||
</id>
|
||||
|
||||
@ -50,6 +51,7 @@
|
||||
<option name="baz">
|
||||
<option name="key">val</option>
|
||||
</option>
|
||||
<option name="fixed">false</option>
|
||||
</options>
|
||||
</field>
|
||||
<field name="email" column="user_email" type="string" column-definition="CHAR(32) NOT NULL" />
|
||||
|
@ -18,6 +18,7 @@ Doctrine\Tests\ORM\Mapping\User:
|
||||
initialValue: 1
|
||||
options:
|
||||
foo: bar
|
||||
unsigned: false
|
||||
fields:
|
||||
name:
|
||||
type: string
|
||||
@ -28,6 +29,7 @@ Doctrine\Tests\ORM\Mapping\User:
|
||||
foo: bar
|
||||
baz:
|
||||
key: val
|
||||
fixed: false
|
||||
email:
|
||||
type: string
|
||||
column: user_email
|
||||
|
Loading…
x
Reference in New Issue
Block a user