Skip to content

Commit

Permalink
minor #29994 Replace gender by eye color in tests (Raphaëll Roussel)
Browse files Browse the repository at this point in the history
This PR was merged into the 3.4 branch.

Discussion
----------

Replace gender by eye color in tests

| Q             | A
| ------------- | ---
| Branch?       | 3.4 <!-- see below -->
| Bug fix?      | yes
| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #29737   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | <!-- required for new features -->

<!--
Write a short README entry for your feature/bugfix here (replace this comment block.)
This will help people understand your PR and can be used as a start of the Doc PR.
Additionally:
 - Bug fixes must be submitted against the lowest branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too).
 - Features and deprecations must be submitted against the master branch.
-->

I've slightly changed @derrabus proposition to use color only because of the potentially racist interpretation when used for a person, open for discussion though.

Commits
-------

7218034 Replace gender by eye color in tests
  • Loading branch information
nicolas-grekas committed Jan 26, 2019
2 parents afb7bb5 + 7218034 commit dc8c506
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 27 deletions.
Expand Up @@ -4,5 +4,5 @@

class Author
{
public $gender;
public $eyeColor;
}
Expand Up @@ -4,5 +4,5 @@

class Person
{
public $gender;
public $eyeColor;
}
@@ -1,4 +1,4 @@
Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Serialization\Author:
attributes:
gender:
eyeColor:
groups: ['group1', 'group2']
Expand Up @@ -5,7 +5,7 @@
http://symfony.com/schema/dic/serializer-mapping/serializer-mapping-1.0.xsd"
>
<class name="Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Serialization\Person">
<attribute name="gender">
<attribute name="eyeColor">
<group>group1</group>
<group>group2</group>
</attribute>
Expand Down
Expand Up @@ -4,5 +4,5 @@

class Author
{
public $gender;
public $eyeColor;
}
Expand Up @@ -4,5 +4,5 @@

class Person
{
public $gender;
public $eyeColor;
}
@@ -1,4 +1,4 @@
Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Validation\Author:
properties:
gender:
- Choice: { choices: [male, female, other], message: Choose a valid gender. }
eyeColor:
- Choice: { choices: [brown, green, blue], message: Choose a valid eye color. }
Expand Up @@ -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">

<class name="Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Validation\Person">
<property name="gender">
<property name="eyeColor">
<constraint name="Choice">
<option name="choices">
<value>male</value>
<value>female</value>
<value>other</value>
<value>brown</value>
<value>green</value>
<value>blue</value>
</option>
<option name="message">Choose a valid gender.</option>
<option name="message">Choose a valid eye color.</option>
</constraint>
</property>
</class>
Expand Down
28 changes: 14 additions & 14 deletions src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php
Expand Up @@ -190,11 +190,11 @@ public function testEncodeScalarRootAttributes()
{
$array = [
'#' => 'Paul',
'@gender' => 'm',
'@eye-color' => 'brown',
];

$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'));
}
Expand All @@ -203,11 +203,11 @@ public function testEncodeRootAttributes()
{
$array = [
'firstname' => 'Paul',
'@gender' => 'm',
'@eye-color' => 'brown',
];

$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'));
}
Expand All @@ -227,11 +227,11 @@ public function testEncodeCdataWrapping()
public function testEncodeScalarWithAttribute()
{
$array = [
'person' => ['@gender' => 'M', '#' => 'Peter'],
'person' => ['@eye-color' => 'brown', '#' => 'Peter'],
];

$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'));
}
Expand Down Expand Up @@ -330,11 +330,11 @@ public function testEncodeSerializerXmlRootNodeNameOption()
$this->encoder->setSerializer($serializer);

$array = [
'person' => ['@gender' => 'M', '#' => 'Peter'],
'person' => ['@eye-color' => 'brown', '#' => 'Peter'],
];

$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));
}
Expand Down Expand Up @@ -398,10 +398,10 @@ public function testDecodeWithNamespace()
public function testDecodeScalarWithAttribute()
{
$source = '<?xml version="1.0"?>'."\n".
'<response><person gender="M">Peter</person></response>'."\n";
'<response><person eye-color="brown">Peter</person></response>'."\n";

$expected = [
'person' => ['@gender' => 'M', '#' => 'Peter'],
'person' => ['@eye-color' => 'brown', '#' => 'Peter'],
];

$this->assertEquals($expected, $this->encoder->decode($source, 'xml'));
Expand All @@ -410,11 +410,11 @@ public function testDecodeScalarWithAttribute()
public function testDecodeScalarRootAttributes()
{
$source = '<?xml version="1.0"?>'."\n".
'<person gender="M">Peter</person>'."\n";
'<person eye-color="brown">Peter</person>'."\n";

$expected = [
'#' => 'Peter',
'@gender' => 'M',
'@eye-color' => 'brown',
];

$this->assertEquals($expected, $this->encoder->decode($source, 'xml'));
Expand All @@ -423,12 +423,12 @@ public function testDecodeScalarRootAttributes()
public function testDecodeRootAttributes()
{
$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 = [
'firstname' => 'Peter',
'lastname' => 'Mac Calloway',
'@gender' => 'M',
'@eye-color' => 'brown',
];

$this->assertEquals($expected, $this->encoder->decode($source, 'xml'));
Expand Down

0 comments on commit dc8c506

Please sign in to comment.