Skip to content

Commit 0d9abf7

Browse files
committed
Bump phpunit
1 parent 0785aa7 commit 0d9abf7

28 files changed

+149
-227
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ composer.lock
77
composer.phar
88
.php_cs.cache
99
.php_cs
10+
.phpunit.result.cache
1011

1112
phpbench.phar
1213
phpbench.phar.pubkey

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ jobs:
3434
- php: 7.1
3535
env: SYMFONY_VERSION=3.4.*
3636
- php: 7.2
37-
env: SYMFONY_VERSION=4.0.*
37+
env: SYMFONY_VERSION=4.0.* PHPUNIT_VERSION=^7.2
3838
- php: 7.2
39-
env: SYMFONY_VERSION=4.1.*
39+
env: SYMFONY_VERSION=4.1.* PHPUNIT_VERSION=^7.2
4040
- php: 7.3
4141
env: SYMFONY_VERSION=4.2.*
4242
- php: 7.3

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
},
5151
"require-dev": {
5252
"doctrine/orm": "^2.5",
53-
"phpunit/phpunit": "^5.7.26 || ^6.0 || ^7.2",
53+
"phpunit/phpunit": "^7.2 || ^8.2",
5454
"react/promise": "^2.5",
5555
"symfony/asset": "^3.4 || ^4.0",
5656
"symfony/browser-kit": "^3.4 || ^4.0",

lib/generator/tests/Generator/TypeGeneratorModeTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313

1414
use Overblog\GraphQLGenerator\Generator\TypeGenerator;
1515
use Overblog\GraphQLGenerator\Tests\TestCase;
16+
use PHPUnit\Framework\MockObject\MockObject;
1617

1718
class TypeGeneratorModeTest extends TestCase
1819
{
1920
/** @var string */
2021
private $dir;
2122

22-
/** @var TypeGenerator|\PHPUnit_Framework_MockObject_MockObject */
23+
/** @var TypeGenerator|MockObject */
2324
private $typeGenerator;
2425

2526
private const CONFIG = [

lib/generator/tests/Generator/TypeGeneratorTest.php

+16-25
Original file line numberDiff line numberDiff line change
@@ -18,43 +18,35 @@
1818
use GraphQL\Type\Definition\ObjectType;
1919
use GraphQL\Type\Definition\StringType;
2020
use GraphQL\Type\Definition\Type;
21+
use Overblog\GraphQLGenerator\Generator\TypeGenerator;
2122

2223
class TypeGeneratorTest extends AbstractTypeGeneratorTest
2324
{
24-
/**
25-
* @expectedException \InvalidArgumentException
26-
* @expectedExceptionMessage Skeleton dir "fake" not found.
27-
*/
2825
public function testWrongSetSkeletonDirs(): void
2926
{
27+
$this->expectException(\InvalidArgumentException::class);
28+
$this->expectExceptionMessage('Skeleton dir "fake" not found.');
3029
$this->typeGenerator->setSkeletonDirs(['fake']);
3130
}
3231

33-
/**
34-
* @expectedException \InvalidArgumentException
35-
* @expectedExceptionMessage Skeleton dir must be string or object implementing __toString, "array" given.
36-
*/
3732
public function testWrongAddSkeletonDir(): void
3833
{
34+
$this->expectException(\InvalidArgumentException::class);
35+
$this->expectExceptionMessage('Skeleton dir must be string or object implementing __toString, "array" given.');
3936
$this->typeGenerator->addSkeletonDir([]);
4037
}
4138

42-
/**
43-
* @expectedException \InvalidArgumentException
44-
* @expectedExceptionMessage Skeleton dirs must be array or object implementing \Traversable interface, "object" given.
45-
*/
4639
public function testWrongObjectSetSkeletonDir(): void
4740
{
41+
$this->expectException(\InvalidArgumentException::class);
42+
$this->expectExceptionMessage('Skeleton dirs must be array or object implementing \Traversable interface, "object" given.');
4843
$this->typeGenerator->setSkeletonDirs(new \stdClass());
4944
}
5045

51-
52-
/**
53-
* @expectedException \InvalidArgumentException
54-
* @expectedExceptionMessageRegExp /Skeleton "fake" could not be found in .*\/skeleton./
55-
*/
5646
public function testWrongGetSkeletonDirs(): void
5747
{
48+
$this->expectException(\InvalidArgumentException::class);
49+
$this->expectExceptionMessageRegExp('/Skeleton "fake" could not be found in .*\/skeleton./');
5850
$this->typeGenerator->getSkeletonContent('fake');
5951
}
6052

@@ -88,12 +80,10 @@ public function testTypeAlias2String(): void
8880
);
8981
}
9082

91-
/**
92-
* @expectedException \RuntimeException
93-
* @expectedExceptionMessage Malformed ListOf wrapper type "[String" expected "]" but got "g".
94-
*/
9583
public function testTypeAlias2StringInvalidListOf(): void
9684
{
85+
$this->expectException(\RuntimeException::class);
86+
$this->expectExceptionMessage('Malformed ListOf wrapper type "[String" expected "]" but got "g".');
9787
$this->generateClasses([
9888
'T' => [
9989
'type' => 'object',
@@ -158,12 +148,13 @@ public function testCallbackEntryDoesNotTreatObject(): void
158148
$this->assertEquals(['result' => 1], $resolveFn());
159149
}
160150

161-
/**
162-
* @expectedException \RuntimeException
163-
* @expectedExceptionMessage Generator [Overblog\GraphQLGenerator\Generator\TypeGenerator::generateFake] for placeholder "fake" is not callable.
164-
*/
165151
public function testProcessInvalidPlaceHoldersReplacements(): void
166152
{
153+
$this->expectException(\RuntimeException::class);
154+
$this->expectExceptionMessage(\sprintf(
155+
'Generator [%s::generateFake] for placeholder "fake" is not callable.',
156+
TypeGenerator::class
157+
));
167158
$this->typeGenerator->setSkeletonDirs(__DIR__.'/../Resources/Skeleton');
168159

169160
$this->generateClasses($this->getConfigs());

tests/Config/Parser/TestCase.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44

55
namespace Overblog\GraphQLBundle\Tests\Config\Parser;
66

7+
use PHPUnit\Framework\MockObject\MockObject;
78
use Symfony\Bundle\FrameworkBundle\Tests\TestCase as BaseTestCase;
89
use Symfony\Component\DependencyInjection\ContainerBuilder;
910

1011
abstract class TestCase extends BaseTestCase
1112
{
12-
/** @var ContainerBuilder|\PHPUnit_Framework_MockObject_MockObject */
13+
/** @var ContainerBuilder|MockObject */
1314
protected $containerBuilder;
1415

1516
public function setUp(): void

tests/Config/Processor/InheritanceProcessorTest.php

+8-16
Original file line numberDiff line numberDiff line change
@@ -17,48 +17,40 @@ class InheritanceProcessorTest extends TestCase
1717
'tata' => ['type' => 'interface', InheritanceProcessor::HEIRS_KEY => ['foo'], 'config' => []],
1818
];
1919

20-
/**
21-
* @expectedException \InvalidArgumentException
22-
* @expectedExceptionMessage Type "toto" inherited by "bar" not found.
23-
*/
2420
public function testExtendsUnknownType(): void
2521
{
22+
$this->expectException(\InvalidArgumentException::class);
23+
$this->expectExceptionMessage('Type "toto" inherited by "bar" not found.');
2624
$configs = $this->fixtures;
2725
unset($configs['toto']);
2826

2927
InheritanceProcessor::process($configs);
3028
}
3129

32-
/**
33-
* @expectedException \InvalidArgumentException
34-
* @expectedExceptionMessage Type "foo" child of "tata" not found.
35-
*/
3630
public function testHeirsUnknownType(): void
3731
{
32+
$this->expectException(\InvalidArgumentException::class);
33+
$this->expectExceptionMessage('Type "foo" child of "tata" not found.');
3834
$configs = $this->fixtures;
3935
unset($configs['foo']);
4036

4137
InheritanceProcessor::process($configs);
4238
}
4339

44-
/**
45-
* @expectedException \InvalidArgumentException
46-
* @expectedExceptionMessage Type circular inheritance detected (foo->bar->toto->foo).
47-
*/
4840
public function testCircularExtendsType(): void
4941
{
42+
$this->expectException(\InvalidArgumentException::class);
43+
$this->expectExceptionMessage('Type circular inheritance detected (foo->bar->toto->foo).');
5044
$configs = $this->fixtures;
5145
$configs['toto'][InheritanceProcessor::INHERITS_KEY] = ['foo'];
5246

5347
InheritanceProcessor::process($configs);
5448
}
5549

56-
/**
57-
* @expectedException \InvalidArgumentException
58-
* @expectedExceptionMessage Type "bar" can't inherit "toto" because its type ("enum") is not allowed type (["object","interface"]).
59-
*/
6050
public function testNotAllowedType(): void
6151
{
52+
$this->expectException(\InvalidArgumentException::class);
53+
$this->expectExceptionMessage('Type "bar" can\'t inherit "toto" because its type ("enum") is not allowed type (["object","interface"]).');
6254
$configs = $this->fixtures;
6355
$configs['toto']['type'] = 'enum';
6456

tests/DependencyInjection/OverblogGraphQLTypesExtensionTest.php

+9-14
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use PHPUnit\Framework\TestCase;
1818
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
1919
use Symfony\Component\DependencyInjection\ContainerBuilder;
20+
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
2021
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
2122

2223
class OverblogGraphQLTypesExtensionTest extends TestCase
@@ -40,31 +41,25 @@ public function tearDown(): void
4041
unset($this->container, $this->extension);
4142
}
4243

43-
/**
44-
* @expectedException \InvalidArgumentException
45-
* @expectedExceptionMessage Configs type should never contain more than one config to deal with inheritance.
46-
*/
4744
public function testMultipleConfigNotAllowed(): void
4845
{
46+
$this->expectException(\InvalidArgumentException::class);
47+
$this->expectExceptionMessage('Configs type should never contain more than one config to deal with inheritance.');
4948
$configs = [['foo' => []], ['bar' => []]];
5049
$this->extension->load($configs, $this->container);
5150
}
5251

53-
/**
54-
* @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
55-
* @expectedExceptionMessageRegExp #The file "(.*)/broken.types.yml" does not contain valid YAML\.#
56-
*/
5752
public function testBrokenYmlOnPrepend(): void
5853
{
54+
$this->expectException(InvalidArgumentException::class);
55+
$this->expectExceptionMessageRegExp('#The file "(.*)/broken.types.yml" does not contain valid YAML\.#');
5956
$this->extension->containerPrependExtensionConfig($this->getMappingConfig('yaml'), $this->container);
6057
}
6158

62-
/**
63-
* @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
64-
* @expectedExceptionMessageRegExp #Unable to parse file "(.*)/broken.types.xml"\.#
65-
*/
6659
public function testBrokenXmlOnPrepend(): void
6760
{
61+
$this->expectException(\InvalidArgumentException::class);
62+
$this->expectExceptionMessageRegExp('#Unable to parse file "(.*)/broken.types.xml"\.#');
6863
$this->extension->containerPrependExtensionConfig($this->getMappingConfig('xml'), $this->container);
6964
}
7065

@@ -84,11 +79,11 @@ public function testPreparseOnPrepend(): void
8479
/**
8580
* @param $internalConfigKey
8681
* @dataProvider internalConfigKeys
87-
* @expectedException \InvalidArgumentException
88-
* @expectedExceptionMessage Don't use internal config keys _object_config, _enum_config, _interface_config, _union_config, _input_object_config, _custom_scalar_config, replace it by "config" instead.
8982
*/
9083
public function testInternalConfigKeysShouldNotBeUsed($internalConfigKey): void
9184
{
85+
$this->expectException(\InvalidArgumentException::class);
86+
$this->expectExceptionMessage('Don\'t use internal config keys _object_config, _enum_config, _interface_config, _union_config, _input_object_config, _custom_scalar_config, replace it by "config" instead.');
9287
$configs = [
9388
['bar' => [$internalConfigKey => []]],
9489
];

tests/Error/ErrorHandlerTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Overblog\GraphQLBundle\Error\UserErrors;
1313
use Overblog\GraphQLBundle\Error\UserWarning;
1414
use Overblog\GraphQLBundle\Event\EventDispatcherVersionHelper;
15+
use PHPUnit\Framework\MockObject\MockObject;
1516
use PHPUnit\Framework\TestCase;
1617
use Symfony\Component\EventDispatcher\EventDispatcher;
1718

@@ -20,7 +21,7 @@ class ErrorHandlerTest extends TestCase
2021
/** @var ErrorHandler */
2122
private $errorHandler;
2223

23-
/** @var EventDispatcher|\PHPUnit_Framework_MockObject_MockObject */
24+
/** @var EventDispatcher|MockObject */
2425
private $dispatcher;
2526

2627
public function setUp(): void

tests/EventListener/ErrorLoggerListenerTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Overblog\GraphQLBundle\EventListener\ErrorLoggerListener;
1212
use PHPUnit\Framework\Constraint\Constraint;
1313
use PHPUnit\Framework\MockObject\Matcher\Invocation;
14+
use PHPUnit\Framework\MockObject\MockObject;
1415
use PHPUnit\Framework\TestCase;
1516
use Psr\Log\LoggerInterface;
1617

@@ -19,7 +20,7 @@ class ErrorLoggerListenerTest extends TestCase
1920
/** @var ErrorLoggerListener */
2021
private $listener;
2122

22-
/** @var LoggerInterface|\PHPUnit_Framework_MockObject_MockObject */
23+
/** @var LoggerInterface|MockObject */
2324
private $logger;
2425

2526
public function setUp(): void

tests/Executor/ExecutorTest.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,22 @@
55
namespace Overblog\GraphQLBundle\Tests\Executor;
66

77
use GraphQL\Executor\Promise\Adapter\ReactPromiseAdapter;
8+
use GraphQL\Executor\Promise\PromiseAdapter;
89
use GraphQL\Type\Schema;
910
use Overblog\GraphQLBundle\Executor\Executor;
11+
use Overblog\GraphQLBundle\Executor\Promise\PromiseAdapterInterface;
1012
use PHPUnit\Framework\TestCase;
1113

1214
class ExecutorTest extends TestCase
1315
{
14-
/**
15-
* @expectedException \RuntimeException
16-
* @expectedExceptionMessage PromiseAdapter should be an object instantiating "Overblog\GraphQLBundle\Executor\Promise\PromiseAdapterInterface" or "GraphQL\Executor\Promise\PromiseAdapter" with a "wait" method.
17-
*/
1816
public function testInvalidExecutorAdapterPromise(): void
1917
{
18+
$this->expectException(\RuntimeException::class);
19+
$this->expectExceptionMessage(\sprintf(
20+
'PromiseAdapter should be an object instantiating "%s" or "%s" with a "wait" method.',
21+
PromiseAdapterInterface::class,
22+
PromiseAdapter::class
23+
));
2024
$schema = $this->getMockBuilder(Schema::class)->disableOriginalConstructor()->getMock();
2125
$executor = new Executor();
2226
$executor->execute(new ReactPromiseAdapter(), $schema, '');

tests/Executor/Promise/Adapter/ReactPromiseAdapterTest.php

+7-8
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,21 @@ public function setUp(): void
2121
$this->adapter = new ReactPromiseAdapter();
2222
}
2323

24-
/**
25-
* @expectedException \InvalidArgumentException
26-
* @expectedExceptionMessage The "Overblog\GraphQLBundle\Executor\Promise\Adapter\ReactPromiseAdapter::wait" method must be call with compatible a Promise.
27-
*/
2824
public function testWaitWithNotSupportedPromise(): void
2925
{
26+
$this->expectException(\InvalidArgumentException::class);
27+
$this->expectExceptionMessage(\sprintf(
28+
'The "%s::wait" method must be call with compatible a Promise.',
29+
ReactPromiseAdapter::class
30+
));
3031
$noSupportedPromise = new Promise(new \stdClass(), $this->adapter);
3132
$this->adapter->wait($noSupportedPromise);
3233
}
3334

34-
/**
35-
* @expectedException \Exception
36-
* @expectedExceptionMessage Promise has been rejected!
37-
*/
3835
public function testWaitRejectedPromise(): void
3936
{
37+
$this->expectException(\Exception::class);
38+
$this->expectExceptionMessage('Promise has been rejected!');
4039
$rejected = $this->adapter->createRejected(new \Exception('Promise has been rejected!'));
4140
$this->adapter->wait($rejected);
4241
}

tests/Functional/Command/DebugCommandTest.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Overblog\GraphQLBundle\Tests\Functional\TestCase;
99
use Symfony\Component\Console\Command\Command;
1010
use Symfony\Component\Console\Tester\CommandTester;
11-
use Symfony\Component\HttpKernel\Kernel;
1211

1312
class DebugCommandTest extends TestCase
1413
{
@@ -58,15 +57,13 @@ public function testProcess(array $categories): void
5857
$expected .= $this->logs[$category]." \n\n\n\n";
5958
}
6059

61-
$this->assertContains($expected, $this->commandTester->getDisplay(), '', \version_compare(Kernel::VERSION, '3.3.0') < 0);
60+
$this->assertStringContainsString($expected, $this->commandTester->getDisplay());
6261
}
6362

64-
/**
65-
* @expectedException \InvalidArgumentException
66-
* @expectedExceptionMessage Invalid category (fake)
67-
*/
6863
public function testInvalidFormat(): void
6964
{
65+
$this->expectException(\InvalidArgumentException::class);
66+
$this->expectExceptionMessage('Invalid category (fake)');
7067
$this->commandTester->execute([
7168
'--category' => 'fake',
7269
]);

0 commit comments

Comments
 (0)