new architecture for tests

This commit is contained in:
Julien Fastré 2017-07-04 16:15:20 +02:00
parent a9da9acdd2
commit fdb5ec6733
20 changed files with 29 additions and 22 deletions

View File

@ -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 - 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 - 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 - cp Tests/Fixtures/App/app/config/parameters.gitlab-ci.yml Tests/Fixtures/App/app/config/parameters.yml
- ./console.sh --env=test cache:warmup - php Resources/test/Fixtures/App/app/console --env=test cache:warmup
- ./console.sh doctrine:migrations:migrate --env=test --no-interaction - php Resources/test/Fixtures/App/app/console doctrine:migrations:migrate --env=test --no-interaction
- ./console.sh doctrine:fixtures:load --env=test --no-interaction - php Resources/test/Fixtures/App/app/console doctrine:fixtures:load --env=test --no-interaction
stages: stages:
- test - test

View File

@ -3,10 +3,8 @@
use Doctrine\Common\Annotations\AnnotationRegistry; use Doctrine\Common\Annotations\AnnotationRegistry;
use Composer\Autoload\ClassLoader; use Composer\Autoload\ClassLoader;
/** /** @var ClassLoader $loader */
* @var ClassLoader $loader $loader = require __DIR__.'/../../../../../vendor/autoload.php';
*/
$loader = require __DIR__.'/../../../../vendor/autoload.php';
AnnotationRegistry::registerLoader(array($loader, 'loadClass')); AnnotationRegistry::registerLoader(array($loader, 'loadClass'));

View File

@ -1,21 +1,27 @@
#!/usr/bin/env php #!/usr/bin/env php
<?php <?php
// if you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
//umask(0000);
set_time_limit(0);
require_once __DIR__.'/../../../bootstrap.php';
require_once __DIR__.'/AppKernel.php';
use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput; use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Debug\Debug; use Symfony\Component\Debug\Debug;
// if you don't want to setup permissions the proper way, just uncomment the following PHP line
// read https://symfony.com/doc/current/setup.html#checking-symfony-application-configuration-and-setup
// for more information
//umask(0000);
set_time_limit(0);
require __DIR__.'/autoload.php';
$input = new ArgvInput(); $input = new ArgvInput();
$env = $input->getParameterOption(array('--env', '-e'), getenv('SYMFONY_ENV') ?: 'dev'); $env = $input->getParameterOption(array('--env', '-e'), getenv('SYMFONY_ENV') ?: 'dev');
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod'; $debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod';
if ($debug) { if ($debug) {
Debug::enable(); Debug::enable();
} }
$kernel = new AppKernel($env, $debug); $kernel = new AppKernel($env, $debug);
$application = new Application($kernel); $application = new Application($kernel);
$application->run($input); $application->run($input);

View File

@ -68,7 +68,8 @@ trait CustomFieldTestHelper
->getForm(); ->getForm();
$kernel->getContainer()->get('twig.loader') $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 $content = $kernel
->getContainer()->get('templating') ->getContainer()->get('templating')

View File

@ -8,6 +8,9 @@
"autoload": { "autoload": {
"psr-4": { "Chill\\CustomFieldsBundle\\": "" } "psr-4": { "Chill\\CustomFieldsBundle\\": "" }
}, },
"autoload-dev": {
"classmap": [ "Resources/test/Fixtures/App/app/AppKernel.php" ]
},
"authors" : [ "authors" : [
{ {
"name": "Champs-Libres", "name": "Champs-Libres",
@ -52,6 +55,6 @@
}, },
"extra": { "extra": {
"symfony-app-dir": "Tests/Fixtures/App/app", "symfony-app-dir": "Tests/Fixtures/App/app",
"app-migrations-dir": "Tests/Fixtures/App/app/DoctrineMigrations" "app-migrations-dir": "Resources/test/Fixtures/App/app/DoctrineMigrations"
} }
} }

View File

@ -1 +0,0 @@
php Tests/Fixtures/App/app/console.php $1 $2 $3 $4 $5

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./Tests/bootstrap.php" colors="true"> <phpunit bootstrap="./Resources/test/Fixtures/App/app/autoload.php" colors="true">
<!-- the file "./Tests/boostrap.php" will be created on the next step --> <!-- the file "./Tests/boostrap.php" will be created on the next step -->
<testsuites> <testsuites>
<testsuite name="ChillMain test suite"> <testsuite name="ChillCustomField test suite">
<directory suffix="Test.php">./Tests</directory> <directory suffix="Test.php">./Tests</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
@ -18,7 +18,7 @@
</whitelist> </whitelist>
</filter> </filter>
<php> <php>
<server name="KERNEL_DIR" value="/Tests/Fixtures/App/app/" /> <server name="KERNEL_DIR" value="Resources/test/Fixtures/App/app/" />
<ini name="error_reporting" value="-16385"/> <ini name="error_reporting" value="-16385"/>
</php> </php>
</phpunit> </phpunit>