From 8791d7212704a5494f261979215e55f12fb817ca Mon Sep 17 00:00:00 2001 From: Sonata CI Date: Sat, 20 Aug 2022 07:53:58 +0100 Subject: [PATCH 1/4] DevKit updates (#1565) --- .php-cs-fixer.dist.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 568a3840d..0547e837f 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -47,7 +47,7 @@ 'ordered_imports' => ['sort_algorithm' => 'alpha', 'imports_order' => ['class', 'function', 'const']], 'php_unit_strict' => true, 'php_unit_test_case_static_method_calls' => true, - 'phpdoc_to_comment' => ['ignored_tags' => ['psalm-suppress']], + 'phpdoc_to_comment' => ['ignored_tags' => ['psalm-suppress', 'phpstan-var']], 'single_line_throw' => false, 'static_lambda' => true, 'strict_comparison' => true, From 2703c76cea5399b2728dc049af7792423f01002a Mon Sep 17 00:00:00 2001 From: SonataCI Date: Mon, 29 Aug 2022 07:06:07 +0000 Subject: [PATCH 2/4] DevKit updates --- bin/console | 2 +- phpunit.xml.dist | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/console b/bin/console index 3e3a431d7..b6aad036b 100755 --- a/bin/console +++ b/bin/console @@ -30,6 +30,6 @@ set_time_limit(0); require dirname(__DIR__) . '/vendor/autoload.php'; -$kernel = new AppKernel(); +$kernel = new AppKernel('test', false); $application = new Application($kernel); $application->run(new ArgvInput()); diff --git a/phpunit.xml.dist b/phpunit.xml.dist index dbe863873..9bfbf993a 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -33,5 +33,8 @@ It's auto-generated by sonata-project/dev-kit package. + + + From 565b9c550a58c206de72d4f3f765f7f53a04ccc5 Mon Sep 17 00:00:00 2001 From: Jordi Sala Morales Date: Mon, 29 Aug 2022 09:52:05 +0200 Subject: [PATCH 3/4] Fix AppKernel --- composer.json | 1 + tests/App/AppKernel.php | 7 ++----- tests/App/config/doctrine.yaml | 2 +- tests/Command/CleanupSnapshotsCommandTest.php | 6 ------ tests/Command/CreateSnapshotsCommandTest.php | 6 ------ tests/Functional/Snapshot/SnapshotManagerTest.php | 6 ------ tests/Functional/Ticket/Issue1134Test.php | 6 ------ tests/Page/TemplateManagerTest.php | 6 ------ tests/custom_bootstrap.php | 6 +++++- 9 files changed, 9 insertions(+), 37 deletions(-) diff --git a/composer.json b/composer.json index 462c6a587..4a6f379e6 100644 --- a/composer.json +++ b/composer.json @@ -70,6 +70,7 @@ "sonata-project/cache-bundle": "^3.3", "symfony/browser-kit": "^4.4", "symfony/css-selector": "^4.4", + "symfony/filesystem": "^4.4", "symfony/phpunit-bridge": "^5.1.4", "vimeo/psalm": "^4.7.2" }, diff --git a/tests/App/AppKernel.php b/tests/App/AppKernel.php index ba7c5afc9..8623352de 100644 --- a/tests/App/AppKernel.php +++ b/tests/App/AppKernel.php @@ -40,11 +40,6 @@ final class AppKernel extends Kernel { use MicroKernelTrait; - public function __construct() - { - parent::__construct('test', false); - } - public function registerBundles(): array { $bundles = [ @@ -95,6 +90,8 @@ protected function configureRoutes(RouteCollectionBuilder $routes): void protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void { + $container->setParameter('app.base_dir', $this->getBaseDir()); + $loader->load($this->getProjectDir().'/config/config.yaml'); } diff --git a/tests/App/config/doctrine.yaml b/tests/App/config/doctrine.yaml index 4f37b5135..36f36adb7 100644 --- a/tests/App/config/doctrine.yaml +++ b/tests/App/config/doctrine.yaml @@ -1,6 +1,6 @@ doctrine: dbal: - url: 'sqlite:///%kernel.cache_dir%/data.db' + url: 'sqlite:///%app.base_dir%database.db' orm: auto_generate_proxy_classes: true naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware diff --git a/tests/Command/CleanupSnapshotsCommandTest.php b/tests/Command/CleanupSnapshotsCommandTest.php index 781050841..dea5f45b5 100644 --- a/tests/Command/CleanupSnapshotsCommandTest.php +++ b/tests/Command/CleanupSnapshotsCommandTest.php @@ -17,7 +17,6 @@ use Sonata\PageBundle\Model\SiteInterface; use Sonata\PageBundle\Model\SiteManagerInterface; use Sonata\PageBundle\Service\Contract\CleanupSnapshotBySiteInterface; -use Sonata\PageBundle\Tests\App\AppKernel; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\Console\Tester\CommandTester; @@ -174,9 +173,4 @@ public function testCleanupSnapshot(): void static::assertStringContainsString('- Cleaning up snapshots ...', $output); static::assertStringContainsString('done!', $output); } - - protected static function getKernelClass(): string - { - return AppKernel::class; - } } diff --git a/tests/Command/CreateSnapshotsCommandTest.php b/tests/Command/CreateSnapshotsCommandTest.php index 5fbe83e07..95ca7ce58 100644 --- a/tests/Command/CreateSnapshotsCommandTest.php +++ b/tests/Command/CreateSnapshotsCommandTest.php @@ -18,7 +18,6 @@ use Sonata\PageBundle\Model\SiteInterface; use Sonata\PageBundle\Model\SiteManagerInterface; use Sonata\PageBundle\Service\Contract\CreateSnapshotBySiteInterface; -use Sonata\PageBundle\Tests\App\AppKernel; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\Console\Input\InputInterface; @@ -202,9 +201,4 @@ public function testRequireSiteAllArgument() static::assertStringContainsString('Please provide an --site=SITE_ID option or the --site=all directive', $output); } - - protected static function getKernelClass(): string - { - return AppKernel::class; - } } diff --git a/tests/Functional/Snapshot/SnapshotManagerTest.php b/tests/Functional/Snapshot/SnapshotManagerTest.php index bdc1134d5..dbfbd116d 100644 --- a/tests/Functional/Snapshot/SnapshotManagerTest.php +++ b/tests/Functional/Snapshot/SnapshotManagerTest.php @@ -19,7 +19,6 @@ use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\OptimisticLockException; use Sonata\PageBundle\Entity\SnapshotManager; -use Sonata\PageBundle\Tests\App\AppKernel; use Sonata\PageBundle\Tests\App\Entity\SonataPagePage; use Sonata\PageBundle\Tests\App\Entity\SonataPageSnapshot; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; @@ -244,9 +243,4 @@ public static function assertDateTimeEquals(\DateTime $expected, \DateTime $actu { static::assertSame($expected->format('c'), $actual->format('c')); } - - protected static function getKernelClass(): string - { - return AppKernel::class; - } } diff --git a/tests/Functional/Ticket/Issue1134Test.php b/tests/Functional/Ticket/Issue1134Test.php index 38bc048cb..7b5d1b2e8 100644 --- a/tests/Functional/Ticket/Issue1134Test.php +++ b/tests/Functional/Ticket/Issue1134Test.php @@ -13,7 +13,6 @@ namespace Sonata\PageBundle\Tests\Functional\Ticket; -use Sonata\PageBundle\Tests\App\AppKernel; use Sonata\PageBundle\Tests\App\Entity\SonataPageSite; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\HttpFoundation\Request; @@ -56,9 +55,4 @@ public function testLabelInShowAction(): void static::assertSame(Response::HTTP_OK, $client->getResponse()->getStatusCode()); } - - protected static function getKernelClass(): string - { - return AppKernel::class; - } } diff --git a/tests/Page/TemplateManagerTest.php b/tests/Page/TemplateManagerTest.php index 676d8a12b..8b0dacba9 100644 --- a/tests/Page/TemplateManagerTest.php +++ b/tests/Page/TemplateManagerTest.php @@ -18,7 +18,6 @@ use Sonata\PageBundle\Model\PageInterface; use Sonata\PageBundle\Model\Template; use Sonata\PageBundle\Page\TemplateManager; -use Sonata\PageBundle\Tests\App\AppKernel; use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\DomCrawler\Crawler; @@ -207,11 +206,6 @@ public function testTemplateShowingBreadcrumbIntoThePage(): void static::assertStringContainsString('Foo', $breadcrumbFoo->text()); } - protected static function getKernelClass(): string - { - return AppKernel::class; - } - /** * Returns the mock template. */ diff --git a/tests/custom_bootstrap.php b/tests/custom_bootstrap.php index 825752af4..85798e61f 100644 --- a/tests/custom_bootstrap.php +++ b/tests/custom_bootstrap.php @@ -15,8 +15,10 @@ use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\NullOutput; +use Symfony\Component\Filesystem\Filesystem; -$application = new Application(new AppKernel()); +$kernel = new AppKernel($_SERVER['APP_ENV'], $_SERVER['APP_DEBUG']); +$application = new Application($kernel); $application->setAutoExit(false); $input = new ArrayInput([ @@ -35,3 +37,5 @@ 'command' => 'doctrine:schema:create', ]); $application->run($input, new NullOutput()); + +(new Filesystem())->remove([$kernel->getCacheDir()]); From 9389aab8e131125d57365c1158b04648d17eb0c7 Mon Sep 17 00:00:00 2001 From: Sonata CI Date: Sun, 4 Sep 2022 08:40:15 +0100 Subject: [PATCH 4/4] DevKit updates for 3.x branch (#1588) * DevKit updates * DevKit updates --- .php-cs-fixer.dist.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 0547e837f..11d81185e 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -45,6 +45,11 @@ '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']], + 'phpdoc_order' => ['order' => ['var', 'param', 'throws', 'return', 'phpstan-var', 'psalm-var', 'phpstan-param', 'psalm-param', 'phpstan-return', 'psalm-return']], + 'phpdoc_separation' => ['groups' => [ + ['phpstan-template', 'phpstan-template-covariant', 'phpstan-extends', 'phpstan-implements', 'phpstan-var', 'psalm-var', 'phpstan-param', 'psalm-param', 'phpstan-return', 'psalm-return'], + ['psalm-suppress', 'phpstan-ignore-next-line'], + ]], 'php_unit_strict' => true, 'php_unit_test_case_static_method_calls' => true, 'phpdoc_to_comment' => ['ignored_tags' => ['psalm-suppress', 'phpstan-var']],