From fdb5ec67332389a8661e9d0f101a0710c906a620 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 4 Jul 2017 16:15:20 +0200 Subject: [PATCH] new architecture for tests --- .gitlab-ci.yml | 6 ++--- .../test}/Fixtures/App/app/AppKernel.php | 0 .../App/app/DoctrineMigrations/.gitignore | 0 .../CustomField/simple_form_render.html.twig | 0 .../App/app/Resources/views/base.html.twig | 0 .../test}/Fixtures/App/app/autoload.php | 6 ++--- .../test}/Fixtures/App/app/config/config.yml | 0 .../Fixtures/App/app/config/config_dev.yml | 0 .../Fixtures/App/app/config/config_test.yml | 0 ...mizable_entities_test_not_empty_config.yml | 0 .../App/app/config/parameters.gitlab-ci.yml | 0 .../App/app/config/parameters.yml.dist | 0 .../test}/Fixtures/App/app/config/routing.yml | 0 .../test/Fixtures/App/app/console | 22 ++++++++++++------- .../test}/Fixtures/App/logs/empty | 0 .../test}/Fixtures/App/web/app_dev.php | 0 Tests/CustomFieldTestHelper.php | 3 ++- composer.json | 5 ++++- console.sh | 1 - phpunit.xml.dist | 8 +++---- 20 files changed, 29 insertions(+), 22 deletions(-) rename {Tests => Resources/test}/Fixtures/App/app/AppKernel.php (100%) rename {Tests => Resources/test}/Fixtures/App/app/DoctrineMigrations/.gitignore (100%) rename {Tests => Resources/test}/Fixtures/App/app/Resources/views/CustomField/simple_form_render.html.twig (100%) rename {Tests => Resources/test}/Fixtures/App/app/Resources/views/base.html.twig (100%) rename {Tests => Resources/test}/Fixtures/App/app/autoload.php (64%) rename {Tests => Resources/test}/Fixtures/App/app/config/config.yml (100%) rename {Tests => Resources/test}/Fixtures/App/app/config/config_dev.yml (100%) rename {Tests => Resources/test}/Fixtures/App/app/config/config_test.yml (100%) rename {Tests => Resources/test}/Fixtures/App/app/config/config_test_customizable_entities_test_not_empty_config.yml (100%) rename {Tests => Resources/test}/Fixtures/App/app/config/parameters.gitlab-ci.yml (100%) rename {Tests => Resources/test}/Fixtures/App/app/config/parameters.yml.dist (100%) rename {Tests => Resources/test}/Fixtures/App/app/config/routing.yml (100%) rename Tests/Fixtures/App/app/console.php => Resources/test/Fixtures/App/app/console (75%) rename {Tests => Resources/test}/Fixtures/App/logs/empty (100%) rename {Tests => Resources/test}/Fixtures/App/web/app_dev.php (100%) delete mode 100755 console.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c8b1fbf92..57aa08dad 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,9 +8,9 @@ - if [ $CI_BUILD_REF_NAME = "1.0" ] ; then export COMPOSER_ROOT_VERSION="1.0-dev"; else export COMPOSER_ROOT_VERSION="dev-master"; fi - php -d memory_limit=-1 /usr/local/bin/composer install --no-interaction - cp Tests/Fixtures/App/app/config/parameters.gitlab-ci.yml Tests/Fixtures/App/app/config/parameters.yml - - ./console.sh --env=test cache:warmup - - ./console.sh doctrine:migrations:migrate --env=test --no-interaction - - ./console.sh doctrine:fixtures:load --env=test --no-interaction + - php Resources/test/Fixtures/App/app/console --env=test cache:warmup + - php Resources/test/Fixtures/App/app/console doctrine:migrations:migrate --env=test --no-interaction + - php Resources/test/Fixtures/App/app/console doctrine:fixtures:load --env=test --no-interaction stages: - test diff --git a/Tests/Fixtures/App/app/AppKernel.php b/Resources/test/Fixtures/App/app/AppKernel.php similarity index 100% rename from Tests/Fixtures/App/app/AppKernel.php rename to Resources/test/Fixtures/App/app/AppKernel.php diff --git a/Tests/Fixtures/App/app/DoctrineMigrations/.gitignore b/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore similarity index 100% rename from Tests/Fixtures/App/app/DoctrineMigrations/.gitignore rename to Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore diff --git a/Tests/Fixtures/App/app/Resources/views/CustomField/simple_form_render.html.twig b/Resources/test/Fixtures/App/app/Resources/views/CustomField/simple_form_render.html.twig similarity index 100% rename from Tests/Fixtures/App/app/Resources/views/CustomField/simple_form_render.html.twig rename to Resources/test/Fixtures/App/app/Resources/views/CustomField/simple_form_render.html.twig diff --git a/Tests/Fixtures/App/app/Resources/views/base.html.twig b/Resources/test/Fixtures/App/app/Resources/views/base.html.twig similarity index 100% rename from Tests/Fixtures/App/app/Resources/views/base.html.twig rename to Resources/test/Fixtures/App/app/Resources/views/base.html.twig diff --git a/Tests/Fixtures/App/app/autoload.php b/Resources/test/Fixtures/App/app/autoload.php similarity index 64% rename from Tests/Fixtures/App/app/autoload.php rename to Resources/test/Fixtures/App/app/autoload.php index 57a507088..39dc0e2ba 100644 --- a/Tests/Fixtures/App/app/autoload.php +++ b/Resources/test/Fixtures/App/app/autoload.php @@ -3,10 +3,8 @@ use Doctrine\Common\Annotations\AnnotationRegistry; use Composer\Autoload\ClassLoader; -/** - * @var ClassLoader $loader - */ -$loader = require __DIR__.'/../../../../vendor/autoload.php'; +/** @var ClassLoader $loader */ +$loader = require __DIR__.'/../../../../../vendor/autoload.php'; AnnotationRegistry::registerLoader(array($loader, 'loadClass')); diff --git a/Tests/Fixtures/App/app/config/config.yml b/Resources/test/Fixtures/App/app/config/config.yml similarity index 100% rename from Tests/Fixtures/App/app/config/config.yml rename to Resources/test/Fixtures/App/app/config/config.yml diff --git a/Tests/Fixtures/App/app/config/config_dev.yml b/Resources/test/Fixtures/App/app/config/config_dev.yml similarity index 100% rename from Tests/Fixtures/App/app/config/config_dev.yml rename to Resources/test/Fixtures/App/app/config/config_dev.yml diff --git a/Tests/Fixtures/App/app/config/config_test.yml b/Resources/test/Fixtures/App/app/config/config_test.yml similarity index 100% rename from Tests/Fixtures/App/app/config/config_test.yml rename to Resources/test/Fixtures/App/app/config/config_test.yml diff --git a/Tests/Fixtures/App/app/config/config_test_customizable_entities_test_not_empty_config.yml b/Resources/test/Fixtures/App/app/config/config_test_customizable_entities_test_not_empty_config.yml similarity index 100% rename from Tests/Fixtures/App/app/config/config_test_customizable_entities_test_not_empty_config.yml rename to Resources/test/Fixtures/App/app/config/config_test_customizable_entities_test_not_empty_config.yml diff --git a/Tests/Fixtures/App/app/config/parameters.gitlab-ci.yml b/Resources/test/Fixtures/App/app/config/parameters.gitlab-ci.yml similarity index 100% rename from Tests/Fixtures/App/app/config/parameters.gitlab-ci.yml rename to Resources/test/Fixtures/App/app/config/parameters.gitlab-ci.yml diff --git a/Tests/Fixtures/App/app/config/parameters.yml.dist b/Resources/test/Fixtures/App/app/config/parameters.yml.dist similarity index 100% rename from Tests/Fixtures/App/app/config/parameters.yml.dist rename to Resources/test/Fixtures/App/app/config/parameters.yml.dist diff --git a/Tests/Fixtures/App/app/config/routing.yml b/Resources/test/Fixtures/App/app/config/routing.yml similarity index 100% rename from Tests/Fixtures/App/app/config/routing.yml rename to Resources/test/Fixtures/App/app/config/routing.yml diff --git a/Tests/Fixtures/App/app/console.php b/Resources/test/Fixtures/App/app/console similarity index 75% rename from Tests/Fixtures/App/app/console.php rename to Resources/test/Fixtures/App/app/console index cf7efc348..f6fd8e5ef 100644 --- a/Tests/Fixtures/App/app/console.php +++ b/Resources/test/Fixtures/App/app/console @@ -1,21 +1,27 @@ #!/usr/bin/env php getParameterOption(array('--env', '-e'), getenv('SYMFONY_ENV') ?: 'dev'); $debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod'; + if ($debug) { -Debug::enable(); + Debug::enable(); } + $kernel = new AppKernel($env, $debug); $application = new Application($kernel); $application->run($input); - diff --git a/Tests/Fixtures/App/logs/empty b/Resources/test/Fixtures/App/logs/empty similarity index 100% rename from Tests/Fixtures/App/logs/empty rename to Resources/test/Fixtures/App/logs/empty diff --git a/Tests/Fixtures/App/web/app_dev.php b/Resources/test/Fixtures/App/web/app_dev.php similarity index 100% rename from Tests/Fixtures/App/web/app_dev.php rename to Resources/test/Fixtures/App/web/app_dev.php diff --git a/Tests/CustomFieldTestHelper.php b/Tests/CustomFieldTestHelper.php index 6c38a447b..3d4c58fe0 100644 --- a/Tests/CustomFieldTestHelper.php +++ b/Tests/CustomFieldTestHelper.php @@ -68,7 +68,8 @@ trait CustomFieldTestHelper ->getForm(); $kernel->getContainer()->get('twig.loader') - ->addPath(__DIR__.'/Fixtures/App/app/Resources/views/', $namespace = 'test'); + ->addPath($kernel->getContainer()->getParameter('kernel.root_dir'). + '/Resources/views/', $namespace = 'test'); $content = $kernel ->getContainer()->get('templating') diff --git a/composer.json b/composer.json index e1ba8518f..06fd2dd2d 100644 --- a/composer.json +++ b/composer.json @@ -8,6 +8,9 @@ "autoload": { "psr-4": { "Chill\\CustomFieldsBundle\\": "" } }, + "autoload-dev": { + "classmap": [ "Resources/test/Fixtures/App/app/AppKernel.php" ] + }, "authors" : [ { "name": "Champs-Libres", @@ -52,6 +55,6 @@ }, "extra": { "symfony-app-dir": "Tests/Fixtures/App/app", - "app-migrations-dir": "Tests/Fixtures/App/app/DoctrineMigrations" + "app-migrations-dir": "Resources/test/Fixtures/App/app/DoctrineMigrations" } } diff --git a/console.sh b/console.sh deleted file mode 100755 index c2d0ec406..000000000 --- a/console.sh +++ /dev/null @@ -1 +0,0 @@ -php Tests/Fixtures/App/app/console.php $1 $2 $3 $4 $5 diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 309d251a0..85bbef1f9 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,9 +1,9 @@ - + - + ./Tests @@ -18,7 +18,7 @@ - + - \ No newline at end of file +