minor #29994 Replace gender by eye color in tests (Raphaëll Roussel)

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
-------

72180342b7 Replace gender by eye color in tests
This commit is contained in:
Nicolas Grekas 2019-01-26 21:56:21 +01:00
commit dc8c506f00
9 changed files with 27 additions and 27 deletions

View File

@ -4,5 +4,5 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Serialization;
class Author
{
public $gender;
public $eyeColor;
}

View File

@ -4,5 +4,5 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Serialization;
class Person
{
public $gender;
public $eyeColor;
}

View File

@ -1,4 +1,4 @@
Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Serialization\Author:
attributes:
gender:
eyeColor:
groups: ['group1', 'group2']

View File

@ -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>

View File

@ -4,5 +4,5 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Validation;
class Author
{
public $gender;
public $eyeColor;
}

View File

@ -4,5 +4,5 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Validation;
class Person
{
public $gender;
public $eyeColor;
}

View File

@ -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. }

View File

@ -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>

View File

@ -190,11 +190,11 @@ XML;
{
$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'));
}
@ -203,11 +203,11 @@ XML;
{
$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'));
}
@ -227,11 +227,11 @@ XML;
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'));
}
@ -330,11 +330,11 @@ XML;
$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));
}
@ -398,10 +398,10 @@ XML;
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'));
@ -410,11 +410,11 @@ XML;
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'));
@ -423,12 +423,12 @@ XML;
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'));