Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions tests/Expression/ExpressionEvaluatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace JMS\Serializer\Tests\Expression;

use JMS\Serializer\Expression\Expression;
use JMS\Serializer\Expression\ExpressionEvaluator;
use PHPUnit\Framework\TestCase;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
Expand All @@ -29,8 +28,6 @@ public function testEvaluate()
public function testParse()
{
$parsed = $this->evaluator->parse('a + b', ['a', 'b']);
self::assertInstanceOf(Expression::class, $parsed);

$evaluated = $this->evaluator->evaluateParsed($parsed, ['a' => 1, 'b' => 2]);
self::assertSame(3, $evaluated);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/IndexedCommentsBlogPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ class IndexedCommentsList
public function addComment(Comment $comment)
{
$this->comments[] = $comment;
$this->count += 1;
++$this->count;
}
}
2 changes: 1 addition & 1 deletion tests/Fixtures/ObjectWithEmptyArrayAndHash.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ObjectWithEmptyArrayAndHash
* @Serializer\SkipWhenEmpty()
*/
#[Serializer\SkipWhenEmpty]
private $object = [];
private $object;

public function __construct()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/TypedProperties/UnionTypedProperties.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class UnionTypedProperties
{
public bool|float|string|array|int $data;

private int|bool|float|string|null $nullableData = null;
private int|bool|float|string|null $nullableData;

private string|false $valueTypedUnion;

Expand Down
8 changes: 4 additions & 4 deletions tests/Handler/FormErrorHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,12 +282,12 @@ protected function getMockForm($name = 'name'): MockObject
$form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock();
$config = $this->getMockBuilder('Symfony\Component\Form\FormConfigInterface')->getMock();

$form->expects($this->any())
$form
->method('getName')
->will($this->returnValue($name));
$form->expects($this->any())
->willReturn($name);
$form
->method('getConfig')
->will($this->returnValue($config));
->willReturn($config);

return $form;
}
Expand Down
6 changes: 5 additions & 1 deletion tests/Metadata/Driver/BaseDriverTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ public function testVirtualProperty()
self::assertArrayHasKey('virtualSerializedValue', $m->propertyMetadata);
self::assertArrayHasKey('typedVirtualProperty', $m->propertyMetadata);

self::assertEquals($m->propertyMetadata['virtualSerializedValue']->serializedName, 'test', 'Serialized name is missing');
self::assertEquals(
'test',
$m->propertyMetadata['virtualSerializedValue']->serializedName,
'Serialized name is missing',
);

$p = new VirtualPropertyMetadata($m->name, 'virtualValue');
$p->getter = 'getVirtualValue';
Expand Down
4 changes: 2 additions & 2 deletions tests/Metadata/Driver/DoctrinePHPCRDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ public function getAnnotationDriver()
{
if (class_exists(DoctrinePHPCRDriver::class)) {
return new AnnotationDriver(new AnnotationReader(), new IdenticalPropertyNamingStrategy());
} else {
return new AnnotationOrAttributeDriver(new IdenticalPropertyNamingStrategy());
}

return new AnnotationOrAttributeDriver(new IdenticalPropertyNamingStrategy());
}

protected function getDoctrinePHPCRDriver()
Expand Down
12 changes: 3 additions & 9 deletions tests/Serializer/BaseSerializationTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ public function testDeserializingNull()
$builder->setObjectConstructor($objectConstructor);
$this->serializer = $builder->build();

$post = new BlogPost('This is a nice title.', $author = new Author('Foo Bar'), new \DateTime('2011-07-30 00:00', new \DateTimeZone('UTC')), new Publisher('Bar Foo'));
$post = new BlogPost('This is a nice title.', new Author('Foo Bar'), new \DateTime('2011-07-30 00:00', new \DateTimeZone('UTC')), new Publisher('Bar Foo'));

$this->setField($post, 'author', null);
$this->setField($post, 'publisher', null);
Expand Down Expand Up @@ -1309,11 +1309,7 @@ public function testFormErrorsWithNonFormComponents($type)
$context = SerializationContext::create();
$context->setInitialType($type);

