Skip to content

Commit

Permalink
Upgrade phpunit (#220)
Browse files Browse the repository at this point in the history
Upgrade phpunit
  • Loading branch information
Korbeil committed Jan 8, 2020
2 parents 1a974c8 + 6668f6e commit 21b2ea3
Show file tree
Hide file tree
Showing 19 changed files with 69 additions and 68 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,5 +1,6 @@
.idea
.php_cs.cache
.phpunit.result.cache
vendor
composer.lock
bin/*
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -47,7 +47,7 @@
"friendsofphp/php-cs-fixer": "2.15.3",
"localheinz/composer-normalize": "~0.8.0",
"phpbench/phpbench": "@dev",
"phpunit/phpunit": "^6.0",
"phpunit/phpunit": "^8.0",
"symfony/framework-bundle": "^4.4 || ^5.0",
"symfony/phpunit-bridge": "^4.1 || ^5.0"
},
Expand Down
78 changes: 39 additions & 39 deletions src/AutoMapper/Tests/AutoMapperTest.php
Expand Up @@ -34,7 +34,7 @@ class AutoMapperTest extends TestCase
/** @var AutoMapper */
private $autoMapper;

public function setUp()
public function setUp(): void
{
@unlink(__DIR__ . '/cache/registry.php');

Expand All @@ -47,7 +47,7 @@ public function setUp()
$this->autoMapper = AutoMapper::create(true, $loader);
}

public function testAutoMapping()
public function testAutoMapping(): void
{
$configurationUser = $this->autoMapper->getConfiguration(User::class, UserDTO::class);
$configurationUser->forMember('yearOfBirth', function (User $user) {
Expand Down Expand Up @@ -75,7 +75,7 @@ public function testAutoMapping()
self::assertSame('Toulon', $userDto->addresses[0]->city);
}

public function testAutoMapperFromArray()
public function testAutoMapperFromArray(): void
{
$user = [
'id' => 1,
Expand All @@ -96,7 +96,7 @@ public function testAutoMapperFromArray()
self::assertEquals(1987, $userDto->createdAt->format('Y'));
}

public function testAutoMapperToArray()
public function testAutoMapperToArray(): void
{
$address = new Address();
$address->setCity('Toulon');
Expand All @@ -106,13 +106,13 @@ public function testAutoMapperToArray()

$userData = $this->autoMapper->map($user, 'array');

self::assertInternalType('array', $userData);
self::assertIsArray($userData);
self::assertEquals(1, $userData['id']);
self::assertInternalType('array', $userData['address']);
self::assertInternalType('string', $userData['createdAt']);
self::assertIsArray($userData['address']);
self::assertIsString($userData['createdAt']);
}

public function testAutoMapperFromStdObject()
public function testAutoMapperFromStdObject(): void
{
$user = new \stdClass();
$user->id = 1;
Expand All @@ -124,7 +124,7 @@ public function testAutoMapperFromStdObject()
self::assertEquals(1, $userDto->id);
}

public function testAutoMapperToStdObject()
public function testAutoMapperToStdObject(): void
{
$userDto = new UserDTO();
$userDto->id = 1;
Expand All @@ -135,28 +135,28 @@ public function testAutoMapperToStdObject()
self::assertEquals(1, $user->id);
}

public function testGroups()
public function testGroups(): void
{
$foo = new Foo();
$foo->setId(10);

$fooArray = $this->autoMapper->map($foo, 'array', new Context(['test']));

self::assertInternalType('array', $fooArray);
self::assertIsArray($fooArray);
self::assertEquals(10, $fooArray['id']);

$fooArray = $this->autoMapper->map($foo, 'array', new Context([]));

self::assertInternalType('array', $fooArray);
self::assertIsArray($fooArray);
self::assertArrayNotHasKey('id', $fooArray);

$fooArray = $this->autoMapper->map($foo, 'array');

self::assertInternalType('array', $fooArray);
self::assertIsArray($fooArray);
self::assertArrayNotHasKey('id', $fooArray);
}

public function testDeepCloning()
public function testDeepCloning(): void
{
$nodeA = new Node();
$nodeB = new Node();
Expand All @@ -177,7 +177,7 @@ public function testDeepCloning()
self::assertSame($newNode, $newNode->parent->parent->parent);
}

public function testDeepCloningArray()
public function testDeepCloningArray(): void
{
$nodeA = new Node();
$nodeB = new Node();
Expand All @@ -188,14 +188,14 @@ public function testDeepCloningArray()

$newNode = $this->autoMapper->map($nodeA, 'array');

self::assertInternalType('array', $newNode);
self::assertInternalType('array', $newNode['parent']);
self::assertInternalType('array', $newNode['parent']['parent']);
self::assertInternalType('array', $newNode['parent']['parent']['parent']);
self::assertIsArray($newNode);
self::assertIsArray($newNode['parent']);
self::assertIsArray($newNode['parent']['parent']);
self::assertIsArray($newNode['parent']['parent']['parent']);
self::assertSame($newNode, $newNode['parent']['parent']['parent']);
}

public function testCircularReferenceArray()
public function testCircularReferenceArray(): void
{
$nodeA = new Node();
$nodeB = new Node();
Expand All @@ -205,13 +205,13 @@ public function testCircularReferenceArray()

$newNode = $this->autoMapper->map($nodeA, 'array');

self::assertInternalType('array', $newNode);
self::assertInternalType('array', $newNode['childs'][0]);
self::assertInternalType('array', $newNode['childs'][0]['childs'][0]);
self::assertIsArray($newNode);
self::assertIsArray($newNode['childs'][0]);
self::assertIsArray($newNode['childs'][0]['childs'][0]);
self::assertSame($newNode, $newNode['childs'][0]['childs'][0]);
}

public function testPrivate()
public function testPrivate(): void
{
$user = new PrivateUser(10, 'foo', 'bar');
/** @var PrivateUserDTO $userDto */
Expand All @@ -223,7 +223,7 @@ public function testPrivate()
self::assertSame('bar', $userDto->getLastName());
}

public function testConstructor()
public function testConstructor(): void
{
$user = new UserDTO();
$user->id = 10;
Expand All @@ -238,7 +238,7 @@ public function testConstructor()
self::assertSame(3, $userDto->getAge());
}

public function testConstructorWithDefault()
public function testConstructorWithDefault(): void
{
$user = new UserDTONoAge();
$user->id = 10;
Expand All @@ -252,7 +252,7 @@ public function testConstructorWithDefault()
self::assertSame(30, $userDto->getAge());
}

public function testConstructorDisable()
public function testConstructorDisable(): void
{
$user = new UserDTONoName();
$user->id = 10;
Expand All @@ -265,7 +265,7 @@ public function testConstructorDisable()
self::assertNull($userDto->getAge());
}

public function testMaxDepth()
public function testMaxDepth(): void
{
$foo = new FooMaxDepth(0, new FooMaxDepth(1, new FooMaxDepth(2, new FooMaxDepth(3, new FooMaxDepth(4)))));
$fooArray = $this->autoMapper->map($foo, 'array');
Expand All @@ -275,7 +275,7 @@ public function testMaxDepth()
self::assertFalse(isset($fooArray['child']['child']['child']));
}

public function testObjectToPopulate()
public function testObjectToPopulate(): void
{
$configurationUser = $this->autoMapper->getConfiguration(User::class, UserDTO::class);
$configurationUser->forMember('yearOfBirth', function (User $user) {
Expand All @@ -292,7 +292,7 @@ public function testObjectToPopulate()
self::assertSame($userDtoToPopulate, $userDto);
}

public function testCircularReferenceLimitOnContext()
public function testCircularReferenceLimitOnContext(): void
{
$nodeA = new Node();
$nodeA->parent = $nodeA;
Expand All @@ -305,7 +305,7 @@ public function testCircularReferenceLimitOnContext()
$this->autoMapper->map($nodeA, 'array', $context);
}

public function testCircularReferenceLimitOnMapper()
public function testCircularReferenceLimitOnMapper(): void
{
$nodeA = new Node();
$nodeA->parent = $nodeA;
Expand All @@ -318,7 +318,7 @@ public function testCircularReferenceLimitOnMapper()
$mapper->map($nodeA, new Context());
}

public function testCircularReferenceHandlerOnContext()
public function testCircularReferenceHandlerOnContext(): void
{
$nodeA = new Node();
$nodeA->parent = $nodeA;
Expand All @@ -333,7 +333,7 @@ public function testCircularReferenceHandlerOnContext()
self::assertSame('foo', $nodeArray['parent']);
}

public function testCircularReferenceHandlerOnMapper()
public function testCircularReferenceHandlerOnMapper(): void
{
$nodeA = new Node();
$nodeA->parent = $nodeA;
Expand All @@ -348,7 +348,7 @@ public function testCircularReferenceHandlerOnMapper()
self::assertSame('foo', $nodeArray['parent']);
}

public function testAllowedAttributes()
public function testAllowedAttributes(): void
{
$configurationUser = $this->autoMapper->getConfiguration(User::class, UserDTO::class);
$configurationUser->forMember('yearOfBirth', function (User $user) {
Expand All @@ -363,7 +363,7 @@ public function testAllowedAttributes()
self::assertNull($userDto->name);
}

public function testIgnoredAttributes()
public function testIgnoredAttributes(): void
{
$configurationUser = $this->autoMapper->getConfiguration(User::class, UserDTO::class);
$configurationUser->forMember('yearOfBirth', function (User $user) {
Expand All @@ -378,7 +378,7 @@ public function testIgnoredAttributes()
self::assertNull($userDto->name);
}

public function testNameConverter()
public function testNameConverter(): void
{
$nameConverter = new class() implements AdvancedNameConverterInterface {
public function normalize($propertyName, string $class = null, string $format = null, array $context = [])
Expand All @@ -405,12 +405,12 @@ public function denormalize($propertyName, string $class = null, string $format

$userArray = $autoMapper->map($user, 'array', new Context());

self::assertInternalType('array', $userArray);
self::assertIsArray($userArray);
self::assertArrayHasKey('@id', $userArray);
self::assertSame(1, $userArray['@id']);
}

public function testDefaultArguments()
public function testDefaultArguments(): void
{
$user = new UserDTONoAge();
$user->id = 10;
Expand All @@ -425,7 +425,7 @@ public function testDefaultArguments()
self::assertSame(50, $userDto->getAge());
}

public function testDiscriminator()
public function testDiscriminator(): void
{
$data = [
'type' => 'cat',
Expand Down
2 changes: 1 addition & 1 deletion src/AutoMapper/composer.json
Expand Up @@ -17,7 +17,7 @@
},
"require-dev": {
"doctrine/annotations": "^1.5",
"phpunit/phpunit": "^6.0",
"phpunit/phpunit": "^8.0",
"symfony/framework-bundle": "^4.4 || ^5.0",
"symfony/serializer": "^4.2 || ^5.0",
"symfony/yaml": "^4.2 || ^5.0"
Expand Down
Expand Up @@ -7,7 +7,7 @@

class UniqueVariableScopeTest extends TestCase
{
public function testUniqueVariable()
public function testUniqueVariable(): void
{
$uniqueVariableScope = new UniqueVariableScope();

Expand Down
6 changes: 3 additions & 3 deletions src/JsonSchema/Tests/JaneBaseTest.php
Expand Up @@ -14,7 +14,7 @@ class JaneBaseTest extends TestCase
/**
* @dataProvider schemaProvider
*/
public function testRessources($name, SplFileInfo $testDirectory)
public function testRessources(SplFileInfo $testDirectory): void
{
// 1. Generate
$command = new GenerateCommand();
Expand Down Expand Up @@ -54,14 +54,14 @@ public function testRessources($name, SplFileInfo $testDirectory)
}
}

public function schemaProvider()
public function schemaProvider(): array
{
$finder = new Finder();
$finder->directories()->in(__DIR__ . '/fixtures');
$finder->depth('< 1');
$data = [];
foreach ($finder as $directory) {
$data[] = [$directory->getFilename(), $directory];
$data[] = [$directory];
}

return $data;
Expand Down
4 changes: 2 additions & 2 deletions src/JsonSchema/Tests/LibraryTest.php
Expand Up @@ -18,7 +18,7 @@ class LibraryTest extends TestCase

protected $printer;

public function setUp()
public function setUp(): void
{
$this->jane = Jane::build([
'reference' => true,
Expand All @@ -32,7 +32,7 @@ public function setUp()
/**
* Unique test with ~70% coverage, library generated from json schema must be the same as the library used.
*/
public function testLibrary()
public function testLibrary(): void
{
$registry = new Registry();
$registry->addSchema(new Schema(__DIR__ . '/data/json-schema.json', 'Jane\JsonSchema', __DIR__ . '/generated', 'JsonSchema'));
Expand Down
2 changes: 1 addition & 1 deletion src/JsonSchema/composer.json
Expand Up @@ -26,7 +26,7 @@
},
"require-dev": {
"friendsofphp/php-cs-fixer": "2.15.3",
"phpunit/phpunit": "^6.0"
"phpunit/phpunit": "^8.0"
},
"suggest": {
"friendsofphp/php-cs-fixer": "Allow to automatically fix cs on generated code for better visualisation"
Expand Down
Expand Up @@ -11,12 +11,12 @@ class ReferenceNormalizerTest extends TestCase
/** @var ReferenceNormalizer */
private $referenceNormalizer;

public function setUp()
public function setUp(): void
{
$this->referenceNormalizer = new ReferenceNormalizer();
}

public function testSupports()
public function testSupports(): void
{
$this->assertFalse($this->referenceNormalizer->supportsNormalization('toto'));
$this->assertTrue($this->referenceNormalizer->supportsNormalization(new Reference('reference', 'schema')));
Expand All @@ -25,15 +25,15 @@ public function testSupports()
/**
* @dataProvider normalizeProvider
*/
public function testNormalize($referenceString)
public function testNormalize($referenceString): void
{
$reference = new Reference($referenceString, 'schema');
$normalized = $this->referenceNormalizer->normalize($reference);

$this->assertEquals($referenceString, $normalized->{'$ref'});
}

public function normalizeProvider()
public function normalizeProvider(): array
{
return [
['#pointer'],
Expand Down

0 comments on commit 21b2ea3

Please sign in to comment.