Skip to content

Commit ebfeb4b

Browse files
authored
Merge pull request #95 from reinfi/update-phpunit
Update phpunit
2 parents 5951017 + 4099522 commit ebfeb4b

File tree

66 files changed

+1881
-1608
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1881
-1608
lines changed

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,11 @@
4646
"laminas/laminas-view": "^2.6",
4747
"laminas/laminas-serializer": "^2.6",
4848
"laminas/laminas-i18n": "^2.7",
49-
"phpunit/phpunit": "^10.0",
49+
"phpunit/phpunit": "^12.0",
5050
"doctrine/orm": "^2.5",
5151
"php-coveralls/php-coveralls": "^2.0",
5252
"symfony/yaml": "^6.0 | ^7.0",
5353
"phpstan/phpstan": "^2.0",
54-
"phpspec/prophecy-phpunit": "^2.0",
5554
"laminas/laminas-hydrator": "^4.2",
5655
"laminas/laminas-validator": "^2.14",
5756
"laminas/laminas-filter": "^2.11",

phpunit.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<?xml version="1.0"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
colors="true"
4+
processIsolation="false"
5+
stopOnFailure="false"
6+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.0/phpunit.xsd"
7+
cacheDirectory=".phpunit.cache"
8+
backupStaticProperties="false"
9+
requireCoverageMetadata="false"
10+
displayDetailsOnTestsThatTriggerDeprecations="true">
311
<coverage/>
412
<testsuites>
513
<testsuite name="unit">

test/Integration/Command/CacheWarmupCommandTest.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
use InvalidArgumentException;
88
use PHPUnit\Framework\TestCase;
9-
use Prophecy\Argument;
10-
use Prophecy\PhpUnit\ProphecyTrait;
119
use Reinfi\DependencyInjection\Annotation\Inject;
1210
use Reinfi\DependencyInjection\Annotation\InjectConfig;
1311
use Reinfi\DependencyInjection\Annotation\InjectConstant;
@@ -22,8 +20,6 @@
2220
*/
2321
class CacheWarmupCommandTest extends TestCase
2422
{
25-
use ProphecyTrait;
26-
2723
protected function setUp(): void
2824
{
2925
parent::setUp();
@@ -43,11 +39,13 @@ public function testItWarmsupCacheEntries(): void
4339
'applicationConfig' => $config,
4440
]
4541
);
46-
$output = $this->prophesize(OutputInterface::class);
47-
$output->writeln(Argument::type('string'))->shouldBeCalled();
42+
$output = $this->createMock(OutputInterface::class);
43+
$output->expects($this->atLeastOnce())
44+
->method('writeln')
45+
->with($this->isString());
4846

4947
$command = new CacheWarmupCommand();
50-
$command->run($input, $output->reveal());
48+
$command->run($input, $output);
5149
}
5250

5351
public function testItThrowsExceptionIfPathNotValid(): void
@@ -62,9 +60,9 @@ public function testItThrowsExceptionIfPathNotValid(): void
6260
'applicationConfig' => $config,
6361
]
6462
);
65-
$output = $this->prophesize(OutputInterface::class);
63+
$output = $this->createMock(OutputInterface::class);
6664

6765
$command = new CacheWarmupCommand();
68-
$command->run($input, $output->reveal());
66+
$command->run($input, $output);
6967
}
7068
}

