Skip to content

Commit

Permalink
Use latest RectorConfig::configure() syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Mar 11, 2024
1 parent 0055895 commit fcb5e09
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 32 deletions.
26 changes: 12 additions & 14 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
};
4 changes: 2 additions & 2 deletions test/Factory/Collector/SessionCollectorFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
28 changes: 14 additions & 14 deletions test/ModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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();
Expand All @@ -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) {
Expand All @@ -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();

Expand All @@ -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);
Expand All @@ -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();

Expand All @@ -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()
Expand Down

0 comments on commit fcb5e09

Please sign in to comment.