diff --git a/.env.test b/.env.test index 914deb541..d431ad16c 100644 --- a/.env.test +++ b/.env.test @@ -3,3 +3,38 @@ # Run tests from root to adapt your own environment KERNEL_CLASS='App\Kernel' APP_SECRET='$ecretf0rt3st' + +ADMIN_PASSWORD=admin + +LOCALE=fr +REDIS_URL=redis +REDIS_PORT=6379 +REDIS_URL=redis://${REDIS_HOST}:${REDIS_PORT} + +JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private.pem +JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem +JWT_PASSPHRASE=2a30f6ba26521a2613821da35f28386e + +TWILIO_SID=~ +TWILIO_SECRET=~ +DEFAULT_CARRIER_CODE=BE + +ADD_ADDRESS_DEFAULT_COUNTRY=BE + +ADD_ADDRESS_MAP_CENTER_X=50.8443 +ADD_ADDRESS_MAP_CENTER_Y=4.3523 +ADD_ADDRESS_MAP_CENTER_Z=15 + +SHORT_MESSAGE_DSN=null://null +MESSENGER_TRANSPORT_DSN=sync:// +###< symfony/messenger ### + +###> doctrine/doctrine-bundle ### +# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url +# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml +# +DATABASE_URL="postgresql://postgres:postgres@db:5432/test?serverVersion=14&charset=utf8" + +ASYNC_UPLOAD_TEMP_URL_KEY= +ASYNC_UPLOAD_TEMP_URL_BASE_PATH= +ASYNC_UPLOAD_TEMP_URL_CONTAINER= diff --git a/.gitmodules b/.gitmodules index 560ba7980..7bc519c88 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ [submodule "_exts/sphinx-php"] path = _exts/sphinx-php url = https://github.com/fabpot/sphinx-php.git -[submodule "tests/app"] - path = tests/app - url = https://gitlab.com/Chill-projet/chill-app.git diff --git a/composer.json b/composer.json index b47856954..c5cd9c982 100644 --- a/composer.json +++ b/composer.json @@ -107,7 +107,7 @@ }, "autoload-dev": { "psr-4": { - "App\\": "tests/app/src/", + "App\\": "tests/", "Chill\\DocGeneratorBundle\\Tests\\": "src/Bundle/ChillDocGeneratorBundle/tests", "Chill\\WopiBundle\\Tests\\": "src/Bundle/ChillDocGeneratorBundle/tests" } @@ -123,12 +123,10 @@ }, "bin-dir": "bin", "optimize-autoloader": true, - "sort-packages": true, - "vendor-dir": "tests/app/vendor" + "sort-packages": true }, "scripts": { "auto-scripts": { - "assets:install %PUBLIC_DIR%": "symfony-cmd", "cache:clear": "symfony-cmd" } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 8f157fcc5..996eae432 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,10 +2,10 @@ diff --git a/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php b/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php index f9392ba57..5adce17b2 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Form/CalendarTypeTest.php @@ -97,9 +97,9 @@ final class CalendarTypeTest extends TypeTestCase $calendar = new Calendar(); $calendar->setMainUser(new class () extends User { - public function getId() + public function getId(): ?int { - return '1'; + return 1; } }); diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php index 151ecf0c2..7024e732b 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadRelationships.php @@ -42,6 +42,7 @@ class LoadRelationships extends Fixture implements DependentFixtureInterface public function load(ObjectManager $manager): void { + return; $existing = []; for ($i = 0; 20 > $i; ++$i) { diff --git a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php index 2dcf69c50..565266a5e 100644 --- a/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php +++ b/src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php @@ -198,6 +198,8 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or return $result; } + + return $picked; } else { $picked = $this->pickChoice($choices); @@ -210,6 +212,8 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or return $result; } + + return $picked; } throw new \LogicException("should not happens"); diff --git a/tests/Kernel.php b/tests/Kernel.php new file mode 100644 index 000000000..5047bfa32 --- /dev/null +++ b/tests/Kernel.php @@ -0,0 +1,55 @@ + $envs) { + if ($envs[$this->environment] ?? $envs['all'] ?? false) { + yield new $class(); + } + } + } + + public function getProjectDir() + { + return \dirname(__DIR__); + } + + protected function configureRoutes(RouteCollectionBuilder $routes) + { + $confDir = $this->getProjectDir().'/tests/app/config'; + + $routes->import($confDir.'/{routes}/'.$this->environment.'/*'.self::CONFIG_EXTS, '/', 'glob'); + $routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob'); + $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob'); + } + + protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader) + { + $container->addResource(new FileResource($this->getProjectDir().'/tests/app/config/bundles.php')); + $container->setParameter('container.dumper.inline_class_loader', \PHP_VERSION_ID < 70400 || $this->debug); + $container->setParameter('container.dumper.inline_factories', true); + $confDir = $this->getProjectDir().'/tests/app/config'; + + $loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob'); + $loader->load($confDir.'/{packages}/'.$this->environment.'/*'.self::CONFIG_EXTS, 'glob'); + $loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob'); + $loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob'); + } +} diff --git a/tests/app b/tests/app deleted file mode 160000 index 5e478fdfb..000000000 --- a/tests/app +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5e478fdfbf429baf3ce852ae69eb1f7101b1b416 diff --git a/tests/app/config/bootstrap.php b/tests/app/config/bootstrap.php new file mode 100644 index 000000000..10c196e4e --- /dev/null +++ b/tests/app/config/bootstrap.php @@ -0,0 +1,23 @@ +=1.2) +if (is_array($env = @include dirname(__DIR__).'/.env.local.php') && (!isset($env['APP_ENV']) || ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? $env['APP_ENV']) === $env['APP_ENV'])) { + (new Dotenv(false))->populate($env); +} else { + // load all the .env files + (new Dotenv(false))->loadEnv(dirname(__DIR__).'/../../.env.test'); +} + +$_SERVER += $_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'; diff --git a/tests/app/config/bundles.php b/tests/app/config/bundles.php new file mode 100644 index 000000000..970afaa99 --- /dev/null +++ b/tests/app/config/bundles.php @@ -0,0 +1,39 @@ + ['all' => true], + Chill\ActivityBundle\ChillActivityBundle::class => ['all' => true], + Chill\AsideActivityBundle\ChillAsideActivityBundle::class => ['all' => true], + Chill\CalendarBundle\ChillCalendarBundle::class => ['all' => true], + Chill\CustomFieldsBundle\ChillCustomFieldsBundle::class => ['all' => true], + Chill\DocGeneratorBundle\ChillDocGeneratorBundle::class => ['all' => true], + Chill\DocStoreBundle\ChillDocStoreBundle::class => ['all' => true], + Chill\EventBundle\ChillEventBundle::class => ['all' => true], + Chill\MainBundle\ChillMainBundle::class => ['all' => true], + Chill\PersonBundle\ChillPersonBundle::class => ['all' => true], + Chill\ReportBundle\ChillReportBundle::class => ['all' => true], + Chill\TaskBundle\ChillTaskBundle::class => ['all' => true], + Chill\ThirdPartyBundle\ChillThirdPartyBundle::class => ['all' => true], + Chill\BudgetBundle\ChillBudgetBundle::class => ['all' => true], + Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], + Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true], + Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true], + Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true], + Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true], + Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], + Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true], + Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], + Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], + Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], + //Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], + Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], + Knp\Bundle\MenuBundle\KnpMenuBundle::class => ['all' => true], + Knp\Bundle\TimeBundle\KnpTimeBundle::class => ['all' => true], + Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true], + loophp\PsrHttpMessageBridgeBundle\PsrHttpMessageBridgeBundle::class => ['all' => true], + \Misd\PhoneNumberBundle\MisdPhoneNumberBundle::class => ['all' => true], + ChampsLibres\WopiBundle\WopiBundle::class => ['all' => true], + Chill\WopiBundle\ChillWopiBundle::class => ['all' => true], + \Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true], + +]; diff --git a/tests/app/config/packages/assets.yaml b/tests/app/config/packages/assets.yaml new file mode 100644 index 000000000..051d36dce --- /dev/null +++ b/tests/app/config/packages/assets.yaml @@ -0,0 +1,3 @@ +framework: + assets: + json_manifest_path: '%kernel.project_dir%/public/build/manifest.json' diff --git a/tests/app/config/packages/cache.yaml b/tests/app/config/packages/cache.yaml new file mode 100644 index 000000000..c7a5f169d --- /dev/null +++ b/tests/app/config/packages/cache.yaml @@ -0,0 +1,33 @@ +framework: + cache: + # Unique name of your app: used to compute stable namespaces for cache keys. + #prefix_seed: your_vendor_name/app_name + + # The "app" cache stores to the filesystem by default. + # The data in this cache should persist between deploys. + # Other options include: + + # Redis + #app: cache.adapter.redis + #default_redis_provider: redis://localhost + + # APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues) + #app: cache.adapter.apcu + + # Namespaced pools use the above "app" backend by default + #pools: + #my.dedicated.cache: null + + default_redis_provider: '%env(resolve:REDIS_URL)%' + + pools: + cache.user_data: + adapter: cache.adapter.redis + public: true + default_lifetime: 300 # 5 minutes + + # will be used in chill_main.tag_aware_cache service + cache.tags: + adapter: cache.adapter.redis + public: false + default_lifetime: 300 diff --git a/tests/app/config/packages/champs-libres.yaml b/tests/app/config/packages/champs-libres.yaml new file mode 100644 index 000000000..ebea3ef58 --- /dev/null +++ b/tests/app/config/packages/champs-libres.yaml @@ -0,0 +1,14 @@ +champs_libres_async_uploader: + openstack: + os_username: '%env(resolve:OS_USERNAME)%' # Required + os_password: '%env(resolve:OS_PASSWORD)%' # Required + os_tenant_id: '%env(resolve:OS_TENANT_ID)%' # Required + os_region_name: '%env(resolve:OS_REGION_NAME)%' # Required + os_auth_url: '%env(resolve:OS_AUTH_URL)%' # Required + temp_url: + temp_url_key: '%env(resolve:ASYNC_UPLOAD_TEMP_URL_KEY)%' # Required + container: '%env(resolve:ASYNC_UPLOAD_TEMP_URL_CONTAINER)%' # Required + temp_url_base_path: '%env(resolve:ASYNC_UPLOAD_TEMP_URL_BASE_PATH)%' # Required. Do not forget a trailing slash + max_post_file_size: 15000000 # 15Mo (bytes) + max_expires_delay: 180 + max_submit_delay: 3600 diff --git a/tests/app/config/packages/chill.yaml b/tests/app/config/packages/chill.yaml new file mode 100644 index 000000000..92dbd0769 --- /dev/null +++ b/tests/app/config/packages/chill.yaml @@ -0,0 +1,23 @@ +chill_main: + available_languages: [ '%env(resolve:LOCALE)%' ] + notifications: + from_email: 'test@yopmail.com' + from_name: 'TEST CHILL' + host: 'localhost' + redis: + host: '%env(resolve:REDIS_HOST)%' + port: '%env(resolve:REDIS_PORT)%' + phone_helper: + twilio_sid: '%env(resolve:TWILIO_SID)%' + twilio_secret: '%env(resolve:TWILIO_SECRET)%' + default_carrier_code: '%env(resolve:DEFAULT_CARRIER_CODE)%' + +chill_custom_fields: + show_empty_values_in_views: false + +# Enable/disable specific libraries (css and js) +twig: + globals: + active_bootstrap: false + active_forkawesome: true + active_ckeditor: false diff --git a/tests/app/config/packages/chill_budget.yaml b/tests/app/config/packages/chill_budget.yaml new file mode 100644 index 000000000..dfb50ac9f --- /dev/null +++ b/tests/app/config/packages/chill_budget.yaml @@ -0,0 +1,14 @@ +#chill_amli_budget: +# resources: +# - { key: travail-temporaire, labels: [{ lang: fr, label: "Travail temporaire" }]} +# - { key: chomage, labels: [{ lang: fr, label: "Allocation de chômage"}]} +# - { key: cpas, labels: [{ lang: fr, label: "CPAS"}]} +# - { key: mutuelle, labels: [{ lang: fr, label: "Mutuelle"}]} +# - { key: pension-alimentaire, labels: [{ lang: fr, label: "Pension alimentaire"}]} +# - { key: allocation-fam, labels: [{ lang: fr, label: "Allocations familiales"}]} +# charges: +# - { key: charge-communes, labels: [{ lang: fr, label: "Charges communes" }]} +# - { key: electricity, labels: [{ lang: fr, label: "Électricité" }]} +# - { key: gaz, labels: [{ lang: fr, label: "Gaz" }]} +# - { key: water, labels: [{ lang: fr, label: "Eau" }]} +# - { key: autres, labels: [ { lang: fr, label: "Autres"}]} diff --git a/tests/app/config/packages/dev/debug.yaml b/tests/app/config/packages/dev/debug.yaml new file mode 100644 index 000000000..26d4e53d2 --- /dev/null +++ b/tests/app/config/packages/dev/debug.yaml @@ -0,0 +1,4 @@ +debug: + # Forwards VarDumper Data clones to a centralized server allowing to inspect dumps on CLI or in your browser. + # See the "server:dump" command to start a new server. + dump_destination: "tcp://%env(VAR_DUMPER_SERVER)%" diff --git a/tests/app/config/packages/dev/monolog.yaml b/tests/app/config/packages/dev/monolog.yaml new file mode 100644 index 000000000..423fc10df --- /dev/null +++ b/tests/app/config/packages/dev/monolog.yaml @@ -0,0 +1,21 @@ +monolog: + handlers: + main: + type: stream + path: "%kernel.logs_dir%/%kernel.environment%.log" + level: debug + channels: ["!event"] + # uncomment to get logging in your browser + # you may have to allow bigger header sizes in your Web server configuration + #firephp: + # type: firephp + # level: info + #chromephp: + # type: chromephp + # level: info + console: + type: console + process_psr_3_messages: false + channels: ['!event', '!doctrine', '!console'] + bubble: false + diff --git a/tests/app/config/packages/doctrine.yaml b/tests/app/config/packages/doctrine.yaml new file mode 100644 index 000000000..9046f2e44 --- /dev/null +++ b/tests/app/config/packages/doctrine.yaml @@ -0,0 +1,18 @@ +doctrine: + dbal: + url: '%env(resolve:DATABASE_URL)%' + + # IMPORTANT: You MUST configure your server version, + # either here or in the DATABASE_URL env var (see .env file) + #server_version: '5.7' + orm: + auto_generate_proxy_classes: true + naming_strategy: doctrine.orm.naming_strategy.default + auto_mapping: true + #mappings: + # App: + # is_bundle: false + # type: annotation + # dir: '%kernel.project_dir%/src/Entity' + # prefix: 'App\Entity' + # alias: App diff --git a/tests/app/config/packages/doctrine_migrations.yaml b/tests/app/config/packages/doctrine_migrations.yaml new file mode 100644 index 000000000..a559780d3 --- /dev/null +++ b/tests/app/config/packages/doctrine_migrations.yaml @@ -0,0 +1,30 @@ +doctrine_migrations: + migrations_paths: + # migrations for default chill modules + 'Chill\Migrations\Main': '@ChillMainBundle/migrations' + 'Chill\Migrations\Activity': '@ChillActivityBundle/migrations' + 'Chill\Migrations\DocStore': '@ChillDocStoreBundle/migrations' + 'Chill\Migrations\CustomFields': '@ChillCustomFieldsBundle/migrations' + 'Chill\Migrations\Event': '@ChillEventBundle/migrations' + 'Chill\Migrations\Person': '@ChillPersonBundle/migrations' + 'Chill\Migrations\Report': '@ChillReportBundle/migrations' + 'Chill\Migrations\Task': '@ChillTaskBundle/migrations' + 'Chill\Migrations\ThirdParty': '@ChillThirdPartyBundle/migrations' + 'Chill\Migrations\AsideActivity': '@ChillAsideActivityBundle/migrations' + 'Chill\Migrations\DocGenerator': '@ChillDocGeneratorBundle/migrations' + 'Chill\Migrations\Calendar': '@ChillCalendarBundle/migrations' + 'Chill\Migrations\Budget': '@ChillBudgetBundle/migrations' + + all_or_nothing: + true + + services: + 'Doctrine\Migrations\Version\Comparator': 'Chill\MainBundle\Doctrine\Migrations\VersionComparator' + + storage: + table_storage: + table_name: 'migration_versions' + version_column_name: 'version' + version_column_length: 1024 + executed_at_column_name: 'executed_at' + execution_time_column_name: 'execution_time' diff --git a/tests/app/config/packages/framework.yaml b/tests/app/config/packages/framework.yaml new file mode 100644 index 000000000..1ce5cb7ac --- /dev/null +++ b/tests/app/config/packages/framework.yaml @@ -0,0 +1,30 @@ +# see https://symfony.com/doc/current/reference/configuration/framework.html +framework: + secret: '%env(APP_SECRET)%' + + # DIRTY FIX un bug dans symfony4 empêche de récupérer un tableau de variables depuis .env + # cfr. https://github.com/symfony/symfony/issues/28599 + trusted_hosts: + - '^(localhost|127.0.0.1)$' + + #csrf_protection: true + #http_method_override: true + + # Enables session support. Note that the session will ONLY be started if you read or write from it. + # Remove or comment this section to explicitly disable session support. + session: + handler_id: null + cookie_secure: auto + cookie_samesite: lax + + #esi: true + #fragments: true + php_errors: + log: true + + ## sf4 check: ou à déplacer dans un chill.yaml + assets: + json_manifest_path: '%kernel.project_dir%/public/build/manifest.json' + + templating: + engines: ['twig'] diff --git a/tests/app/config/packages/lexik_jwt_authentication.yaml b/tests/app/config/packages/lexik_jwt_authentication.yaml new file mode 100644 index 000000000..93041d0a2 --- /dev/null +++ b/tests/app/config/packages/lexik_jwt_authentication.yaml @@ -0,0 +1,12 @@ +lexik_jwt_authentication: + secret_key: '%env(resolve:JWT_SECRET_KEY)%' + public_key: '%env(resolve:JWT_PUBLIC_KEY)%' + pass_phrase: '%env(JWT_PASSPHRASE)%' + + # required for wopi - recommended duration + token_ttl: 36000 + + token_extractors: + query_parameter: + enabled: true + name: access_token diff --git a/tests/app/config/packages/loophp_psr17.yaml b/tests/app/config/packages/loophp_psr17.yaml new file mode 100644 index 000000000..b5481376d --- /dev/null +++ b/tests/app/config/packages/loophp_psr17.yaml @@ -0,0 +1,8 @@ +services: + # Register loophp/psr17/Psr17 class and autowire/autoconfigure it. + loophp\psr17\Psr17: + autowire: true + autoconfigure: true + + # Alias the service to the Psr17 interface. + loophp\psr17\Psr17Interface: '@loophp\psr17\Psr17' diff --git a/tests/app/config/packages/nyholm_psr7.yaml b/tests/app/config/packages/nyholm_psr7.yaml new file mode 100644 index 000000000..f1357233b --- /dev/null +++ b/tests/app/config/packages/nyholm_psr7.yaml @@ -0,0 +1,21 @@ +services: + # Register nyholm/psr7 services for autowiring with PSR-17 (HTTP factories) + Psr\Http\Message\RequestFactoryInterface: '@nyholm.psr7.psr17_factory' + Psr\Http\Message\ResponseFactoryInterface: '@nyholm.psr7.psr17_factory' + Psr\Http\Message\ServerRequestFactoryInterface: '@nyholm.psr7.psr17_factory' + Psr\Http\Message\StreamFactoryInterface: '@nyholm.psr7.psr17_factory' + Psr\Http\Message\UploadedFileFactoryInterface: '@nyholm.psr7.psr17_factory' + Psr\Http\Message\UriFactoryInterface: '@nyholm.psr7.psr17_factory' + + # Register nyholm/psr7 services for autowiring with HTTPlug factories + Http\Message\MessageFactory: '@nyholm.psr7.httplug_factory' + Http\Message\RequestFactory: '@nyholm.psr7.httplug_factory' + Http\Message\ResponseFactory: '@nyholm.psr7.httplug_factory' + Http\Message\StreamFactory: '@nyholm.psr7.httplug_factory' + Http\Message\UriFactory: '@nyholm.psr7.httplug_factory' + + nyholm.psr7.psr17_factory: + class: Nyholm\Psr7\Factory\Psr17Factory + + nyholm.psr7.httplug_factory: + class: Nyholm\Psr7\Factory\HttplugFactory diff --git a/tests/app/config/packages/prod/deprecations.yaml b/tests/app/config/packages/prod/deprecations.yaml new file mode 100644 index 000000000..920a06197 --- /dev/null +++ b/tests/app/config/packages/prod/deprecations.yaml @@ -0,0 +1,8 @@ +# As of Symfony 5.1, deprecations are logged in the dedicated "deprecation" channel when it exists +#monolog: +# channels: [deprecation] +# handlers: +# deprecation: +# type: stream +# channels: [deprecation] +# path: "%kernel.logs_dir%/%kernel.environment%.deprecations.log" diff --git a/tests/app/config/packages/prod/doctrine.yaml b/tests/app/config/packages/prod/doctrine.yaml new file mode 100644 index 000000000..084f59a05 --- /dev/null +++ b/tests/app/config/packages/prod/doctrine.yaml @@ -0,0 +1,20 @@ +doctrine: + orm: + auto_generate_proxy_classes: false + metadata_cache_driver: + type: pool + pool: doctrine.system_cache_pool + query_cache_driver: + type: pool + pool: doctrine.system_cache_pool + result_cache_driver: + type: pool + pool: doctrine.result_cache_pool + +framework: + cache: + pools: + doctrine.result_cache_pool: + adapter: cache.app + doctrine.system_cache_pool: + adapter: cache.system diff --git a/tests/app/config/packages/prod/monolog.yaml b/tests/app/config/packages/prod/monolog.yaml new file mode 100644 index 000000000..8fb26a524 --- /dev/null +++ b/tests/app/config/packages/prod/monolog.yaml @@ -0,0 +1,14 @@ +monolog: + handlers: + graylog: + type: gelf + publisher: + hostname: "%env(resolve:GELF_HOST)%" + port: "%env(resolve:GELF_PORT)%" + level: warning + channels: ['!event'] + console: + type: console + process_psr_3_messages: false + channels: ['!event', '!doctrine', '!console'] + bubble: false diff --git a/tests/app/config/packages/prod/routing.yaml b/tests/app/config/packages/prod/routing.yaml new file mode 100644 index 000000000..b3e6a0af2 --- /dev/null +++ b/tests/app/config/packages/prod/routing.yaml @@ -0,0 +1,3 @@ +framework: + router: + strict_requirements: null diff --git a/tests/app/config/packages/prod/webpack_encore.yaml b/tests/app/config/packages/prod/webpack_encore.yaml new file mode 100644 index 000000000..d0b3ba81e --- /dev/null +++ b/tests/app/config/packages/prod/webpack_encore.yaml @@ -0,0 +1,4 @@ +#webpack_encore: + # Cache the entrypoints.json (rebuild Symfony's cache when entrypoints.json changes) + # Available in version 1.2 + #cache: true diff --git a/tests/app/config/packages/ramsey_uuid_doctrine.yaml b/tests/app/config/packages/ramsey_uuid_doctrine.yaml new file mode 100644 index 000000000..cfc3036f9 --- /dev/null +++ b/tests/app/config/packages/ramsey_uuid_doctrine.yaml @@ -0,0 +1,4 @@ +doctrine: + dbal: + types: + uuid: 'Ramsey\Uuid\Doctrine\UuidType' diff --git a/tests/app/config/packages/routing.yaml b/tests/app/config/packages/routing.yaml new file mode 100644 index 000000000..b45c1cec7 --- /dev/null +++ b/tests/app/config/packages/routing.yaml @@ -0,0 +1,7 @@ +framework: + router: + utf8: true + + # Configure how to generate URLs in non-HTTP contexts, such as CLI commands. + # See https://symfony.com/doc/current/routing.html#generating-urls-in-commands + #default_uri: http://localhost diff --git a/tests/app/config/packages/security.yaml b/tests/app/config/packages/security.yaml new file mode 100644 index 000000000..f93eb04c3 --- /dev/null +++ b/tests/app/config/packages/security.yaml @@ -0,0 +1,58 @@ +security: + + # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers + providers: + + chain_provider: + chain : + providers: [in_memory, users] + in_memory: + memory: + users: + admin: { password: '%env(resolve:ADMIN_PASSWORD)%', roles: ['ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH'] } + users: + id: chill.main.user_provider + + encoders: + + Chill\MainBundle\Entity\User: + algorithm: bcrypt + Symfony\Component\Security\Core\User\User: plaintext + + firewalls: + + dev: + pattern: ^/(_(profiler|wdt)|css|images|js)/ + security: false + + default: + anonymous: ~ + provider: chain_provider + form_login: + csrf_parameter: _csrf_token + csrf_token_id: authenticate + #csrf_provider: security.csrf.token_manager + logout_on_user_change: true + logout: ~ + + # uncomment to enable impersonate mode in Chill + # https://symfony.com/doc/current/security/impersonating_user.html + # switch_user: true + + # activate different ways to authenticate + # https://symfony.com/doc/current/security.html#firewalls-authentication + + # Easy way to control access for large sections of your site + # Note: Only the *first* access control that matches will be used + access_control: + - { path: ^/(login|logout), roles: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: ^/public, roles: IS_AUTHENTICATED_ANONYMOUSLY } + # access for homepage, the homepage redirect admin to admin section + - { path: ^/$, roles: [ IS_AUTHENTICATED_REMEMBERED ] } + - { path: ^/homepage$, roles: [ IS_AUTHENTICATED_REMEMBERED ] } + # idem + - { path: ^/([a-z]+/)?homepage, roles: [ IS_AUTHENTICATED_REMEMBERED ] } + # admin section, only for admin + - { path: ^/([a-z]+/)?admin, roles: ROLE_ADMIN } + # other pages, only for regular user (no admin) + - { path: ^/, roles: ROLE_USER } diff --git a/tests/app/config/packages/sensio_framework_extra.yaml b/tests/app/config/packages/sensio_framework_extra.yaml new file mode 100644 index 000000000..1821ccc07 --- /dev/null +++ b/tests/app/config/packages/sensio_framework_extra.yaml @@ -0,0 +1,3 @@ +sensio_framework_extra: + router: + annotations: false diff --git a/tests/app/config/packages/test/chill.yaml b/tests/app/config/packages/test/chill.yaml new file mode 100644 index 000000000..a6a68dee4 --- /dev/null +++ b/tests/app/config/packages/test/chill.yaml @@ -0,0 +1,5 @@ +--- +chill_main: + available_languages: + - 'fr' + - 'en' diff --git a/tests/app/config/packages/test/framework.yaml b/tests/app/config/packages/test/framework.yaml new file mode 100644 index 000000000..23906ec36 --- /dev/null +++ b/tests/app/config/packages/test/framework.yaml @@ -0,0 +1,6 @@ +framework: + test: true + session: + storage_id: session.storage.mock_file + assets: + json_manifest_path: NULL diff --git a/tests/app/config/packages/test/mailer.yaml b/tests/app/config/packages/test/mailer.yaml new file mode 100644 index 000000000..52b99299c --- /dev/null +++ b/tests/app/config/packages/test/mailer.yaml @@ -0,0 +1,5 @@ +framework: + mailer: + dsn: 'null://null' + envelope: + sender: 'test@chill.social' diff --git a/tests/app/config/packages/test/monolog.yaml b/tests/app/config/packages/test/monolog.yaml new file mode 100644 index 000000000..fc40641dc --- /dev/null +++ b/tests/app/config/packages/test/monolog.yaml @@ -0,0 +1,12 @@ +monolog: + handlers: + main: + type: fingers_crossed + action_level: error + handler: nested + excluded_http_codes: [404, 405] + channels: ["!event"] + nested: + type: stream + path: "%kernel.logs_dir%/%kernel.environment%.log" + level: debug diff --git a/tests/app/config/packages/test/security.yaml b/tests/app/config/packages/test/security.yaml new file mode 100644 index 000000000..4ff914485 --- /dev/null +++ b/tests/app/config/packages/test/security.yaml @@ -0,0 +1,8 @@ +--- +# config/packages/test/security.yaml +security: + firewalls: + default: + http_basic: ~ + role_hierarchy: + CHILL_MASTER_ROLE: [CHILL_INHERITED_ROLE_1] diff --git a/tests/app/config/packages/test/twig.yaml b/tests/app/config/packages/test/twig.yaml new file mode 100644 index 000000000..8c6e0b401 --- /dev/null +++ b/tests/app/config/packages/test/twig.yaml @@ -0,0 +1,2 @@ +twig: + strict_variables: true diff --git a/tests/app/config/packages/test/validator.yaml b/tests/app/config/packages/test/validator.yaml new file mode 100644 index 000000000..1e5ab7880 --- /dev/null +++ b/tests/app/config/packages/test/validator.yaml @@ -0,0 +1,3 @@ +framework: + validation: + not_compromised_password: false diff --git a/tests/app/config/packages/test/webpack_encore.yaml b/tests/app/config/packages/test/webpack_encore.yaml new file mode 100644 index 000000000..9ad967357 --- /dev/null +++ b/tests/app/config/packages/test/webpack_encore.yaml @@ -0,0 +1,2 @@ +webpack_encore: + strict_mode: false diff --git a/tests/app/config/packages/translation.yaml b/tests/app/config/packages/translation.yaml new file mode 100644 index 000000000..58f048218 --- /dev/null +++ b/tests/app/config/packages/translation.yaml @@ -0,0 +1,7 @@ +framework: + + default_locale: '%env(resolve:LOCALE)%' + + translator: + default_path: '%kernel.project_dir%/translations' + fallbacks: [ '%env(resolve:LOCALE)%' ] diff --git a/tests/app/config/packages/twig.yaml b/tests/app/config/packages/twig.yaml new file mode 100644 index 000000000..02d862922 --- /dev/null +++ b/tests/app/config/packages/twig.yaml @@ -0,0 +1,17 @@ +twig: + default_path: '%kernel.project_dir%/templates' + debug: '%kernel.debug%' + strict_variables: '%kernel.debug%' + exception_controller: null + + ## In Symfony 5, bootstrap_5 theme is supported. But not yet in sf4 !! + # see sf5 https://symfony.com/doc/current/form/form_themes.html + # see sf4 https://symfony.com/doc/4.4/form/form_themes.html + # + # While waiting for the upgrade, we get the form theme file + # (https://github.com/symfony/symfony/tree/5.4/src/Symfony/Bridge/Twig/Resources/views/Form), + # put it in ChillMainBundle/Resources/views/Form/bootstrap5/ + # and adapt it lightly. + # + form_themes: ['@ChillMain/Form/bootstrap5/bootstrap_5_horizontal_layout.html.twig'] + #form_themes: ['bootstrap_5_horizontal_layout.html.twig'] diff --git a/tests/app/config/packages/validator.yaml b/tests/app/config/packages/validator.yaml new file mode 100644 index 000000000..350786a13 --- /dev/null +++ b/tests/app/config/packages/validator.yaml @@ -0,0 +1,8 @@ +framework: + validation: + email_validation_mode: html5 + + # Enables validator auto-mapping support. + # For instance, basic validation constraints will be inferred from Doctrine's metadata. + #auto_mapping: + # App\Entity\: [] diff --git a/tests/app/config/packages/webpack_encore.yaml b/tests/app/config/packages/webpack_encore.yaml new file mode 100644 index 000000000..709531205 --- /dev/null +++ b/tests/app/config/packages/webpack_encore.yaml @@ -0,0 +1,33 @@ +--- +webpack_encore: + # The path where Encore is building the assets - i.e. Encore.setOutputPath() + output_path: '%kernel.project_dir%/public/build' + + # If multiple builds are defined (as shown below), you can disable the default build: + # output_path: false + + # Set attributes that will be rendered on all script and link tags + script_attributes: + defer: true + # link_attributes: + # + + # If using Encore.enableIntegrityHashes() and need the crossorigin attribute (default: false, or use 'anonymous' or 'use-credentials') + # crossorigin: 'anonymous' + + # Preload all rendered script and link tags automatically via the HTTP/2 Link header + # preload: true + + # Throw an exception if the entrypoints.json file is missing or an entry is missing from the data + # strict_mode: false + + # If you have multiple builds: + # builds: + # pass "frontend" as the 3rg arg to the Twig functions + # {{ encore_entry_script_tags('entry1', null, 'frontend') }} + + # frontend: '%kernel.project_dir%/public/frontend/build' + + # Cache the entrypoints.json (rebuild Symfony's cache when entrypoints.json changes) + # Put in config/packages/prod/webpack_encore.yaml + # cache: true diff --git a/tests/app/config/packages/workflow.yaml b/tests/app/config/packages/workflow.yaml new file mode 100644 index 000000000..855df59cd --- /dev/null +++ b/tests/app/config/packages/workflow.yaml @@ -0,0 +1,2 @@ +framework: + workflows: null diff --git a/tests/app/config/preload.php b/tests/app/config/preload.php new file mode 100644 index 000000000..064bdcd6a --- /dev/null +++ b/tests/app/config/preload.php @@ -0,0 +1,9 @@ +bootEnv(dirname(__DIR__).'/.env'); +} diff --git a/tests/console b/tests/console new file mode 100755 index 000000000..264e064a1 --- /dev/null +++ b/tests/console @@ -0,0 +1,42 @@ +#!/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__).'/tests/app/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);