[AdminBundle][Tests] Use the new directory structure

This commit is contained in:
Jan Goralski 2022-09-07 16:09:11 +02:00 committed by Mateusz Zalewski
parent 0006ffd10f
commit 1adda6bf7d
No known key found for this signature in database
GPG key ID: 9BECA0BB71612E52
13 changed files with 286 additions and 209 deletions

View file

@ -1,201 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Bundle\AdminBundle\Tests;
use BabDev\PagerfantaBundle\BabDevPagerfantaBundle;
use Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle;
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle;
use FOS\RestBundle\FOSRestBundle;
use JMS\SerializerBundle\JMSSerializerBundle;
use Knp\Bundle\GaufretteBundle\KnpGaufretteBundle;
use Knp\Bundle\MenuBundle\KnpMenuBundle;
use League\FlysystemBundle\FlysystemBundle;
use Liip\ImagineBundle\LiipImagineBundle;
use Payum\Bundle\PayumBundle\PayumBundle;
use Sonata\BlockBundle\SonataBlockBundle;
use Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle;
use Sylius\Bundle\AddressingBundle\SyliusAddressingBundle;
use Sylius\Bundle\AdminBundle\SyliusAdminBundle;
use Sylius\Bundle\AttributeBundle\SyliusAttributeBundle;
use Sylius\Bundle\ChannelBundle\SyliusChannelBundle;
use Sylius\Bundle\CoreBundle\SyliusCoreBundle;
use Sylius\Bundle\CurrencyBundle\SyliusCurrencyBundle;
use Sylius\Bundle\CustomerBundle\SyliusCustomerBundle;
use Sylius\Bundle\FixturesBundle\SyliusFixturesBundle;
use Sylius\Bundle\GridBundle\SyliusGridBundle;
use Sylius\Bundle\InventoryBundle\SyliusInventoryBundle;
use Sylius\Bundle\LocaleBundle\SyliusLocaleBundle;
use Sylius\Bundle\MailerBundle\SyliusMailerBundle;
use Sylius\Bundle\MoneyBundle\SyliusMoneyBundle;
use Sylius\Bundle\OrderBundle\SyliusOrderBundle;
use Sylius\Bundle\PaymentBundle\SyliusPaymentBundle;
use Sylius\Bundle\PayumBundle\SyliusPayumBundle;
use Sylius\Bundle\ProductBundle\SyliusProductBundle;
use Sylius\Bundle\PromotionBundle\SyliusPromotionBundle;
use Sylius\Bundle\ResourceBundle\SyliusResourceBundle;
use Sylius\Bundle\ReviewBundle\SyliusReviewBundle;
use Sylius\Bundle\ShippingBundle\SyliusShippingBundle;
use Sylius\Bundle\TaxationBundle\SyliusTaxationBundle;
use Sylius\Bundle\TaxonomyBundle\SyliusTaxonomyBundle;
use Sylius\Bundle\ThemeBundle\SyliusThemeBundle;
use Sylius\Bundle\UiBundle\SyliusUiBundle;
use Sylius\Bundle\UserBundle\SyliusUserBundle;
use Sylius\Calendar\SyliusCalendarBundle;
use SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Bundle\SecurityBundle\SecurityBundle;
use Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle;
use Symfony\Bundle\TwigBundle\TwigBundle;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
use Symfony\Component\Routing\RouteCollectionBuilder;
use Symfony\WebpackEncoreBundle\WebpackEncoreBundle;
use winzou\Bundle\StateMachineBundle\winzouStateMachineBundle;
final class TestKernel extends BaseKernel
{
use MicroKernelTrait;
public function registerBundles(): array
{
return [
new FrameworkBundle(),
new SecurityBundle(),
new SwiftmailerBundle(),
new TwigBundle(),
new DoctrineBundle(),
new SyliusCalendarBundle(),
new SyliusOrderBundle(),
new SyliusMoneyBundle(),
new SyliusCurrencyBundle(),
new SyliusLocaleBundle(),
new SyliusProductBundle(),
new SyliusChannelBundle(),
new SyliusAttributeBundle(),
new SyliusTaxationBundle(),
new SyliusShippingBundle(),
new SyliusPaymentBundle(),
new SyliusMailerBundle(),
new SyliusPromotionBundle(),
new SyliusAddressingBundle(),
new SyliusInventoryBundle(),
new SyliusTaxonomyBundle(),
new SyliusUserBundle(),
new SyliusCustomerBundle(),
new SyliusUiBundle(),
new SyliusReviewBundle(),
new SyliusCoreBundle(),
new SyliusResourceBundle(),
new SyliusGridBundle(),
new winzouStateMachineBundle(),
new BazingaHateoasBundle(),
new JMSSerializerBundle(),
new FOSRestBundle(),
new KnpGaufretteBundle(),
new FlysystemBundle(),
new LiipImagineBundle(),
new PayumBundle(),
new StofDoctrineExtensionsBundle(),
new BabDevPagerfantaBundle(),
new SyliusFixturesBundle(),
new SyliusPayumBundle(),
new SyliusThemeBundle(),
new SonataBlockBundle(),
new DoctrineMigrationsBundle(),
new SyliusLabsDoctrineMigrationsExtraBundle(),
new KnpMenuBundle(),
new SyliusAdminBundle(),
new WebpackEncoreBundle(),
];
}
protected function configureContainer(ContainerBuilder $containerBuilder, LoaderInterface $loader): void
{
$containerBuilder->setParameter('locale', 'en_US');
$containerBuilder->loadFromExtension('framework', [
'test' => null,
'secret' => 'S0ME_SECRET',
'session' => [
'handler_id' => null,
],
'default_locale' => '%locale%',
'translator' => [
'fallbacks' => [
'%locale%',
'en',
],
],
]);
$containerBuilder->loadFromExtension('security', [
'firewalls' => [
'main' => [
'anonymous' => true,
],
],
]);
$containerBuilder->loadFromExtension('doctrine', [
'dbal' => [
'driver' => 'pdo_mysql',
'server_version' => '5.7',
'charset' => 'UTF8',
'url' => 'sqlite:///%kernel.project_dir%/var/data.db',
],
]);
$containerBuilder->loadFromExtension('swiftmailer', [
'disable_delivery' => true,
'logging' => true,
'spool' => [
'type' => 'file',
'path' => '%kernel.cache_dir%/spool',
],
]);
$containerBuilder->loadFromExtension('stof_doctrine_extensions', [
'default_locale' => '%locale%',
]);
$containerBuilder->loadFromExtension('twig', [
'debug' => '%kernel.debug%',
'strict_variables' => '%kernel.debug%',
]);
$loader->load('@SyliusCoreBundle/Resources/config/app/config.yml');
}
/**
* @param RoutingConfigurator|RouteCollectionBuilder $routes
*/
protected function configureRoutes(object $routes): void
{
$routes->import('@SyliusAdminBundle/Resources/config/routing.yml');
}
public function getCacheDir(): string
{
return sys_get_temp_dir() . '/SyliusCoreBundle/cache/' . $this->getEnvironment();
}
public function getLogDir(): string
{
return sys_get_temp_dir() . '/SyliusCoreBundle/logs';
}
}