test/Integration/Factory/AutoWiringFactoryTest.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use Laminas\ServiceManager\AbstractPluginManager;
88
use Laminas\ServiceManager\Exception\InvalidServiceException;
9-
use Prophecy\PhpUnit\ProphecyTrait;
109
use Reinfi\DependencyInjection\Factory\AutoWiringFactory;
1110
use Reinfi\DependencyInjection\Test\Base\AbstractIntegration;
1211
use Reinfi\DependencyInjection\Test\Service\PluginService;
@@ -24,8 +23,6 @@
2423
*/
2524
class AutoWiringFactoryTest extends AbstractIntegration
2625
{
27-
use ProphecyTrait;
28-
2926
public function testItCreatesServiceWithDependencies(): void
3027
{
3128
$container = $this->getServiceManager(require __DIR__ . '/../../resources/config.php');
@@ -93,17 +90,18 @@ public function testItCreatesServiceFromPluginManager(): void
9390
{
9491
$container = $this->getServiceManager(require __DIR__ . '/../../resources/config.php');
9592

96-
$pluginManager = $this->prophesize(AbstractPluginManager::class);
97-
$pluginManager->getServiceLocator()
98-
->willReturn($container)
99-
->shouldBeCalled();
100-
$pluginManager->has(Service2::class)
101-
->willReturn(false)
102-
->shouldBeCalled();
93+
$pluginManager = $this->createMock(AbstractPluginManager::class);
94+
$pluginManager->expects($this->atLeastOnce())
95+
->method('getServiceLocator')
96+
->willReturn($container);
97+
$pluginManager->expects($this->once())
98+
->method('has')
99+
->with(Service2::class)
100+
->willReturn(false);
103101

104102
$factory = new AutoWiringFactory();
105103

106-
$instance = $factory->createService($pluginManager->reveal(), PluginService::class, null);
104+
$instance = $factory->createService($pluginManager, PluginService::class, null);
107105

108106
self::assertInstanceOf(PluginService::class, $instance);
109107
}

test/Integration/Factory/InjectionFactoryTest.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Laminas\ServiceManager\AbstractPluginManager;
88
use Laminas\ServiceManager\Exception\InvalidServiceException;
99
use Laminas\Stdlib\ArrayUtils;
10-
use Prophecy\PhpUnit\ProphecyTrait;
1110
use Reinfi\DependencyInjection\Factory\InjectionFactory;
1211
use Reinfi\DependencyInjection\Service\Extractor\YamlExtractor;
1312
use Reinfi\DependencyInjection\Test\Base\AbstractIntegration;
@@ -24,8 +23,6 @@
2423
*/
2524
class InjectionFactoryTest extends AbstractIntegration
2625
{
27-
use ProphecyTrait;
28-
2926
public function testItCreatesServiceWithDependencies(): void
3027
{
3128
$container = $this->getServiceManager(require __DIR__ . '/../../resources/config.php');
@@ -84,14 +81,14 @@ public function testItCreatesServiceFromPluginManager(): void
8481
{
8582
$container = $this->getServiceManager(require __DIR__ . '/../../resources/config.php');
8683

87-
$pluginManager = $this->prophesize(AbstractPluginManager::class);
88-
$pluginManager->getServiceLocator()
89-
->willReturn($container)
90-
->shouldBeCalled();
84+
$pluginManager = $this->createMock(AbstractPluginManager::class);
85+
$pluginManager->expects($this->atLeastOnce())
86+
->method('getServiceLocator')
87+
->willReturn($container);
9188

9289
$factory = new InjectionFactory();
9390

94-
$instance = $factory->createService($pluginManager->reveal(), PluginService::class, null);
91+
$instance = $factory->createService($pluginManager, PluginService::class, null);
9592

9693
self::assertInstanceOf(PluginService::class, $instance);
9794
}

test/Unit/AbstractFactory/Config/InjectConfigAbstractFactoryTest.php

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Reinfi\DependencyInjection\Test\Unit\AbstractFactory\Config;
66

77
use PHPUnit\Framework\TestCase;
8-
use Prophecy\PhpUnit\ProphecyTrait;
98
use Psr\Container\ContainerInterface;
109
use Reinfi\DependencyInjection\AbstractFactory\Config\InjectConfigAbstractFactory;
1110
use Reinfi\DependencyInjection\Service\ConfigService;
@@ -15,16 +14,11 @@
1514
*/
1615
class InjectConfigAbstractFactoryTest extends TestCase
1716
{
18-
use ProphecyTrait;
19-
2017
public function testItCanCreateServiceWithConfigPattern(): void
2118
{
2219
$factory = new InjectConfigAbstractFactory();
2320

24-
/** @var ContainerInterface $container */
25-
$container = $this
26-
->prophesize(ContainerInterface::class)
27-
->reveal();
21+
$container = $this->createMock(ContainerInterface::class);
2822

2923
self::assertTrue(
3024
$factory->canCreate($container, 'Config.reinfi.di.test'),
@@ -36,10 +30,7 @@ public function testItCanNotCreateServiceWithNonConfigPattern(): void
3630
{
3731
$factory = new InjectConfigAbstractFactory();
3832

39-
/** @var ContainerInterface $container */
40-
$container = $this
41-
->prophesize(ContainerInterface::class)
42-
->reveal();
33+
$container = $this->createMock(ContainerInterface::class);
4334

4435
self::assertFalse(
4536
$factory->canCreate($container, 'service.reinfi.di.test'),
@@ -51,21 +42,21 @@ public function testItCallsConfigServiceForConfigPattern(): void
5142
{
5243
$factory = new InjectConfigAbstractFactory();
5344

54-
$container = $this
55-
->prophesize(ContainerInterface::class);
56-
57-
$configService = $this->prophesize(ConfigService::class);
58-
$configService->resolve('reinfi.di.test')
59-
->willReturn(true)
60-
->shouldBeCalled();
45+
$configService = $this->createMock(ConfigService::class);
46+
$configService->expects($this->once())
47+
->method('resolve')
48+
->with('reinfi.di.test')
49+
->willReturn(true);
6150

62-
$container->get(ConfigService::class)
63-
->willReturn($configService->reveal());
51+
$container = $this->createMock(ContainerInterface::class);
52+
$container->method('get')
53+
->with(ConfigService::class)
54+
->willReturn($configService);
6455

65-
$factory->canCreate($container->reveal(), 'Config.reinfi.di.test');
56+
$factory->canCreate($container, 'Config.reinfi.di.test');
6657

6758
$factory(
68-
$container->reveal(),
59+
$container,
6960
'config.reinfi.di.test',
7061
);
7162
}

test/Unit/Annotation/InjectConfigTest.php

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Laminas\Config\Config;
88
use Laminas\ServiceManager\AbstractPluginManager;
99
use PHPUnit\Framework\TestCase;
10-
use Prophecy\PhpUnit\ProphecyTrait;
1110
use Psr\Container\ContainerInterface;
1211
use Reinfi\DependencyInjection\Annotation\InjectConfig;
1312
use Reinfi\DependencyInjection\Service\ConfigService;
@@ -17,23 +16,25 @@
1716
*/
1817
class InjectConfigTest extends TestCase
1918
{
20-
use ProphecyTrait;
21-
2219
public function testItCallsConfigServiceFromContainerWithValue(): void
2320
{
2421
$inject = new InjectConfig([
2522
'value' => 'reinfi.di.test',
2623
]);
2724

28-
$configService = $this->prophesize(ConfigService::class);
29-
$configService->resolve('reinfi.di.test')
25+
$configService = $this->createMock(ConfigService::class);
26+
$configService->expects($this->once())
27+
->method('resolve')
28+
->with('reinfi.di.test')
3029
->willReturn(true);
3130

32-
$container = $this->prophesize(ContainerInterface::class);
33-
$container->get(ConfigService::class)
34-
->willReturn($configService->reveal());
31+
$container = $this->createMock(ContainerInterface::class);
32+
$container->expects($this->once())
33+
->method('get')
34+
->with(ConfigService::class)
35+
->willReturn($configService);
3536

36-
self::assertTrue($inject($container->reveal()), 'Invoke should return true');
37+
self::assertTrue($inject($container), 'Invoke should return true');
3738
}
3839

3940
public function testItCallsConfigServiceFromPluginManagerWithValue(): void
@@ -42,19 +43,24 @@ public function testItCallsConfigServiceFromPluginManagerWithValue(): void
4243
'value' => 'reinfi.di.test',
4344
]);
4445

45-
$configService = $this->prophesize(ConfigService::class);
46-
$configService->resolve('reinfi.di.test')
46+
$configService = $this->createMock(ConfigService::class);
47+
$configService->expects($this->once())
48+
->method('resolve')
49+
->with('reinfi.di.test')
4750
->willReturn(true);
4851

49-
$container = $this->prophesize(ContainerInterface::class);
50-
$container->get(ConfigService::class)
51-
->willReturn($configService->reveal());
52+
$container = $this->createMock(ContainerInterface::class);
53+
$container->expects($this->once())
54+
->method('get')
55+
->with(ConfigService::class)
56+
->willReturn($configService);
5257

53-
$pluginManager = $this->prophesize(AbstractPluginManager::class);
54-
$pluginManager->getServiceLocator()
55-
->willReturn($container->reveal());
58+
$pluginManager = $this->createMock(AbstractPluginManager::class);
59+
$pluginManager->expects($this->once())
60+
->method('getServiceLocator')
61+
->willReturn($container);
5662

57-
self::assertTrue($inject($pluginManager->reveal()), 'Invoke should return true');
63+
self::assertTrue($inject($pluginManager), 'Invoke should return true');
5864
}
5965

6066
public function testItReturnsArrayIfPropertyIsSet(): void
@@ -64,17 +70,23 @@ public function testItReturnsArrayIfPropertyIsSet(): void
6470
'asArray' => true,
6571
]);
6672

67-
$config = $this->prophesize(Config::class);
68-
$config->toArray()->shouldBeCalled()->willReturn([true]);
73+
$config = $this->createMock(Config::class);
74+
$config->expects($this->once())
75+
->method('toArray')
76+
->willReturn([true]);
6977

70-
$configService = $this->prophesize(ConfigService::class);
71-
$configService->resolve('reinfi.di.test')
72-
->willReturn($config->reveal());
78+
$configService = $this->createMock(ConfigService::class);
79+
$configService->expects($this->once())
80+
->method('resolve')
81+
->with('reinfi.di.test')
82+
->willReturn($config);
7383

74-
$container = $this->prophesize(ContainerInterface::class);
75-
$container->get(ConfigService::class)
76-
->willReturn($configService->reveal());
84+
$container = $this->createMock(ContainerInterface::class);
85+
$container->expects($this->once())
86+
->method('get')
87+
->with(ConfigService::class)
88+
->willReturn($configService);
7789

78-
self::assertEquals([true], $inject($container->reveal()), 'Invoke should return array containing true');
90+
self::assertEquals([true], $inject($container), 'Invoke should return array containing true');
7991
}
8092
}

test/Unit/Annotation/InjectConstantTest.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,22 @@
55
namespace Reinfi\DependencyInjection\Test\Unit\Annotation;
66

77
use PHPUnit\Framework\TestCase;
8-
use Prophecy\PhpUnit\ProphecyTrait;
98
use Psr\Container\ContainerInterface;
109
use Reinfi\DependencyInjection\Annotation\InjectConstant;
11-
use Reinfi\DependencyInjection\Service\InjectionService;
1210
use Reinfi\DependencyInjection\Test\Service\Service2;
1311

1412
/**
1513
* @package Reinfi\DependencyInjection\Test\Unit\Annotation
1614
*/
1715
class InjectConstantTest extends TestCase
1816
{
19-
use ProphecyTrait;
20-
2117
public function testItShouldConvertScalarTypes(): void
2218
{
2319
$injectScalar = new InjectConstant();
2420
$injectScalar->value = Service2::class . '::CONSTANT';
2521

26-
$container = $this->prophesize(ContainerInterface::class);
27-
$container->get(InjectionService::class)->willReturn(true);
22+
$container = $this->createMock(ContainerInterface::class);
2823

29-
self::assertSame(Service2::CONSTANT, $injectScalar($container->reveal()));
24+
self::assertSame(Service2::CONSTANT, $injectScalar($container));
3025
}
3126
}

test/Unit/Annotation/InjectContainerTest.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Reinfi\DependencyInjection\Test\Unit\Annotation;
66

77
use PHPUnit\Framework\TestCase;
8-
use Prophecy\PhpUnit\ProphecyTrait;
98
use Psr\Container\ContainerInterface;
109
use Reinfi\DependencyInjection\Annotation\InjectContainer;
1110

@@ -14,18 +13,12 @@
1413
*/
1514
class InjectContainerTest extends TestCase
1615
{
17-
use ProphecyTrait;
18-
1916
public function testItCallsContainerWithValue(): void
2017
{
2118
$inject = new InjectContainer();
2219

23-
$container = $this->prophesize(ContainerInterface::class);
20+
$container = $this->createMock(ContainerInterface::class);
2421

25-
self::assertEquals(
26-
$container->reveal(),
27-
$inject($container->reveal()),
28-
'Invoke should return provided container'
29-
);
22+
self::assertEquals($container, $inject($container), 'Invoke should return provided container');
3023
}
3124
}

0 commit comments

Comments
 (0)