Replace gender by eye color in tests
This commit is contained in:
parent
afb7bb5dde
commit
72180342b7
@ -4,5 +4,5 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Serialization;
|
|||||||
|
|
||||||
class Author
|
class Author
|
||||||
{
|
{
|
||||||
public $gender;
|
public $eyeColor;
|
||||||
}
|
}
|
||||||
|
@ -4,5 +4,5 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Serialization;
|
|||||||
|
|
||||||
class Person
|
class Person
|
||||||
{
|
{
|
||||||
public $gender;
|
public $eyeColor;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Serialization\Author:
|
Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Serialization\Author:
|
||||||
attributes:
|
attributes:
|
||||||
gender:
|
eyeColor:
|
||||||
groups: ['group1', 'group2']
|
groups: ['group1', 'group2']
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
http://symfony.com/schema/dic/serializer-mapping/serializer-mapping-1.0.xsd"
|
http://symfony.com/schema/dic/serializer-mapping/serializer-mapping-1.0.xsd"
|
||||||
>
|
>
|
||||||
<class name="Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Serialization\Person">
|
<class name="Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Serialization\Person">
|
||||||
<attribute name="gender">
|
<attribute name="eyeColor">
|
||||||
<group>group1</group>
|
<group>group1</group>
|
||||||
<group>group2</group>
|
<group>group2</group>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
@ -4,5 +4,5 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Validation;
|
|||||||
|
|
||||||
class Author
|
class Author
|
||||||
{
|
{
|
||||||
public $gender;
|
public $eyeColor;
|
||||||
}
|
}
|
||||||
|
@ -4,5 +4,5 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Validation;
|
|||||||
|
|
||||||
class Person
|
class Person
|
||||||
{
|
{
|
||||||
public $gender;
|
public $eyeColor;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Validation\Author:
|
Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Validation\Author:
|
||||||
properties:
|
properties:
|
||||||
gender:
|
eyeColor:
|
||||||
- Choice: { choices: [male, female, other], message: Choose a valid gender. }
|
- Choice: { choices: [brown, green, blue], message: Choose a valid eye color. }
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
|
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
|
||||||
|
|
||||||
<class name="Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Validation\Person">
|
<class name="Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Validation\Person">
|
||||||
<property name="gender">
|
<property name="eyeColor">
|
||||||
<constraint name="Choice">
|
<constraint name="Choice">
|
||||||
<option name="choices">
|
<option name="choices">
|
||||||
<value>male</value>
|
<value>brown</value>
|
||||||
<value>female</value>
|
<value>green</value>
|
||||||
<value>other</value>
|
<value>blue</value>
|
||||||
</option>
|
</option>
|
||||||
<option name="message">Choose a valid gender.</option>
|
<option name="message">Choose a valid eye color.</option>
|
||||||
</constraint>
|
</constraint>
|
||||||
</property>
|
</property>
|
||||||
</class>
|
</class>
|
||||||
|
@ -190,11 +190,11 @@ XML;
|
|||||||
{
|
{
|
||||||
$array = [
|
$array = [
|
||||||
'#' => 'Paul',
|
'#' => 'Paul',
|
||||||
'@gender' => 'm',
|
'@eye-color' => 'brown',
|
||||||
];
|
];
|
||||||
|
|
||||||
$expected = '<?xml version="1.0"?>'."\n".
|
$expected = '<?xml version="1.0"?>'."\n".
|
||||||
'<response gender="m">Paul</response>'."\n";
|
'<response eye-color="brown">Paul</response>'."\n";
|
||||||
|
|
||||||
$this->assertEquals($expected, $this->encoder->encode($array, 'xml'));
|
$this->assertEquals($expected, $this->encoder->encode($array, 'xml'));
|
||||||
}
|
}
|
||||||
@ -203,11 +203,11 @@ XML;
|
|||||||
{
|
{
|
||||||
$array = [
|
$array = [
|
||||||
'firstname' => 'Paul',
|
'firstname' => 'Paul',
|
||||||
'@gender' => 'm',
|
'@eye-color' => 'brown',
|
||||||
];
|
];
|
||||||
|
|
||||||
$expected = '<?xml version="1.0"?>'."\n".
|
$expected = '<?xml version="1.0"?>'."\n".
|
||||||
'<response gender="m"><firstname>Paul</firstname></response>'."\n";
|
'<response eye-color="brown"><firstname>Paul</firstname></response>'."\n";
|
||||||
|
|
||||||
$this->assertEquals($expected, $this->encoder->encode($array, 'xml'));
|
$this->assertEquals($expected, $this->encoder->encode($array, 'xml'));
|
||||||
}
|
}
|
||||||
@ -227,11 +227,11 @@ XML;
|
|||||||
public function testEncodeScalarWithAttribute()
|
public function testEncodeScalarWithAttribute()
|
||||||
{
|
{
|
||||||
$array = [
|
$array = [
|
||||||
'person' => ['@gender' => 'M', '#' => 'Peter'],
|
'person' => ['@eye-color' => 'brown', '#' => 'Peter'],
|
||||||
];
|
];
|
||||||
|
|
||||||
$expected = '<?xml version="1.0"?>'."\n".
|
$expected = '<?xml version="1.0"?>'."\n".
|
||||||
'<response><person gender="M">Peter</person></response>'."\n";
|
'<response><person eye-color="brown">Peter</person></response>'."\n";
|
||||||
|
|
||||||
$this->assertEquals($expected, $this->encoder->encode($array, 'xml'));
|
$this->assertEquals($expected, $this->encoder->encode($array, 'xml'));
|
||||||
}
|
}
|
||||||
@ -330,11 +330,11 @@ XML;
|
|||||||
$this->encoder->setSerializer($serializer);
|
$this->encoder->setSerializer($serializer);
|
||||||
|
|
||||||
$array = [
|
$array = [
|
||||||
'person' => ['@gender' => 'M', '#' => 'Peter'],
|
'person' => ['@eye-color' => 'brown', '#' => 'Peter'],
|
||||||
];
|
];
|
||||||
|
|
||||||
$expected = '<?xml version="1.0"?>'."\n".
|
$expected = '<?xml version="1.0"?>'."\n".
|
||||||
'<test><person gender="M">Peter</person></test>'."\n";
|
'<test><person eye-color="brown">Peter</person></test>'."\n";
|
||||||
|
|
||||||
$this->assertEquals($expected, $serializer->serialize($array, 'xml', $options));
|
$this->assertEquals($expected, $serializer->serialize($array, 'xml', $options));
|
||||||
}
|
}
|
||||||
@ -398,10 +398,10 @@ XML;
|
|||||||
public function testDecodeScalarWithAttribute()
|
public function testDecodeScalarWithAttribute()
|
||||||
{
|
{
|
||||||
$source = '<?xml version="1.0"?>'."\n".
|
$source = '<?xml version="1.0"?>'."\n".
|
||||||
'<response><person gender="M">Peter</person></response>'."\n";
|
'<response><person eye-color="brown">Peter</person></response>'."\n";
|
||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'person' => ['@gender' => 'M', '#' => 'Peter'],
|
'person' => ['@eye-color' => 'brown', '#' => 'Peter'],
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->assertEquals($expected, $this->encoder->decode($source, 'xml'));
|
$this->assertEquals($expected, $this->encoder->decode($source, 'xml'));
|
||||||
@ -410,11 +410,11 @@ XML;
|
|||||||
public function testDecodeScalarRootAttributes()
|
public function testDecodeScalarRootAttributes()
|
||||||
{
|
{
|
||||||
$source = '<?xml version="1.0"?>'."\n".
|
$source = '<?xml version="1.0"?>'."\n".
|
||||||
'<person gender="M">Peter</person>'."\n";
|
'<person eye-color="brown">Peter</person>'."\n";
|
||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'#' => 'Peter',
|
'#' => 'Peter',
|
||||||
'@gender' => 'M',
|
'@eye-color' => 'brown',
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->assertEquals($expected, $this->encoder->decode($source, 'xml'));
|
$this->assertEquals($expected, $this->encoder->decode($source, 'xml'));
|
||||||
@ -423,12 +423,12 @@ XML;
|
|||||||
public function testDecodeRootAttributes()
|
public function testDecodeRootAttributes()
|
||||||
{
|
{
|
||||||
$source = '<?xml version="1.0"?>'."\n".
|
$source = '<?xml version="1.0"?>'."\n".
|
||||||
'<person gender="M"><firstname>Peter</firstname><lastname>Mac Calloway</lastname></person>'."\n";
|
'<person eye-color="brown"><firstname>Peter</firstname><lastname>Mac Calloway</lastname></person>'."\n";
|
||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'firstname' => 'Peter',
|
'firstname' => 'Peter',
|
||||||
'lastname' => 'Mac Calloway',
|
'lastname' => 'Mac Calloway',
|
||||||
'@gender' => 'M',
|
'@eye-color' => 'brown',
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->assertEquals($expected, $this->encoder->decode($source, 'xml'));
|
$this->assertEquals($expected, $this->encoder->decode($source, 'xml'));
|
||||||
|
Reference in New Issue
Block a user