View file

@ -43,7 +43,8 @@
"require-dev": {
"phpspec/phpspec": "^7.2",
"phpunit/phpunit": "^8.5",
"symfony/dependency-injection": "^5.4 || ^6.0"
"symfony/dependency-injection": "^5.4 || ^6.0",
"symfony/dotenv": "^5.4 || ^6.0"
},
"config": {
"allow-plugins": {

View file

@ -4,6 +4,12 @@
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/8.5/phpunit.xsd"
colors="true"
>
<testsuites>
<testsuite name="SyliusAdminBundle Test Suite">
<directory>./Tests/</directory>
</testsuite>
</testsuites>
<php>
<ini name="error_reporting" value="-1" />
@ -12,12 +18,6 @@
<env name="SHELL_VERBOSITY" value="-1" />
<!-- ###- symfony/framework-bundle ### -->
<server name="KERNEL_CLASS" value="Sylius\Bundle\AdminBundle\Tests\TestKernel" />
<server name="KERNEL_CLASS" value="\Sylius\Bundle\AdminBundle\Application\Kernel" />
</php>
<testsuites>
<testsuite name="SyliusAdminBundle Test Suite">
<directory>./Tests/</directory>
</testsuite>
</testsuites>
</phpunit>

View file

@ -0,0 +1,5 @@
###> symfony/framework-bundle ###
APP_ENV=dev
APP_DEBUG=1
MESSENGER_TRANSPORT_DSN=sync://
###< symfony/framework-bundle ###

View file

@ -0,0 +1 @@
KERNEL_CLASS='Sylius\Bundle\AdminBundle\Application\Kernel'

View file

@ -0,0 +1,47 @@
/public/assets
/public/css
/public/js
/public/media
/public/build
!/public/media/image/.gitkeep
/bin/symfony_requirements
/docs/.doctrees
/composer.lock
/node_modules
/etc/build/*
!/etc/build/.gitignore
/behat.yml
/phpspec.yml
# Symfony CLI https://symfony.com/doc/current/setup/symfony_server.html#different-php-settings-per-project
/.php-version
/php.ini
###> symfony/framework-bundle ###
.env.*.local
.env.local
.env.local.php
/public/bundles
/var/
/vendor/
###< symfony/framework-bundle ###
###> friendsofphp/php-cs-fixer ###
/.php_cs
/.php_cs.cache
###< friendsofphp/php-cs-fixer ###
###> phpunit/phpunit ###
/phpunit.xml
/.phpunit.result.cache
###< phpunit/phpunit ###
###> lexik/jwt-authentication-bundle ###
/Application/config/jwt/private.pem
/Application/config/jwt/public.pem
###< lexik/jwt-authentication-bundle ###

View file

@ -0,0 +1,33 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
use Symfony\Component\Dotenv\Dotenv;
require __DIR__ . '/../../vendor/autoload.php';
// Load cached env vars if the .env.local.php file exists
// Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
$envLocalPhpPath = dirname(__DIR__) . '/.env.local.php';
if (is_array($env = @include $envLocalPhpPath)) {
$_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())->loadEnv(dirname(__DIR__) . '/.env');
}
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev';
$_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';

View file

@ -0,0 +1,61 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['test_with_swiftmailer' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true],
Sylius\Bundle\OrderBundle\SyliusOrderBundle::class => ['all' => true],
Sylius\Bundle\MoneyBundle\SyliusMoneyBundle::class => ['all' => true],
Sylius\Bundle\CurrencyBundle\SyliusCurrencyBundle::class => ['all' => true],
Sylius\Bundle\LocaleBundle\SyliusLocaleBundle::class => ['all' => true],
Sylius\Bundle\ProductBundle\SyliusProductBundle::class => ['all' => true],
Sylius\Bundle\ChannelBundle\SyliusChannelBundle::class => ['all' => true],
Sylius\Bundle\AttributeBundle\SyliusAttributeBundle::class => ['all' => true],
Sylius\Bundle\TaxationBundle\SyliusTaxationBundle::class => ['all' => true],
Sylius\Bundle\ShippingBundle\SyliusShippingBundle::class => ['all' => true],
Sylius\Bundle\PaymentBundle\SyliusPaymentBundle::class => ['all' => true],
Sylius\Bundle\MailerBundle\SyliusMailerBundle::class => ['all' => true],
Sylius\Bundle\PromotionBundle\SyliusPromotionBundle::class => ['all' => true],
Sylius\Bundle\AddressingBundle\SyliusAddressingBundle::class => ['all' => true],
Sylius\Bundle\InventoryBundle\SyliusInventoryBundle::class => ['all' => true],
Sylius\Bundle\TaxonomyBundle\SyliusTaxonomyBundle::class => ['all' => true],
Sylius\Bundle\UserBundle\SyliusUserBundle::class => ['all' => true],
Sylius\Bundle\CustomerBundle\SyliusCustomerBundle::class => ['all' => true],
Sylius\Bundle\UiBundle\SyliusUiBundle::class => ['all' => true],
Sylius\Bundle\ReviewBundle\SyliusReviewBundle::class => ['all' => true],
Sylius\Bundle\CoreBundle\SyliusCoreBundle::class => ['all' => true],
Sylius\Bundle\ResourceBundle\SyliusResourceBundle::class => ['all' => true],
Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true],
winzou\Bundle\StateMachineBundle\winzouStateMachineBundle::class => ['all' => true],
Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle::class => ['all' => true],
JMS\SerializerBundle\JMSSerializerBundle::class => ['all' => true],
FOS\RestBundle\FOSRestBundle::class => ['all' => true],
Knp\Bundle\GaufretteBundle\KnpGaufretteBundle::class => ['all' => true],
Liip\ImagineBundle\LiipImagineBundle::class => ['all' => true],
Payum\Bundle\PayumBundle\PayumBundle::class => ['all' => true],
Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true],
BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true],
Sylius\Bundle\FixturesBundle\SyliusFixturesBundle::class => ['all' => true],
Sylius\Bundle\PayumBundle\SyliusPayumBundle::class => ['all' => true],
Sylius\Bundle\ThemeBundle\SyliusThemeBundle::class => ['all' => true],
Sonata\BlockBundle\SonataBlockBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true],
Knp\Bundle\MenuBundle\KnpMenuBundle::class => ['all' => true],
Sylius\Bundle\AdminBundle\SyliusAdminBundle::class => ['all' => true],
];

View file

@ -0,0 +1,33 @@
imports:
- { resource: "@SyliusCoreBundle/Resources/config/app/config.yml" }
parameters:
locale: en_US
database_driver: pdo_sqlite
database_path: "%kernel.project_dir%/var/db.sql"
framework:
secret: "ch4mb3r0f5ecr3ts"
default_locale: "%locale%"
session:
handler_id: ~
storage_factory_id: session.storage.factory.mock_file
test: ~
mailer:
dsn: 'null://null'
security:
firewalls:
main:
security: false
doctrine_migrations:
storage:
table_storage:
table_name: sylius_migrations
doctrine:
dbal:
driver: "%database_driver%"
path: "%database_path%"
charset: UTF8

View file

@ -0,0 +1,6 @@
swiftmailer:
disable_delivery: true
logging: true
spool:
type: file
path: '%kernel.cache_dir%/spool'

View file

@ -0,0 +1,3 @@
sylius_admin:
resource: '@SyliusAdminBundle/Resources/config/routing.yml'
prefix: /admin

View file

@ -0,0 +1,38 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
use Sylius\Bundle\ApiBundle\Application\Kernel;
use Symfony\Component\ErrorHandler\Debug;
use Symfony\Component\HttpFoundation\Request;
require dirname(__DIR__) . '/config/bootstrap.php';
if ($_SERVER['APP_DEBUG']) {
umask(0000);
Debug::enable();
}
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
}
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
Request::setTrustedHosts([$trustedHosts]);
}
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);

View file

@ -0,0 +1,50 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Bundle\AdminBundle\Application;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
final class Kernel extends BaseKernel
{
use MicroKernelTrait;
private const CONFIG_EXTS = '.{php,xml,yaml,yml}';
public function getCacheDir(): string
{
return $this->getProjectDir() . '/var/cache/' . $this->environment;
}
public function getLogDir(): string
{
return $this->getProjectDir() . '/var/log';
}
public function getProjectDir(): string
{
return parent::getProjectDir() . '/test';
}
public function registerBundles(): iterable
{
$bundlesPath = $this->getProjectDir() . '/config/bundles.php';
$contents = require $bundlesPath;
foreach ($contents as $class => $envs) {
if (isset($envs['all']) || isset($envs[$this->environment])) {
yield new $class();
}
}
}
}