try {
$this->serialize($form, $context);
} catch (\Throwable $e) {
self::assertTrue(false, 'Serialization should not throw an exception');
}
$this->serialize($form, $context);
}

public static function initialFormTypeProvider()
Expand Down Expand Up @@ -1998,9 +1994,7 @@ public function testThrowingExceptionWhenDeserializingUnionDocBlockTypes()
}

$this->expectException(RuntimeException::class);

$object = new UnionTypedDocBlockProperty(10000);
$deserialized = $this->deserialize(static::getContent('data_integer'), UnionTypedDocBlockProperty::class);
$this->deserialize(static::getContent('data_integer'), UnionTypedDocBlockProperty::class);
}

public function testIterable(): void
Expand Down
4 changes: 2 additions & 2 deletions tests/Serializer/ContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testSerializationContextPathAndDepth()
$self = $this;

$exclusionStrategy = $this->getMockBuilder(ExclusionStrategyInterface::class)->getMock();
$exclusionStrategy->expects($this->any())
$exclusionStrategy
->method('shouldSkipClass')
->with($this->anything(), $this->callback(static function (SerializationContext $context) use ($self, $objects) {
$expectedDepth = $expectedPath = null;
Expand All @@ -61,7 +61,7 @@ public function testSerializationContextPathAndDepth()
}))
->willReturn(false);

