Skip to content

Commit 76b2257

Browse files
committed
Remove prophecy: migrate to native PHPUnit mocking
1 parent ae76c0e commit 76b2257

11 files changed

+203
-451
lines changed

composer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,12 @@
2727
"require-dev": {
2828
"infection/infection": "^0.29.10",
2929
"patchlevel/coding-standard": "^1.3.0",
30-
"psr/cache": "^2.0.0|^3.0.0",
31-
"psr/simple-cache": "^2.0.0|^3.0.0",
3230
"phpbench/phpbench": "^1.2.15",
33-
"phpspec/prophecy-phpunit": "^2.1.0",
3431
"phpstan/phpstan": "^2.1.0",
3532
"phpunit/phpunit": "^11.5.17",
3633
"psalm/plugin-phpunit": "^0.19.2",
34+
"psr/cache": "^2.0.0|^3.0.0",
35+
"psr/simple-cache": "^2.0.0|^3.0.0",
3736
"roave/infection-static-analysis-plugin": "^1.36.0",
3837
"symfony/var-dumper": "^5.4.29|^6.4.0|^7.0.0",
3938
"vimeo/psalm": "^6.0.0"

composer.lock

Lines changed: 1 addition & 196 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/Unit/Cryptography/CryptographySubscriberTest.php

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,12 @@
1111
use Patchlevel\Hydrator\Metadata\ClassMetadata;
1212
use PHPUnit\Framework\Attributes\CoversClass;
1313
use PHPUnit\Framework\TestCase;
14-
use Prophecy\PhpUnit\ProphecyTrait;
1514
use ReflectionClass;
1615
use stdClass;
1716

1817
#[CoversClass(CryptographySubscriber::class)]
1918
final class CryptographySubscriberTest extends TestCase
2019
{
21-
use ProphecyTrait;
22-
2320
public function testSubscriptions(): void
2421
{
2522
self::assertEquals([
@@ -39,13 +36,10 @@ public function testPreHydrate(): void
3936
$metadata,
4037
);
4138

42-
$cryptographer = $this->prophesize(PayloadCryptographer::class);
43-
$cryptographer->decrypt(
44-
$metadata,
45-
['foo' => 'bar'],
46-
)->willReturn(['foo' => 'baz'])->shouldBeCalledOnce();
39+
$cryptographer = $this->createMock(PayloadCryptographer::class);
40+
$cryptographer->expects($this->once())->method('decrypt')->with($metadata, ['foo' => 'bar'])->willReturn(['foo' => 'baz']);
4741

48-
$subscriber = new CryptographySubscriber($cryptographer->reveal());
42+
$subscriber = new CryptographySubscriber($cryptographer);
4943
$subscriber->preHydrate($event);
5044

5145
self::assertEquals(['foo' => 'baz'], $event->data);
@@ -62,13 +56,10 @@ public function testPostExtract(): void
6256
$metadata,
6357
);
6458

65-
$cryptographer = $this->prophesize(PayloadCryptographer::class);
66-
$cryptographer->encrypt(
67-
$metadata,
68-
['foo' => 'bar'],
69-
)->willReturn(['foo' => 'baz'])->shouldBeCalledOnce();
59+
$cryptographer = $this->createMock(PayloadCryptographer::class);
60+
$cryptographer->expects($this->once())->method('encrypt')->with($metadata, ['foo' => 'bar'])->willReturn(['foo' => 'baz']);
7061

71-
$subscriber = new CryptographySubscriber($cryptographer->reveal());
62+
$subscriber = new CryptographySubscriber($cryptographer);
7263
$subscriber->postExtract($event);
7364

7465
self::assertEquals(['foo' => 'baz'], $event->data);

0 commit comments

Comments
 (0)