diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 120d8b6..50535b7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -64,3 +64,7 @@ jobs: - name: Run bundle tests run: composer test + + - + name: Run lint container + run: (cd src/Bundle/test && bin/console lint:container) diff --git a/composer.json b/composer.json index da93f39..d127e6d 100644 --- a/composer.json +++ b/composer.json @@ -45,6 +45,7 @@ "phpunit/phpunit": "^9.4", "sylius-labs/coding-standard": "^4.0", "symfony/console": "^5.4", + "symfony/dotenv": "^5.4", "symfony/swiftmailer-bundle": "^3.1", "symfony/twig-bundle": "^5.4", "vimeo/psalm": "^4.22", @@ -64,11 +65,9 @@ "autoload-dev": { "psr-4": { "Sylius\\Bundle\\MailerBundle\\spec\\": "src/Bundle/spec/", - "Sylius\\Component\\Mailer\\spec\\": "src/Component/spec/" - }, - "classmap": [ - "src/Bundle/test/app/AppKernel.php" - ] + "Sylius\\Component\\Mailer\\spec\\": "src/Component/spec/", + "App\\": "src/Bundle/test/src/" + } }, "scripts": { "analyse": [ diff --git a/phpunit.xml.dist b/phpunit.xml.dist index b54f546..832d44d 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -5,7 +5,7 @@ colors="true" > - + diff --git a/src/Bundle/test/.env b/src/Bundle/test/.env new file mode 100644 index 0000000..afd9352 --- /dev/null +++ b/src/Bundle/test/.env @@ -0,0 +1 @@ +APP_ENV=test diff --git a/src/Bundle/test/app/AppKernel.php b/src/Bundle/test/app/AppKernel.php deleted file mode 100644 index 1f4a64e..0000000 --- a/src/Bundle/test/app/AppKernel.php +++ /dev/null @@ -1,39 +0,0 @@ -load(__DIR__ . '/config/config.yml'); - } -} diff --git a/src/Bundle/test/app/config/config.yml b/src/Bundle/test/app/config/config.yml deleted file mode 100644 index 7b2fce2..0000000 --- a/src/Bundle/test/app/config/config.yml +++ /dev/null @@ -1,13 +0,0 @@ -imports: - - { resource: "@SyliusMailerBundle/test/app/config/parameters.yml" } - -framework: - assets: false - secret: "%secret%" - default_locale: "%locale%" - http_method_override: true - test: ~ - -twig: - debug: "%kernel.debug%" - strict_variables: "%kernel.debug%" diff --git a/src/Bundle/test/app/console b/src/Bundle/test/app/console deleted file mode 100755 index 296012b..0000000 --- a/src/Bundle/test/app/console +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env php -run($input); diff --git a/src/Bundle/test/bin/console b/src/Bundle/test/bin/console new file mode 100755 index 0000000..3b1b0a6 --- /dev/null +++ b/src/Bundle/test/bin/console @@ -0,0 +1,38 @@ +#!/usr/bin/env php +getParameterOption(['--env', '-e'], null, true)) { + putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env); +} + +if ($input->hasParameterOption('--no-debug', true)) { + putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0'); +} + +require dirname(__DIR__).'/config/bootstrap.php'; + +if ($_SERVER['APP_DEBUG']) { + umask(0000); + + if (class_exists(Debug::class)) { + Debug::enable(); + } +} + +$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']); +$application = new Application($kernel); +$application->run($input); diff --git a/src/Bundle/test/config/bootstrap.php b/src/Bundle/test/config/bootstrap.php new file mode 100644 index 0000000..ff1f1b1 --- /dev/null +++ b/src/Bundle/test/config/bootstrap.php @@ -0,0 +1,32 @@ +=1.2) +if (is_array($env = @include dirname(__DIR__) . '/.env.local.php')) { + $_SERVER += $env; + $_ENV += $env; +} elseif (!class_exists(Dotenv::class)) { + throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.'); +} else { + // load all the .env files + (new Dotenv(true))->loadEnv(dirname(__DIR__) . '/.env'); +} + +$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'test'; +$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV']; +$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], \FILTER_VALIDATE_BOOLEAN) ? '1' : '0'; diff --git a/src/Bundle/test/config/bundles.php b/src/Bundle/test/config/bundles.php new file mode 100644 index 0000000..1ef5aa2 --- /dev/null +++ b/src/Bundle/test/config/bundles.php @@ -0,0 +1,19 @@ + ['all' => true], + Sylius\Bundle\MailerBundle\SyliusMailerBundle::class => ['all' => true], + Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], + Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true], +]; diff --git a/src/Bundle/test/config/packages/framework.yaml b/src/Bundle/test/config/packages/framework.yaml new file mode 100644 index 0000000..298db27 --- /dev/null +++ b/src/Bundle/test/config/packages/framework.yaml @@ -0,0 +1,6 @@ +framework: + assets: false + secret: "%secret%" + default_locale: "%locale%" + http_method_override: true + test: ~ diff --git a/src/Bundle/test/config/packages/twig.yaml b/src/Bundle/test/config/packages/twig.yaml new file mode 100644 index 0000000..fa8824d --- /dev/null +++ b/src/Bundle/test/config/packages/twig.yaml @@ -0,0 +1,3 @@ +twig: + debug: "%kernel.debug%" + strict_variables: "%kernel.debug%" diff --git a/src/Bundle/test/app/config/parameters.yml b/src/Bundle/test/config/services.yaml similarity index 100% rename from src/Bundle/test/app/config/parameters.yml rename to src/Bundle/test/config/services.yaml diff --git a/src/Bundle/test/src/Kernel.php b/src/Bundle/test/src/Kernel.php new file mode 100644 index 0000000..b268e2d --- /dev/null +++ b/src/Bundle/test/src/Kernel.php @@ -0,0 +1,22 @@ +