minor #13818 [Serializer] Test that normalizers ignore non-existing attributes. (dunglas)

This PR was squashed before being merged into the 2.7 branch (closes #13818).

Discussion
----------

[Serializer] Test that normalizers ignore non-existing attributes.

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  |no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Test the behavior of normalizers when an attribute doesn't exist.

Commits
-------

df0fe30 [Serializer] Test that normalizers ignore non-existing attributes.
This commit is contained in:
Fabien Potencier 2015-03-03 09:32:45 +01:00
commit 12cf04f8f3
2 changed files with 16 additions and 0 deletions

View File

@ -426,6 +426,14 @@ class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('foo', $obj->getFoo());
$this->assertEquals('bar', $obj->getBar());
}
public function testDenormalizeNonExistingAttribute()
{
$this->assertEquals(
new PropertyDummy(),
$this->normalizer->denormalize(array('non_existing' => true), __NAMESPACE__.'\PropertyDummy')
);
}
}
class GetSetDummy

View File

@ -333,6 +333,14 @@ class PropertyNormalizerTest extends \PHPUnit_Framework_TestCase
$expected = array('me' => 'Symfony\Component\Serializer\Tests\Fixtures\PropertyCircularReferenceDummy');
$this->assertEquals($expected, $this->normalizer->normalize($obj));
}
public function testDenormalizeNonExistingAttribute()
{
$this->assertEquals(
new PropertyDummy(),
$this->normalizer->denormalize(array('non_existing' => true), __NAMESPACE__.'\PropertyDummy')
);
}
}
class PropertyDummy