Skip to content

Commit

Permalink
Merge branch '3.4' into 4.1
Browse files Browse the repository at this point in the history
* 3.4:
  [HttpFoundation] Check file exists before unlink
  [Console] Fixed symfony#29835: ConfirmationQuestion with default true for answer '0'
  [Translation] Concatenated translation messages
  [Form] ensure compatibility with older PHPUnit mocks
  [Serializer] Docblock about throwing exceptions on serializer
  [Debug][ErrorHandler] Preserve our error handler when a logger set another one
  [Form] Changed UrlType input type to text when default_protocol is not null
  [Bugfix] MemcachedSessionHandler::close() must close connection
  • Loading branch information
nicolas-grekas committed Jan 25, 2019
2 parents 1618a05 + a2369c9 commit fdf7188
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
2 changes: 2 additions & 0 deletions Normalizer/DenormalizerInterface.php
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Serializer\Normalizer;

use Symfony\Component\Serializer\Exception\BadMethodCallException;
use Symfony\Component\Serializer\Exception\ExceptionInterface;
use Symfony\Component\Serializer\Exception\ExtraAttributesException;
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
use Symfony\Component\Serializer\Exception\LogicException;
Expand Down Expand Up @@ -41,6 +42,7 @@ interface DenormalizerInterface
* @throws ExtraAttributesException Occurs when the item doesn't have attribute to receive given data
* @throws LogicException Occurs when the normalizer is not supposed to denormalize
* @throws RuntimeException Occurs if the class cannot be instantiated
* @throws ExceptionInterface Occurs for all the other cases of errors
*/
public function denormalize($data, $class, $format = null, array $context = []);

Expand Down
2 changes: 2 additions & 0 deletions Normalizer/NormalizerInterface.php
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Serializer\Normalizer;

use Symfony\Component\Serializer\Exception\CircularReferenceException;
use Symfony\Component\Serializer\Exception\ExceptionInterface;
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
use Symfony\Component\Serializer\Exception\LogicException;

Expand All @@ -35,6 +36,7 @@ interface NormalizerInterface
* @throws CircularReferenceException Occurs when the normalizer detects a circular reference when no circular
* reference handler can fix it
* @throws LogicException Occurs when the normalizer is not called in an expected context
* @throws ExceptionInterface Occurs for all the other cases of errors
*/
public function normalize($object, $format = null, array $context = []);

Expand Down
33 changes: 13 additions & 20 deletions Tests/Mapping/ClassMetadataTest.php
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Serializer\Tests\Mapping;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Serializer\Mapping\AttributeMetadata;
use Symfony\Component\Serializer\Mapping\ClassMetadata;

/**
Expand All @@ -29,11 +30,8 @@ public function testAttributeMetadata()
{
$classMetadata = new ClassMetadata('c');

$a1 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock();
$a1->method('getName')->willReturn('a1');

$a2 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock();
$a2->method('getName')->willReturn('a2');
$a1 = new AttributeMetadata('a1');
$a2 = new AttributeMetadata('a2');

$classMetadata->addAttributeMetadata($a1);
$classMetadata->addAttributeMetadata($a2);
Expand All @@ -46,33 +44,28 @@ public function testMerge()
$classMetadata1 = new ClassMetadata('c1');
$classMetadata2 = new ClassMetadata('c2');

$ac1 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock();
$ac1->method('getName')->willReturn('a1');
$ac1->method('getGroups')->willReturn(['a', 'b']);

$ac2 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock();
$ac2->method('getName')->willReturn('a1');
$ac2->method('getGroups')->willReturn(['b', 'c']);
$ac1 = new AttributeMetadata('a1');
$ac1->addGroup('a');
$ac1->addGroup('b');
$ac2 = new AttributeMetadata('a1');
$ac2->addGroup('b');
$ac2->addGroup('c');

$classMetadata1->addAttributeMetadata($ac1);
$classMetadata2->addAttributeMetadata($ac2);

$classMetadata1->merge($classMetadata2);

$ac1->method('getGroups')->willReturn('a', 'b', 'c');

$this->assertEquals(['a1' => $ac1], $classMetadata2->getAttributesMetadata());
$this->assertSame(['a', 'b', 'c'], $ac1->getGroups());
$this->assertEquals(['a1' => $ac1], $classMetadata1->getAttributesMetadata());
}

public function testSerialize()
{
$classMetadata = new ClassMetadata('a');

$a1 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock();
$a1->method('getName')->willReturn('b1');

$a2 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock();
$a2->method('getName')->willReturn('b2');
$a1 = new AttributeMetadata('b1');
$a2 = new AttributeMetadata('b2');

$classMetadata->addAttributeMetadata($a1);
$classMetadata->addAttributeMetadata($a2);
Expand Down

0 comments on commit fdf7188

Please sign in to comment.