From fcb5e090fc21b9b85185cff9c04968b5f5aca67c Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 11 Mar 2024 13:15:58 +0700 Subject: [PATCH] Use latest RectorConfig::configure() syntax --- rector.php | 26 ++++++++--------- .../Collector/SessionCollectorFactoryTest.php | 4 +-- .../SessionToolbarControllerFactoryTest.php | 4 +-- test/ModuleTest.php | 28 +++++++++---------- 4 files changed, 30 insertions(+), 32 deletions(-) diff --git a/rector.php b/rector.php index 3b63894..2d9b55b 100644 --- a/rector.php +++ b/rector.php @@ -5,19 +5,17 @@ use Rector\Set\ValueObject\SetList; use Rector\Set\ValueObject\LevelSetList; -return static function (RectorConfig $rectorConfig): void { - $rectorConfig->sets([ - SetList::CODE_QUALITY, - SetList::NAMING, - LevelSetList::UP_TO_PHP_73, - SetList::DEAD_CODE, - SetList::CODING_STYLE - ]); - - $rectorConfig->paths([__DIR__ . '/config', __DIR__ . '/src', __DIR__ . '/test', __DIR__ . '/rector.php']); - $rectorConfig->importNames(); - - $rectorConfig->skip([ +return RectorConfig::configure() + ->withPreparedSets( + codeQuality: true, + naming: true, + deadCode: true, + codingStyle: true + ) + ->withPhpSets(php73: true) + ->withPaths([__DIR__ . '/config', __DIR__ . '/src', __DIR__ . '/test']) + ->withRootFiles() + ->withImportNames() + ->withSkip([ CallableThisArrayToAnonymousFunctionRector::class, ]); -}; diff --git a/test/Factory/Collector/SessionCollectorFactoryTest.php b/test/Factory/Collector/SessionCollectorFactoryTest.php index a8afc53..916856d 100644 --- a/test/Factory/Collector/SessionCollectorFactoryTest.php +++ b/test/Factory/Collector/SessionCollectorFactoryTest.php @@ -53,9 +53,9 @@ protected function setUp(): void public function testInvoke() { - $sessionManager = $this->prophesize(SessionManagerInterface::class); + $objectProphecy = $this->prophesize(SessionManagerInterface::class); $this->serviceLocator->get(SessionManager::class) - ->willReturn($sessionManager) + ->willReturn($objectProphecy) ->shouldBeCalled(); $sessionCollector = $this->factory->__invoke($this->serviceLocator->reveal()); diff --git a/test/Factory/Controller/SessionToolbarControllerFactoryTest.php b/test/Factory/Controller/SessionToolbarControllerFactoryTest.php index 84a89ee..e7d95a4 100644 --- a/test/Factory/Controller/SessionToolbarControllerFactoryTest.php +++ b/test/Factory/Controller/SessionToolbarControllerFactoryTest.php @@ -54,9 +54,9 @@ protected function setUp(): void public function testInvoke() { - $mockViewRenderer = $this->prophesize(RendererInterface::class); + $objectProphecy = $this->prophesize(RendererInterface::class); $this->serviceLocator->get('ViewRenderer') - ->willReturn($mockViewRenderer) + ->willReturn($objectProphecy) ->shouldBeCalled(); $sessionManager = $this->prophesize(SessionManagerInterface::class); diff --git a/test/ModuleTest.php b/test/ModuleTest.php index e9be92d..716bc71 100644 --- a/test/ModuleTest.php +++ b/test/ModuleTest.php @@ -54,8 +54,8 @@ protected function setUp(): void */ public function testOnBootstrapOnSessionNotExists() { - $e = $this->prophesize(MvcEvent::class); - $this->assertNull($this->module->onBootstrap($e->reveal())); + $objectProphecy = $this->prophesize(MvcEvent::class); + $this->assertNull($this->module->onBootstrap($objectProphecy->reveal())); } public function provideHasMessages() @@ -72,7 +72,7 @@ public function provideHasMessages() */ public function testOnBootstrap($hasMessages) { - $e = $this->prophesize(MvcEvent::class); + $objectProphecy = $this->prophesize(MvcEvent::class); if ($hasMessages) { new Container(); @@ -91,7 +91,7 @@ public function testOnBootstrap($hasMessages) $flashMessenger = $this->prophesize(FlashMessenger::class); $pluginManager = $this->prophesize(PluginManager::class); - $sharedEvmAttach->will(static function () use ($module, $e, $hasMessages, $abstractActionController, $flashMessenger, $pluginManager) { + $sharedEvmAttach->will(static function () use ($module, $objectProphecy, $hasMessages, $abstractActionController, $flashMessenger, $pluginManager) { $abstractActionController->getPluginManager()->willReturn($pluginManager)->shouldBeCalled(); $pluginManager->has('flashMessenger')->willReturn(true)->shouldBeCalled(); if ($hasMessages) { @@ -113,10 +113,10 @@ public function testOnBootstrap($hasMessages) $abstractActionController->plugin('flashMessenger') ->willReturn($flashMessenger) ->shouldBeCalled(); - $e->getTarget() + $objectProphecy->getTarget() ->willReturn($abstractActionController) ->shouldBeCalled(); - $module->flashMessengerHandler($e->reveal()); + $module->flashMessengerHandler($objectProphecy->reveal()); }); $sharedEvmAttach->shouldBeCalled(); @@ -127,17 +127,17 @@ public function testOnBootstrap($hasMessages) ->willReturn($eventManager) ->shouldBeCalled(); - $e->getApplication() + $objectProphecy->getApplication() ->willReturn($application) ->shouldBeCalled(); } - $this->assertNull($this->module->onBootstrap($e->reveal())); + $this->assertNull($this->module->onBootstrap($objectProphecy->reveal())); } public function testOnBootstrapWithDoesntHasFlashMessenger() { - $e = $this->prophesize(MvcEvent::class); + $objectProphecy = $this->prophesize(MvcEvent::class); $application = $this->prophesize(Application::class); $eventManager = $this->prophesize(EventManager::class); @@ -152,13 +152,13 @@ public function testOnBootstrapWithDoesntHasFlashMessenger() $abstractActionController = $this->prophesize(AbstractActionController::class); $pluginManager = $this->prophesize(PluginManager::class); - $sharedEvmAttach->will(static function () use ($module, $e, $abstractActionController, $pluginManager) { + $sharedEvmAttach->will(static function () use ($module, $objectProphecy, $abstractActionController, $pluginManager) { $abstractActionController->getPluginManager()->willReturn($pluginManager)->shouldBeCalled(); $pluginManager->has('flashMessenger')->willReturn(false)->shouldBeCalled(); - $e->getTarget() + $objectProphecy->getTarget() ->willReturn($abstractActionController) ->shouldBeCalled(); - $module->flashMessengerHandler($e->reveal()); + $module->flashMessengerHandler($objectProphecy->reveal()); }); $sharedEvmAttach->shouldBeCalled(); @@ -169,11 +169,11 @@ public function testOnBootstrapWithDoesntHasFlashMessenger() ->willReturn($eventManager) ->shouldBeCalled(); - $e->getApplication() + $objectProphecy->getApplication() ->willReturn($application) ->shouldBeCalled(); - $this->module->onBootstrap($e->reveal()); + $this->module->onBootstrap($objectProphecy->reveal()); } public function testGetConfig()