diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 82830dad6..568a3840d 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -27,38 +27,26 @@ HEADER; $rules = [ - '@PHP70Migration' => true, - '@PHP70Migration:risky' => true, - '@PHP71Migration' => true, - '@PHP71Migration:risky' => true, - '@PHPUnit57Migration:risky' => true, - '@PHPUnit60Migration:risky' => true, + '@PHP74Migration' => true, + '@PHP74Migration:risky' => true, + '@PSR12' => true, + '@PSR12:risky' => true, '@Symfony' => true, '@Symfony:risky' => true, - 'array_syntax' => ['syntax' => 'short'], 'combine_consecutive_issets' => true, 'combine_consecutive_unsets' => true, - 'compact_nullable_typehint' => true, 'global_namespace_import' => ['import_classes' => false, 'import_constants' => false, 'import_functions' => false], 'header_comment' => ['header' => $header], 'list_syntax' => ['syntax' => 'short'], - 'logical_operators' => true, 'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'], 'multiline_whitespace_before_semicolons' => ['strategy' => 'no_multi_line'], - 'no_extra_blank_lines' => true, - 'no_php4_constructor' => true, - 'no_superfluous_phpdoc_tags' => ['allow_mixed' => true], 'no_useless_else' => true, 'no_useless_return' => true, 'nullable_type_declaration_for_default_null_value' => ['use_nullable_type_declaration' => true], 'ordered_class_elements' => true, 'ordered_imports' => ['sort_algorithm' => 'alpha', 'imports_order' => ['class', 'function', 'const']], - 'php_unit_method_casing' => false, - 'php_unit_set_up_tear_down_visibility' => true, 'php_unit_strict' => true, - 'php_unit_test_annotation' => false, 'php_unit_test_case_static_method_calls' => true, - 'phpdoc_order' => true, 'phpdoc_to_comment' => ['ignored_tags' => ['psalm-suppress']], 'single_line_throw' => false, 'static_lambda' => true, diff --git a/src/Admin/Extension/CreateSnapshotAdminExtension.php b/src/Admin/Extension/CreateSnapshotAdminExtension.php index 10b35f4d4..9e0fa55c4 100644 --- a/src/Admin/Extension/CreateSnapshotAdminExtension.php +++ b/src/Admin/Extension/CreateSnapshotAdminExtension.php @@ -34,7 +34,7 @@ class CreateSnapshotAdminExtension extends AbstractAdminExtension */ protected $backend; - //NEXT_MAJOR: restrict type to CreateSnapshotByPageInterface + // NEXT_MAJOR: restrict type to CreateSnapshotByPageInterface public function __construct($backend) { $this->backend = $backend; @@ -65,15 +65,15 @@ protected function sendMessage($object) { if ($object instanceof BlockInterface && method_exists($object, 'getPage')) { $page = $object->getPage(); - $pageId = $page->getId(); //NEXT_MAJOR: Remove this line. + $pageId = $page->getId(); // NEXT_MAJOR: Remove this line. } elseif ($object instanceof PageInterface) { $page = $object; - $pageId = $page->getId(); //NEXT_MAJOR: Remove this line. + $pageId = $page->getId(); // NEXT_MAJOR: Remove this line. } else { return; } - //NEXT_MAJOR: Remove the if code and all code related with BackendInterface + // NEXT_MAJOR: Remove the if code and all code related with BackendInterface if ($this->backend instanceof BackendInterface) { @trigger_error( sprintf( diff --git a/src/Block/BreadcrumbBlockService.php b/src/Block/BreadcrumbBlockService.php index 3f35b3e27..db50eb2e5 100644 --- a/src/Block/BreadcrumbBlockService.php +++ b/src/Block/BreadcrumbBlockService.php @@ -55,7 +55,7 @@ public function getName() public function getBlockMetadata($code = null) { - return new Metadata($this->getName(), ($code ?? $this->getName()), false, 'SonataPageBundle', [ + return new Metadata($this->getName(), $code ?? $this->getName(), false, 'SonataPageBundle', [ 'class' => 'fa fa-bars', ]); } diff --git a/src/Block/ContainerBlockService.php b/src/Block/ContainerBlockService.php index fb03fc5b9..436e899b9 100644 --- a/src/Block/ContainerBlockService.php +++ b/src/Block/ContainerBlockService.php @@ -43,7 +43,7 @@ public function configureSettings(OptionsResolver $resolver) public function getBlockMetadata($code = null) { - return new Metadata($this->getName(), ($code ?? $this->getName()), false, 'SonataPageBundle', [ + return new Metadata($this->getName(), $code ?? $this->getName(), false, 'SonataPageBundle', [ 'class' => 'fa fa-square-o', ]); } diff --git a/src/Block/PageListBlockService.php b/src/Block/PageListBlockService.php index 9c4d78d75..40d613472 100755 --- a/src/Block/PageListBlockService.php +++ b/src/Block/PageListBlockService.php @@ -113,7 +113,7 @@ public function configureSettings(OptionsResolver $resolver) public function getBlockMetadata($code = null) { - return new Metadata($this->getName(), ($code ?? $this->getName()), false, 'SonataPageBundle', [ + return new Metadata($this->getName(), $code ?? $this->getName(), false, 'SonataPageBundle', [ 'class' => 'fa fa-home', ]); } diff --git a/src/CmsManager/DecoratorStrategy.php b/src/CmsManager/DecoratorStrategy.php index e09fa6a34..73a6db8e6 100644 --- a/src/CmsManager/DecoratorStrategy.php +++ b/src/CmsManager/DecoratorStrategy.php @@ -55,7 +55,7 @@ public function isDecorable(Request $request, $requestType, Response $response) return false; } - if ('text/html' !== (substr($response->headers->get('Content-Type') ?: 'text/html', 0, 9))) { + if ('text/html' !== substr($response->headers->get('Content-Type') ?: 'text/html', 0, 9)) { return false; } diff --git a/src/Command/CleanupSnapshotsCommand.php b/src/Command/CleanupSnapshotsCommand.php index d2987b6e9..fb4f72a87 100644 --- a/src/Command/CleanupSnapshotsCommand.php +++ b/src/Command/CleanupSnapshotsCommand.php @@ -32,16 +32,16 @@ public function configure() $this->setDescription('Cleanups the deprecated snapshots by a given site'); $this->addOption('site', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Site id'); - //NEXT_MAJOR: Remove the "base-console" option. + // NEXT_MAJOR: Remove the "base-console" option. $this->addOption('base-console', null, InputOption::VALUE_OPTIONAL, 'Base Symfony console command', 'app/console'); - //NEXT_MAJOR: Remove the "mode" option. + // NEXT_MAJOR: Remove the "mode" option. $this->addOption('mode', null, InputOption::VALUE_OPTIONAL, 'Run the command asynchronously', 'sync'); $this->addOption('keep-snapshots', null, InputOption::VALUE_OPTIONAL, 'Keep a given count of snapshots per page', 5); } protected function initialize(InputInterface $input, OutputInterface $output) { - //NEXT_MAJOR: Remove this condition. + // NEXT_MAJOR: Remove this condition. if ('app/console' !== $input->getOption('base-console')) { @trigger_error( 'The "base-console" is deprecated since sonata-project/page-bundle 3.27.0 and will be removed in 4.0', @@ -49,7 +49,7 @@ protected function initialize(InputInterface $input, OutputInterface $output) ); } - //NEXT_MAJOR: Remove this condition. + // NEXT_MAJOR: Remove this condition. if (!\in_array($input->getOption('mode'), ['async', 'sync'], true)) { throw new \InvalidArgumentException('Option "mode" is not valid (async|sync).'); } @@ -66,14 +66,14 @@ protected function execute(InputInterface $input, OutputInterface $output) $siteOption = $input->getOption('site'); $keepSnapshots = $input->getOption('keep-snapshots'); - //NEXT_MAJOR: Remove this condition, because site will be optional. + // NEXT_MAJOR: Remove this condition, because site will be optional. if ([] === $siteOption) { $output->writeln('Please provide an --site=SITE_ID option or the --site=all directive'); return 1; } - //NEXT_MAJOR: Remove this block condition. + // NEXT_MAJOR: Remove this block condition. if (['all'] === $siteOption) { @trigger_error( sprintf( @@ -88,7 +88,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } foreach ($this->getSites($siteOption) as $site) { - //NEXT_MAJOR: Remove this "async" block condition. + // NEXT_MAJOR: Remove this "async" block condition. if ('async' === $input->getOption('mode')) { @trigger_error( 'The async mode is deprecated since sonata-project/page-bundle 3.27.0 and will be removed in 4.0', @@ -108,7 +108,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->write(sprintf('%s - Cleaning up snapshots ...', $site->getName())); - //NEXT_MAJOR: inject this class in the constructor CleanupSnapshotBySiteInterface $cleanupSnapshot + // NEXT_MAJOR: inject this class in the constructor CleanupSnapshotBySiteInterface $cleanupSnapshot $cleanupSnapshot = $this->getContainer()->get('sonata.page.service.cleanup_snapshot'); $cleanupSnapshot->cleanupBySite($site, $keepSnapshots); @@ -129,7 +129,7 @@ protected function execute(InputInterface $input, OutputInterface $output) */ protected function getSites($ids): array { - //NEXT_MAJOR: Inject this on the __construct. + // NEXT_MAJOR: Inject this on the __construct. $siteManager = $this->getContainer()->get('sonata.page.manager.site'); if ([] === $ids) { diff --git a/src/Command/CloneSiteCommand.php b/src/Command/CloneSiteCommand.php index 42ebfe0ee..85363e564 100644 --- a/src/Command/CloneSiteCommand.php +++ b/src/Command/CloneSiteCommand.php @@ -136,7 +136,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } } - //NEXT_MAJOR: Remove this target condition block. + // NEXT_MAJOR: Remove this target condition block. if ($page->getTarget()) { @trigger_error( 'target page is deprecate since sonata-project/page-bundle 3.27.0'. diff --git a/src/Command/CreateSiteCommand.php b/src/Command/CreateSiteCommand.php index dd03273d3..c808644b5 100644 --- a/src/Command/CreateSiteCommand.php +++ b/src/Command/CreateSiteCommand.php @@ -49,9 +49,9 @@ public function configure() $this->setHelp( <<<'EOT' -The sonata:page:create-site command create a new site entity. + The sonata:page:create-site command create a new site entity. -EOT + EOT ); } @@ -100,12 +100,12 @@ public function execute(InputInterface $input, OutputInterface $output) $output->writeln( <<name : {$site->getName()} - site : http(s)://{$site->getHost()}{$site->getRelativePath()} - enabled : from {$info_enabledFrom} => to {$info_enabledTo} + Creating website with the following information : + name : {$site->getName()} + site : http(s)://{$site->getHost()}{$site->getRelativePath()} + enabled : from {$info_enabledFrom} => to {$info_enabledTo} -INFO + INFO ); $confirmation = true; diff --git a/src/Command/CreateSnapshotsCommand.php b/src/Command/CreateSnapshotsCommand.php index ba7c5a0f4..ebc6b86a0 100644 --- a/src/Command/CreateSnapshotsCommand.php +++ b/src/Command/CreateSnapshotsCommand.php @@ -42,7 +42,7 @@ class CreateSnapshotsCommand extends BaseCommand */ public function __construct($createSnapshot = null) { - //NEXT_MAJOR: Remove the "if" condition and let only the "else" code. + // NEXT_MAJOR: Remove the "if" condition and let only the "else" code. if (\is_string($createSnapshot) || null === $createSnapshot) { @trigger_error(sprintf( 'The %s class is final since sonata-project/page-bundle 3.27.0 and and it will be removed in 4.0' @@ -60,9 +60,9 @@ public function configure() { $this->setDescription('Create a snapshots of all pages available'); $this->addOption('site', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Site id'); - //NEXT_MAJOR: Remove the "base-console" option. + // NEXT_MAJOR: Remove the "base-console" option. $this->addOption('base-console', null, InputOption::VALUE_OPTIONAL, 'Base symfony console command', 'php app/console'); - //NEXT_MAJOR: Remove the "mode" option. + // NEXT_MAJOR: Remove the "mode" option. $this->addOption('mode', null, InputOption::VALUE_OPTIONAL, 'Run the command asynchronously', 'sync'); } @@ -70,7 +70,7 @@ public function execute(InputInterface $input, OutputInterface $output) { $siteOption = $input->getOption('site'); - //NEXT_MAJOR: Remove this condition. + // NEXT_MAJOR: Remove this condition. if ('php app/console' !== $input->getOption('base-console')) { @trigger_error( 'The "base-console" is deprecated since sonata-project/page-bundle 3.27.0 and will be removed in 4.0', @@ -78,14 +78,14 @@ public function execute(InputInterface $input, OutputInterface $output) ); } - //NEXT_MAJOR: Remove this condition, because site will be optional + // NEXT_MAJOR: Remove this condition, because site will be optional if ([] === $siteOption) { $output->writeln('Please provide an --site=SITE_ID option or the --site=all directive'); return 1; } - //NEXT_MAJOR: Remove this block condition. + // NEXT_MAJOR: Remove this block condition. if (['all'] === $siteOption) { @trigger_error( sprintf( @@ -138,7 +138,7 @@ public function execute(InputInterface $input, OutputInterface $output) */ protected function getSites($ids): array { - //NEXT_MAJOR: Inject this on the __construct. + // NEXT_MAJOR: Inject this on the __construct. $siteManager = $this->getContainer()->get('sonata.page.manager.site'); if ([] === $ids) { diff --git a/src/Command/DumpPageCommand.php b/src/Command/DumpPageCommand.php index efd623372..b57987de6 100644 --- a/src/Command/DumpPageCommand.php +++ b/src/Command/DumpPageCommand.php @@ -37,14 +37,14 @@ public function configure() $this->setDescription('Dump page information'); $this->setHelp( <<addArgument('manager', InputArgument::REQUIRED, 'The manager service id'); diff --git a/src/Command/RenderBlockCommand.php b/src/Command/RenderBlockCommand.php index 6901b6206..fc90d9a5f 100644 --- a/src/Command/RenderBlockCommand.php +++ b/src/Command/RenderBlockCommand.php @@ -36,12 +36,12 @@ public function configure() $this->setDescription('Dump page information'); $this->setHelp( <<addArgument('manager', InputArgument::REQUIRED, 'The manager service id'); diff --git a/src/Command/UpdateCoreRoutesCommand.php b/src/Command/UpdateCoreRoutesCommand.php index dc2f1f81a..3511f61f2 100644 --- a/src/Command/UpdateCoreRoutesCommand.php +++ b/src/Command/UpdateCoreRoutesCommand.php @@ -51,14 +51,14 @@ public function execute(InputInterface $input, OutputInterface $output) $siteOption = $input->getOption('site'); - //NEXT_MAJOR: Remove this condition, because site will be optional + // NEXT_MAJOR: Remove this condition, because site will be optional if ([] === $siteOption) { $output->writeln('Please provide an --site=SITE_ID option or the --site=all directive'); return 1; } - //NEXT_MAJOR: Remove this block condition. + // NEXT_MAJOR: Remove this block condition. if (['all'] === $siteOption) { @trigger_error( sprintf( @@ -108,7 +108,7 @@ public function execute(InputInterface $input, OutputInterface $output) */ protected function getSites($ids): array { - //NEXT_MAJOR: Inject this on the __construct. + // NEXT_MAJOR: Inject this on the __construct. $siteManager = $this->getContainer()->get('sonata.page.manager.site'); if ([] === $ids) { diff --git a/src/Controller/PageAdminController.php b/src/Controller/PageAdminController.php index a32439de5..4b4b588cc 100644 --- a/src/Controller/PageAdminController.php +++ b/src/Controller/PageAdminController.php @@ -46,12 +46,12 @@ public function batchActionSnapshot($query) } foreach ($query->execute() as $page) { - //NEXT_MAJOR: Remove the $notificationBackend variable + // NEXT_MAJOR: Remove the $notificationBackend variable $notificationBackend = $this->get('sonata.notification.backend'); - //NEXT_MAJOR: Remove the "if" condition and use only "createByPage" + // NEXT_MAJOR: Remove the "if" condition and use only "createByPage" if ($notificationBackend instanceof RuntimeBackend) { - //NEXT_MAJOR: Inject CreateSnapshotByPageInterface type and remove this "get" call. + // NEXT_MAJOR: Inject CreateSnapshotByPageInterface type and remove this "get" call. $this->get('sonata.page.service.create_snapshot')->createByPage($page); } else { @trigger_error( diff --git a/src/Controller/SiteAdminController.php b/src/Controller/SiteAdminController.php index 2e6f8c517..5afaadfef 100644 --- a/src/Controller/SiteAdminController.php +++ b/src/Controller/SiteAdminController.php @@ -53,12 +53,11 @@ public function snapshotsAction() $this->admin->setSubject($object); if ('POST' === $request->getMethod()) { - - //NEXT_MAJOR: remove notificationBackend and else block. + // NEXT_MAJOR: remove notificationBackend and else block. $notificationBacked = $this->get('sonata.notification.backend'); if ($notificationBacked instanceof RuntimeBackend) { - //NEXT_MAJOR: inject CreateSnapshotBySiteInterface and remove this get. + // NEXT_MAJOR: inject CreateSnapshotBySiteInterface and remove this get. $createSnapshot = $this->get('sonata.page.service.create_snapshot'); $createSnapshot->createBySite($object); } else { diff --git a/src/Controller/SnapshotAdminController.php b/src/Controller/SnapshotAdminController.php index 555cc6fc8..e3e80dfbf 100644 --- a/src/Controller/SnapshotAdminController.php +++ b/src/Controller/SnapshotAdminController.php @@ -54,7 +54,7 @@ public function createAction(?Request $request = null) $form->submit($request->request->get($form->getName())); if ($form->isValid()) { - //@NEXT_MAJOR: when you're going to inject this service use CreateSnapshotByPageInterface + // @NEXT_MAJOR: when you're going to inject this service use CreateSnapshotByPageInterface $createSnapshot = $this->get('sonata.page.service.create_snapshot'); $snapshot = $createSnapshot->createByPage($page); diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index f508c2936..db45d3232 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -40,40 +40,40 @@ public function getConfigTreeBuilder() $node = $node->children(); $routerAutoRegisterInfo = <<<'EOF' -Automatically add 'sonata.page.router' service to the index of 'cmf_routing.router' chain router + Automatically add 'sonata.page.router' service to the index of 'cmf_routing.router' chain router -Examples: -enabled: true Enable auto-registration -priority: 150 The priority -EOF; + Examples: + enabled: true Enable auto-registration + priority: 150 The priority + EOF; $ignoreRoutePatternsInfo = <<<'EOF' -(.*)admin(.*) ignore admin route, i.e. route containing 'admin' -^_(.*) ignore Symfony routes -EOF; + (.*)admin(.*) ignore admin route, i.e. route containing 'admin' + ^_(.*) ignore Symfony routes + EOF; $ignoreUriPatternsInfo = <<<'EOF' -admin(.*) ignore admin route, i.e. route containing 'admin' -EOF; + admin(.*) ignore admin route, i.e. route containing 'admin' + EOF; $pageDefaultsInfo = <<<'EOF' -Example: -homepage: { decorate: false } disable decoration for 'homepage', key is a page route -EOF; + Example: + homepage: { decorate: false } disable decoration for 'homepage', key is a page route + EOF; $catchExceptionsInfo = <<<'EOF' -Manage the HTTP errors + Manage the HTTP errors -Examples: -not_found: [404] render 404 page with "not_found" key (name generated: _page_internal_error_not_found) -fatal: [500] render 500 page with "fatal" key (name generated: _page_internal_error_fatal) -EOF; + Examples: + not_found: [404] render 404 page with "not_found" key (name generated: _page_internal_error_not_found) + fatal: [500] render 500 page with "fatal" key (name generated: _page_internal_error_fatal) + EOF; $directPublicationInfo = <<<'EOF' -Generates a snapshot when a page is saved from the admin. + Generates a snapshot when a page is saved from the admin. -You can use %kernel.debug%, if you want to publish in dev mode, but not in prod. -EOF; + You can use %kernel.debug%, if you want to publish in dev mode, but not in prod. + EOF; $node ->scalarNode('skip_redirection') @@ -240,9 +240,7 @@ public function getConfigTreeBuilder() ->end() ->validate() ->always() - ->then(static function ($matrix) { - return Parser::parse($matrix['layout'], $matrix['mapping']); - }) + ->then(static fn ($matrix) => Parser::parse($matrix['layout'], $matrix['mapping'])) ->end() ->end() ->end() diff --git a/src/DependencyInjection/SonataPageExtension.php b/src/DependencyInjection/SonataPageExtension.php index b492ce839..d2fb0bf99 100644 --- a/src/DependencyInjection/SonataPageExtension.php +++ b/src/DependencyInjection/SonataPageExtension.php @@ -92,7 +92,7 @@ public function load(array $configs, ContainerBuilder $container) $loader->load('form.xml'); $loader->load('twig.xml'); $loader->load('http_kernel.xml'); - //@NEXT_MAJOR: Remove this load, and consumer.xml file + // @NEXT_MAJOR: Remove this load, and consumer.xml file $loader->load('consumer.xml'); $loader->load('service.xml'); $loader->load('validators.xml'); diff --git a/src/Entity/Transformer.php b/src/Entity/Transformer.php index c144f3c16..b69b661cc 100644 --- a/src/Entity/Transformer.php +++ b/src/Entity/Transformer.php @@ -89,7 +89,7 @@ public function create(PageInterface $page) $snapshot->setParentId($page->getParent()->getId()); } - //NEXT_MAJOR: Remove this "if" condition block. + // NEXT_MAJOR: Remove this "if" condition block. if ($page->getTarget()) { @trigger_error( 'target page is deprecate since sonata-project/page-bundle 3.27.0'. @@ -114,7 +114,7 @@ public function create(PageInterface $page) $content['updated_at'] = $page->getUpdatedAt()->format('U'); $content['slug'] = $page->getSlug(); $content['parent_id'] = $page->getParent() ? $page->getParent()->getId() : null; - $content['target_id'] = $page->getTarget() ? $page->getTarget()->getId() : null; //NEXT_MAJOR: Remove this line. + $content['target_id'] = $page->getTarget() ? $page->getTarget()->getId() : null; // NEXT_MAJOR: Remove this line. $content['blocks'] = []; foreach ($page->getBlocks() as $block) { diff --git a/src/Route/RoutePageGenerator.php b/src/Route/RoutePageGenerator.php index 96ca337c9..c7dd2497f 100644 --- a/src/Route/RoutePageGenerator.php +++ b/src/Route/RoutePageGenerator.php @@ -224,11 +224,11 @@ public function update(SiteInterface $site, ?OutputInterface $output = null, $cl $this->writeln( $output, <<<'MSG' - - *WARNING* : Pages has been updated however some pages do not exist anymore. - You must remove them manually. - -MSG + + *WARNING* : Pages has been updated however some pages do not exist anymore. + You must remove them manually. + + MSG ); } } diff --git a/tests/Cache/BlockJsCacheTest.php b/tests/Cache/BlockJsCacheTest.php index 6a19bc74b..dbc2bd5e2 100644 --- a/tests/Cache/BlockJsCacheTest.php +++ b/tests/Cache/BlockJsCacheTest.php @@ -89,22 +89,22 @@ public function testInitCache(): void static::assertInstanceOf(CacheElement::class, $cacheElement); $expected = <<<'EXPECTED' -
- -
-EXPECTED; +
+ +
+ EXPECTED; static::assertSame($expected, $cacheElement->getData()->getContent()); } diff --git a/tests/Command/CleanupSnapshotsCommandTest.php b/tests/Command/CleanupSnapshotsCommandTest.php index b61e66ee0..781050841 100644 --- a/tests/Command/CleanupSnapshotsCommandTest.php +++ b/tests/Command/CleanupSnapshotsCommandTest.php @@ -41,7 +41,7 @@ protected function setUp(): void public function testRequireSiteOption(): void { - //Command + // Command $command = $this->application->find('sonata:page:cleanup-snapshots'); $commandTester = new CommandTester($command); @@ -62,15 +62,15 @@ public function testRequireSiteOption(): void */ public function testInvalidSiteModeValue(): void { - //Assert + // Assert static::expectException(\InvalidArgumentException::class); static::expectExceptionMessage('Option "mode" is not valid (async|sync).'); - //Setup command + // Setup command $command = $this->application->find('sonata:page:cleanup-snapshots'); $commandTester = new CommandTester($command); - //Run code + // Run code $commandTester->execute([ 'command' => $command->getName(), '--site' => [1], @@ -83,30 +83,31 @@ public function testInvalidSiteModeValue(): void */ public function testKeepSnapshotIsANumberValue(): void { - //Assert + // Assert static::expectException(\InvalidArgumentException::class); static::expectExceptionMessage('Please provide an integer value for the option "keep-snapshots".'); - //Setup command + // Setup command $command = $this->application->find('sonata:page:cleanup-snapshots'); $commandTester = new CommandTester($command); - //Run code + // Run code $commandTester->execute([ 'command' => $command->getName(), '--site' => [1], - '--mode' => 'sync', //NEXT_MAJOR: Remove this argument. + '--mode' => 'sync', // NEXT_MAJOR: Remove this argument. '--keep-snapshots' => '5a', ]); } /** - * @test it's cleanup for all sites using notification bundle. + * it's cleanup for all sites using notification bundle. + * * @group legacy */ public function testCleanupSnapshotAsync(): void { - //Mock + // Mock $siteManagerMock = $this->createMock(SiteManagerInterface::class); $siteManagerMock ->method('findAll') @@ -120,15 +121,15 @@ public function testCleanupSnapshotAsync(): void ->method('createAndPublish'); self::$container->set('sonata.notification.backend', $notificationBackend); - //Setup command + // Setup command $command = $this->application->find('sonata:page:cleanup-snapshots'); $commandTester = new CommandTester($command); - //Run code + // Run code $commandTester->execute([ 'command' => $command->getName(), - '--mode' => 'async', //NEXT_MAJOR: Remove this option. - '--site' => ['all'], //NEXT_MAJOR: Remove this option. + '--mode' => 'async', // NEXT_MAJOR: Remove this option. + '--site' => ['all'], // NEXT_MAJOR: Remove this option. ]); $output = $commandTester->getDisplay(); @@ -142,7 +143,7 @@ public function testCleanupSnapshotAsync(): void */ public function testCleanupSnapshot(): void { - //Mock + // Mock $siteManagerMock = $this->createMock(SiteManagerInterface::class); $siteManagerMock ->method('findAll') @@ -157,14 +158,14 @@ public function testCleanupSnapshot(): void self::$container->set('sonata.page.service.cleanup_snapshot', $cleanupSnapshotMock); - //Setup command + // Setup command $command = $this->application->find('sonata:page:cleanup-snapshots'); $commandTester = new CommandTester($command); - //Run code + // Run code $commandTester->execute([ 'command' => $command->getName(), - '--site' => ['all'], //NEXT_MAJOR: Remove this option. + '--site' => ['all'], // NEXT_MAJOR: Remove this option. ]); $output = $commandTester->getDisplay(); diff --git a/tests/Command/CreateSnapshotsCommandTest.php b/tests/Command/CreateSnapshotsCommandTest.php index 14d421394..5fbe83e07 100644 --- a/tests/Command/CreateSnapshotsCommandTest.php +++ b/tests/Command/CreateSnapshotsCommandTest.php @@ -38,7 +38,7 @@ final class CreateSnapshotsCommandTest extends KernelTestCase protected function setUp(): void { parent::setUp(); - //Mocks + // Mocks $siteMock = $this->createMock(SiteInterface::class); $siteMock ->method('getId') @@ -72,17 +72,17 @@ protected function setUp(): void */ public function testCreateOneSnapshotAsync(): void { - //Mock + // Mock $backendMock = $this->createMock(BackendInterface::class); $backendMock ->expects(static::once()) ->method('createAndPublish'); - //Set mock services + // Set mock services self::$container->set('sonata.page.manager.site', $this->siteManagerMock); self::$container->set('sonata.notification.backend', $backendMock); - //Command + // Command $command = $this->application->find('sonata:page:create-snapshots'); $commandTester = new CommandTester($command); @@ -99,7 +99,7 @@ public function testCreateOneSnapshotAsync(): void public function testCreateSnapshot() { - //Mocks + // Mocks $createSnapshotsMock = $this->createMock(CreateSnapshotBySiteInterface::class); $createSnapshotsMock ->expects(static::once()) @@ -117,12 +117,12 @@ public function testCreateSnapshot() $inputMock = $this->createMock(InputInterface::class); $inputMock ->method('getOption') - //NEXT_MAJOR: Change to ->willReturnOnConsecutiveCalls(['all'], 'sync') + // NEXT_MAJOR: Change to ->willReturnOnConsecutiveCalls(['all'], 'sync') ->willReturnOnConsecutiveCalls('php app/console', ['all'], 'sync'); $outputMock = $this->createMock(OutputInterface::class); - //Run code + // Run code $createSnapshotCommandMock->execute($inputMock, $outputMock); } @@ -163,7 +163,7 @@ public function testCallNotificationBackend( $inputMock = $this->createMock(InputInterface::class); $inputMock ->method('getOption') - //NEXT_MAJOR: Change to ->willReturnOnConsecutiveCalls(['all'], $mode) + // NEXT_MAJOR: Change to ->willReturnOnConsecutiveCalls(['all'], $mode) ->willReturnOnConsecutiveCalls('php app/console', ['all'], $mode); $outputMock = $this->createMock(OutputInterface::class); diff --git a/tests/Controller/PageAdminControllerTest.php b/tests/Controller/PageAdminControllerTest.php index 079e99897..6074dc312 100644 --- a/tests/Controller/PageAdminControllerTest.php +++ b/tests/Controller/PageAdminControllerTest.php @@ -89,7 +89,7 @@ public function testCallTheNotificationCreateSnapshot(): void ->method('execute') ->willReturn([$pageMock]); - //Run code + // Run code $this->controller->batchActionSnapshot($queryMock); } @@ -100,7 +100,7 @@ public function testCreateSnapshotByPage(): void $this->admin->method('generateUrl')->willReturn('https://fake.bar'); - //NEXT_MAJOR: Remove the RuntimeBackend mock + // NEXT_MAJOR: Remove the RuntimeBackend mock $backend = $this->createMock(RuntimeBackend::class); $backend ->expects(static::exactly(0)) @@ -120,7 +120,7 @@ public function testCreateSnapshotByPage(): void ->method('execute') ->willReturn([$pageMock]); - //Run code + // Run code $this->controller->batchActionSnapshot($queryMock); } diff --git a/tests/Entity/BlockInteractorTest.php b/tests/Entity/BlockInteractorTest.php index 998499f5f..f33e0381e 100644 --- a/tests/Entity/BlockInteractorTest.php +++ b/tests/Entity/BlockInteractorTest.php @@ -28,12 +28,12 @@ final class BlockInteractorTest extends TestCase */ public function testLoadPageBlocks(): void { - //Mock + // Mock $managerRegistryMock = $this->createMock(ManagerRegistry::class); $blockManagerInterfaceMock = $this->createMock(BlockManagerInterface::class); - //NEXT_MAJOR: use PageInterface + // NEXT_MAJOR: use PageInterface $pageMock = $this->createMock(Page::class); - //NEXT_MAJOR: use BlockInterface + // NEXT_MAJOR: use BlockInterface $blockMock = $this->createMock(Block::class); $blockInteractorMock = $this @@ -47,10 +47,10 @@ public function testLoadPageBlocks(): void ->method('getBlocksById') ->willReturn([$blockMock]); - //Run + // Run $blocks = $blockInteractorMock->loadPageBlocks($pageMock); - //Asserts + // Asserts static::assertSame([$blockMock], $blocks); } @@ -59,7 +59,7 @@ public function testLoadPageBlocks(): void */ public function testNotLoadBlocks(): void { - //Mock + // Mock $managerRegistryMock = $this->createMock(ManagerRegistry::class); $blockManagerInterfaceMock = $this->createMock(BlockManagerInterface::class); $pageMock = $this->createMock(PageInterface::class); @@ -70,16 +70,16 @@ public function testNotLoadBlocks(): void $blockInteractor = new BlockInteractor($managerRegistryMock, $blockManagerInterfaceMock); - //Change property visibility + // Change property visibility $reflection = new \ReflectionClass($blockInteractor); $reflection_property = $reflection->getProperty('pageBlocksLoaded'); $reflection_property->setAccessible(true); $reflection_property->setValue($blockInteractor, [1 => 'fake_value(block already loaded).']); - //Run + // Run $result = $blockInteractor->loadPageBlocks($pageMock); - //Assert + // Assert static::assertSame([], $result); } @@ -91,25 +91,25 @@ public function testNotLoadBlocks(): void */ public function testDisableAndAddChildrenBlocks(): void { - //Mock + // Mock $managerRegistryMock = $this->createMock(ManagerRegistry::class); $blockManagerInterfaceMock = $this->createMock(BlockManagerInterface::class); - //NEXT_MAJOR: use PageInterface + // NEXT_MAJOR: use PageInterface $pageMock = $this->createMock(Page::class); $containerBlockMock = $this->createMock(Block::class); $containerBlockMock - ->expects(static::exactly(2))//NEXT_MAJOR: change this to static::once() + ->expects(static::exactly(2))// NEXT_MAJOR: change this to static::once() ->method('getId') ->willReturn(22); $emailButtonMock = $this->createMock(Block::class); $emailButtonMock - ->expects(static::exactly(3))//NEXT_MAJOR: change this to static::once() + ->expects(static::exactly(3))// NEXT_MAJOR: change this to static::once() ->method('getParent') ->willReturn($containerBlockMock); - //Run + // Run $blockInteractorMock = $this ->getMockBuilder(BlockInteractor::class) ->setConstructorArgs([$managerRegistryMock, $blockManagerInterfaceMock]) @@ -120,7 +120,7 @@ public function testDisableAndAddChildrenBlocks(): void ->method('getBlocksById') ->willReturn([22 => $containerBlockMock, $emailButtonMock]); - //Assert + // Assert $blockInteractorMock->loadPageBlocks($pageMock); } } diff --git a/tests/Model/PageTest.php b/tests/Model/PageTest.php index f2ef6c733..0ffde9dee 100644 --- a/tests/Model/PageTest.php +++ b/tests/Model/PageTest.php @@ -76,7 +76,6 @@ public function testHeader(): void 'Expires' => '0', ], [ - ' Location ' => ' http://www.google.fr ', "\r\nExpires " => " 0\r\n", ], @@ -210,7 +209,7 @@ public function testGetterSetter(): void static::assertInstanceOf(SnapshotInterface::class, $page->getSnapshot()); - //NEXT_MAJOR remove those target code. + // NEXT_MAJOR remove those target code. $page->setTarget($this->createMock(PageInterface::class)); static::assertInstanceOf(PageInterface::class, $page->getTarget()); $page->setTarget(null); diff --git a/tests/Service/CleanupSnapshotServiceTest.php b/tests/Service/CleanupSnapshotServiceTest.php index 1017caffe..59f1b2c0d 100644 --- a/tests/Service/CleanupSnapshotServiceTest.php +++ b/tests/Service/CleanupSnapshotServiceTest.php @@ -28,7 +28,7 @@ class CleanupSnapshotServiceTest extends TestCase */ public function testCallCleanupQuery(): void { - //Mock + // Mock $snapshotManagerMock = $this->createMock(SnapshotManager::class); $snapshotManagerMock ->method('getEntityManager') @@ -51,7 +51,7 @@ public function testCallCleanupQuery(): void ->method('getId') ->willReturn(2); - //Run code + // Run code $cleanupSnapshot = new CleanupSnapshotService($snapshotManagerMock, $pageManagerMock); $cleanupSnapshot->cleanupBySite($siteMock, 4); } diff --git a/tests/Service/CreateSnapshotServiceTest.php b/tests/Service/CreateSnapshotServiceTest.php index 0f2993eea..c72391934 100644 --- a/tests/Service/CreateSnapshotServiceTest.php +++ b/tests/Service/CreateSnapshotServiceTest.php @@ -27,7 +27,7 @@ final class CreateSnapshotServiceTest extends TestCase { public function testCreateBySite(): void { - //Mocks + // Mocks $snapshotManagerMock = $this->createMock(SnapshotManager::class); $snapshotManagerMock ->method('getEntityManager') @@ -45,12 +45,12 @@ public function testCreateBySite(): void $siteMock = $this->createMock(SiteInterface::class); - //Asserts mocks + // Asserts mocks $transformerMock ->expects(static::once()) ->method('create'); - //Execute code + // Execute code $createSnapshotService = new CreateSnapshotService( $snapshotManagerMock, $pageManagerMock,