$exclusionStrategy->expects($this->any())
$exclusionStrategy
->method('shouldSkipProperty')
->with($this->anything(), $this->callback(static function (SerializationContext $context) use ($self, $objects) {
$expectedDepth = $expectedPath = null;
Expand Down
10 changes: 5 additions & 5 deletions tests/Serializer/DateIntervalFormatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ public function testFormat()
$dtf = new DateHandler();

$ATOMDateIntervalString = $dtf->format(new \DateInterval('P0D'));
self::assertEquals($ATOMDateIntervalString, 'P0DT0S');
self::assertEquals('P0DT0S', $ATOMDateIntervalString);

$ATOMDateIntervalString = $dtf->format(new \DateInterval('P0DT0S'));
self::assertEquals($ATOMDateIntervalString, 'P0DT0S');
self::assertEquals('P0DT0S', $ATOMDateIntervalString);

$ATOMDateIntervalString = $dtf->format(new \DateInterval('PT45M'));

self::assertEquals($ATOMDateIntervalString, 'PT45M');
self::assertEquals('PT45M', $ATOMDateIntervalString);

$ATOMDateIntervalString = $dtf->format(new \DateInterval('P2YT45M'));

self::assertEquals($ATOMDateIntervalString, 'P2YT45M');
self::assertEquals('P2YT45M', $ATOMDateIntervalString);

$ATOMDateIntervalString = $dtf->format(new \DateInterval('P2Y4DT6H8M16S'));

self::assertEquals($ATOMDateIntervalString, 'P2Y4DT6H8M16S');
self::assertEquals('P2Y4DT6H8M16S', $ATOMDateIntervalString);
}
}
14 changes: 7 additions & 7 deletions tests/Serializer/Doctrine/ObjectConstructorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ public function testFallbackOnEmbeddableClassWithXmlDriver()
$connection = $this->createConnection();
$entityManager = $this->createXmlEntityManager($connection);

$this->registry = $registry = new SimpleBaseManagerRegistry(
$this->registry = new SimpleBaseManagerRegistry(
static function ($id) use ($connection, $entityManager) {
switch ($id) {
case 'default_connection':
Expand Down Expand Up @@ -394,7 +394,7 @@ public function testFallbackOnEmbeddableClassWithXmlDriverAndXmlData()
$connection = $this->createConnection();
$entityManager = $this->createXmlEntityManager($connection);

$this->registry = $registry = new SimpleBaseManagerRegistry(
$this->registry = new SimpleBaseManagerRegistry(
static function ($id) use ($connection, $entityManager) {
switch ($id) {
case 'default_connection':
Expand Down Expand Up @@ -426,33 +426,33 @@ public function testArrayKeyExistsOnObject(): void

$ormClassMetadata = $this->createMock(DoctrineClassMetadata::class);
$ormClassMetadata
->expects(self::atLeastOnce())
->expects($this->atLeastOnce())
->method('getIdentifierFieldNames')
->willReturn(['id']);

$om = $this->createMock(ObjectManager::class);
$om
->expects(self::atLeastOnce())
->expects($this->atLeastOnce())
->method('getMetadataFactory')
->willReturn($metadataFactory);
$om
->expects(self::atLeastOnce())
->expects($this->atLeastOnce())
->method('getClassMetadata')
->willReturnMap([
[BlogPostSeo::class, $ormClassMetadata],
]);

$registry = $this->createMock(ManagerRegistry::class);
$registry
->expects(self::atLeastOnce())
->expects($this->atLeastOnce())
->method('getManagerForClass')
->willReturnMap([
[BlogPostSeo::class, $om],
]);

$fallback = $this->createMock(ObjectConstructorInterface::class);
$fallback
->expects(self::once())
->expects($this->once())
->method('construct');

$type = ['name' => BlogPostSeo::class, 'params' => []];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ public function testListenersCanChangeType()
{
$proxy = new SimpleObjectProxy('foo', 'bar');

$realClassEventTriggered1 = false;
$this->dispatcher->addListener('serializer.pre_serialize', static function (PreSerializeEvent $event) {
$event->setType('foo', ['bar']);
}, get_parent_class($proxy));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testValidate(): void
{
$obj = new stdClass();

$this->validator->expects(self::once())
$this->validator->expects($this->once())
->method('validate')
->with($obj, null, ['foo'])
->willReturn(new ConstraintViolationList());
Expand All @@ -42,7 +42,7 @@ public function testValidateThrowsExceptionWhenListIsNotEmpty(): void
{
$obj = new stdClass();

$this->validator->expects(self::once())
$this->validator->expects($this->once())
->method('validate')
->with($obj, null, ['foo'])
->willReturn(new ConstraintViolationList([new ConstraintViolation('foo', 'foo', [], 'a', 'b', 'c')]));
Expand All @@ -57,15 +57,15 @@ public function testValidateThrowsExceptionWhenListIsNotEmpty(): void

public function testValidatorIsNotCalledWhenNoGroupsAreSet(): void
{
$this->validator->expects(self::never())
$this->validator->expects($this->never())
->method('validate');

$this->subscriber->onPostDeserialize(new ObjectEvent(DeserializationContext::create(), new stdClass(), []));
}

public function testValidationIsOnlyPerformedOnRootObject(): void
{
$this->validator->expects(self::once())
$this->validator->expects($this->once())
->method('validate')
->with(self::isInstanceOf(AuthorList::class), null, ['Foo'])
->willReturn(new ConstraintViolationList());
Expand Down
4 changes: 2 additions & 2 deletions tests/Serializer/XmlSerializationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,15 @@ public function testUnserializeMissingArray()
{
$xml = '<result></result>';
$object = $this->serializer->deserialize($xml, 'JMS\Serializer\Tests\Fixtures\ObjectWithAbsentXmlListNode', 'xml');
self::assertEquals($object->absentAndNs, []);
self::assertEquals([], $object->absentAndNs);

$xml = '<result xmlns:x="http://www.example.com">
<absent_and_ns>
<x:entry>foo</x:entry>
</absent_and_ns>
</result>';
$object = $this->serializer->deserialize($xml, 'JMS\Serializer\Tests\Fixtures\ObjectWithAbsentXmlListNode', 'xml');
self::assertEquals($object->absentAndNs, ['foo']);
self::assertEquals(['foo'], $object->absentAndNs);
}

public function testObjectWithNamespacesAndList()
Expand Down
2 changes: 1 addition & 1 deletion tests/Util/DeprecationLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __destruct()
} else {
sort($this->errors);
array_map(static function (array $m) {
[$errno, $errstr, $errfile, $errline] = $m;
[, $errstr, $errfile, $errline] = $m;
echo '- ' . sprintf('%s in %s:%s', $errstr, $errfile, $errline) . PHP_EOL;
}, $this->errors);
}
Expand Down
Loading