From 3bb95fdcff50715457d672fda122d4fcb823a26a Mon Sep 17 00:00:00 2001 From: Maxim Babichev Date: Mon, 8 Aug 2022 18:08:44 +0300 Subject: [PATCH] DispatcherService fix --- composer.json | 5 ++++- ecs.php | 4 ++-- rector.php | 4 ++-- src/Internal/Service/DispatcherService.php | 5 +++++ tests/Units/Domain/WalletFloatTest.php | 2 +- tests/Units/Service/MathTest.php | 4 ++-- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 0902486fa..815eac633 100644 --- a/composer.json +++ b/composer.json @@ -86,6 +86,9 @@ }, "config": { "process-timeout":0, - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "infection/extension-installer": true + } } } diff --git a/ecs.php b/ecs.php index 1763eaa4c..5b30fefbf 100644 --- a/ecs.php +++ b/ecs.php @@ -6,11 +6,11 @@ use PhpCsFixer\Fixer\Phpdoc\PhpdocToCommentFixer; use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestClassRequiresCoversFixer; use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use Symplify\EasyCodingStandard\Config\ECSConfig; use Symplify\EasyCodingStandard\ValueObject\Option; use Symplify\EasyCodingStandard\ValueObject\Set\SetList; -return static function (ContainerConfigurator $containerConfigurator): void { +return static function (ECSConfig $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(ArraySyntaxFixer::class) ->call('configure', [[ diff --git a/rector.php b/rector.php index 83cb68547..7fd13c2a9 100644 --- a/rector.php +++ b/rector.php @@ -2,14 +2,14 @@ declare(strict_types=1); +use Rector\Config\RectorConfig; use Rector\Core\Configuration\Option; use Rector\Laravel\Set\LaravelSetList; use Rector\Php74\Rector\Property\TypedPropertyRector; use Rector\PHPUnit\Set\PHPUnitSetList; use Rector\Set\ValueObject\SetList; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -return static function (ContainerConfigurator $containerConfigurator): void { +return static function (RectorConfig $containerConfigurator): void { // get parameters $parameters = $containerConfigurator->parameters(); $parameters->set(Option::PATHS, [ diff --git a/src/Internal/Service/DispatcherService.php b/src/Internal/Service/DispatcherService.php index fdeb4fb96..43c9fc818 100644 --- a/src/Internal/Service/DispatcherService.php +++ b/src/Internal/Service/DispatcherService.php @@ -35,6 +35,9 @@ public function flush(): void foreach ($this->events as $event) { $this->dispatcher->flush($event); } + + $this->dispatcher->forgetPushed(); + $this->events = []; } public function forgot(): void @@ -42,6 +45,8 @@ public function forgot(): void foreach ($this->events as $event) { $this->dispatcher->forget($event); } + + $this->events = []; } /** @throws UnknownEventException */ diff --git a/tests/Units/Domain/WalletFloatTest.php b/tests/Units/Domain/WalletFloatTest.php index ea461ba0a..fd97dd366 100644 --- a/tests/Units/Domain/WalletFloatTest.php +++ b/tests/Units/Domain/WalletFloatTest.php @@ -196,7 +196,7 @@ public function testMantissa(): void self::assertSame($transaction->type, Transaction::TYPE_WITHDRAW); self::assertSame($user->balanceInt, 1_000_000 - 255672); - self::assertSame((float) $user->balanceFloat, 10000.00 - 2556.72); + self::assertSame((float) $user->balanceFloat, 7443.28); $transaction = $user->depositFloat(2556.72 * 2); self::assertSame($transaction->amountInt, 255672 * 2); diff --git a/tests/Units/Service/MathTest.php b/tests/Units/Service/MathTest.php index 451d24dd7..e273bdea3 100644 --- a/tests/Units/Service/MathTest.php +++ b/tests/Units/Service/MathTest.php @@ -143,8 +143,8 @@ public function testDiv(): void self::assertSame(-0.2, (float) $provider->div(-1, 5)); // float - self::assertSame(0.24223602484472, (float) $provider->div(1.17, 4.83)); - self::assertSame(-0.26519337016574, (float) $provider->div(-1.44, 5.43)); + self::assertSame(0.24223602484472, (float) $provider->div(1.17, 4.83, 14)); + self::assertSame(-0.26519337016574, (float) $provider->div(-1.44, 5.43, 14)); self::assertSame( 0,