From a09fb5c6ad830d04a8f83e872ab422f438bb8354 Mon Sep 17 00:00:00 2001 From: Alexis Lefebvre Date: Sun, 9 Feb 2020 18:33:11 +0100 Subject: [PATCH] =?UTF-8?q?Remove=20=E2=80=9Cparatest:run=E2=80=9D=20comma?= =?UTF-8?q?nd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 9 +- README.md | 1 - composer.json | 3 +- doc/installation.md | 2 +- doc/paratest.md | 65 -------------- src/Command/RunParatestCommand.php | 89 ------------------- src/DependencyInjection/Configuration.php | 11 --- .../LiipFunctionalTestExtension.php | 1 - src/Resources/config/commands.xml | 11 --- tests/AppConfig/config.yml | 3 - tests/Command/ParatestCommandTest.php | 62 ------------- .../ConfigurationConfigTest.php | 2 - .../DependencyInjection/ConfigurationTest.php | 2 - 13 files changed, 9 insertions(+), 252 deletions(-) delete mode 100644 doc/paratest.md delete mode 100644 src/Command/RunParatestCommand.php delete mode 100644 src/Resources/config/commands.xml delete mode 100644 tests/Command/ParatestCommandTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b7d8b84..0b7c2b07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Changelog -## 3.0 [TBA] +## 4.0 + +### Removed + * Drop support of `paratest:run` + +## 3.0 This new major version introduces a number of breaking changes; see the [upgrade guide](UPGRADE-3.0.md) for more details. ### Added @@ -14,7 +19,7 @@ This new major version introduces a number of breaking changes; see the [upgrade ### Removed * Removed fixtures loading in favor of https://github.com/liip/LiipTestFixturesBundle -## 2.0 [TBA] +## 2.0 This new major version introduces a number of breaking changes; see the [upgrade guide](UPGRADE-2.0.md) for more details. ### Added diff --git a/README.md b/README.md index 6f96bfc1..7b3f1aa1 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,6 @@ Documentation * [Caveats](doc/caveats.md) To run tests in parallel: -* [Paratest](doc/paratest.md) * [Fastest](doc/fastest.md) [Travis Master]: https://travis-ci.org/liip/LiipFunctionalTestBundle diff --git a/composer.json b/composer.json index bd0f5fd4..eb87c04a 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,6 @@ "symfony/framework-bundle": "4.3.0" }, "suggest": { - "brianium/paratest": "Required when using paratest to parallelize tests", "liip/test-fixtures-bundle": "Efficient loading of Doctrine fixtures in functional test-cases for Symfony applications" }, "autoload": { @@ -51,7 +50,7 @@ }, "extra": { "branch-alias": { - "dev-master": "3.x-dev" + "dev-master": "4.x-dev" } } } diff --git a/doc/installation.md b/doc/installation.md index 332ce5dd..58cdcf1e 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -12,7 +12,7 @@ Installation following command to download the latest stable version of this bundle: ```bash - $ composer require --dev liip/functional-test-bundle:^3.0.0 + $ composer require --dev liip/functional-test-bundle:^4.0.0 ``` This command requires you to have Composer installed globally, as explained diff --git a/doc/paratest.md b/doc/paratest.md deleted file mode 100644 index e196826c..00000000 --- a/doc/paratest.md +++ /dev/null @@ -1,65 +0,0 @@ -Introduction -============ - -ParaTest is PHPUnit Extension allowing to run unit test in parallel, it strongly reduces unit test time consuming. -To run test with paratest, you will need to download ParaTest package through composer and follow the different setup steps. - -Installation -============ - -1) Add ParaTest package - -To install with composer, simply run `composer require brianium/paratest` - -2) Add the connection factory to your config_test.yml - -Since Paratest run your tests through multiple process, we need to feed it with seperate data. -That's why we need to first create test schema, load fixtures, then duplicate the test schema for each created processes. - -In order to do this, simply add the following to your config_test.yml - -```yaml -parameters: - doctrine.dbal.connection_factory.class: Liip\FunctionalTestBundle\Factory\ConnectionFactory -``` - -then rename your default test dbname with this: - -```yaml -doctrine: - dbal: - default_connection: default - connections: - default: - driver: pdo_sqlite - user: test - path: "%kernel.cache_dir%/__DBNAME__.db" - memory: false -``` - -The connection factory will replace __DBNAME__ with it s own unique ID depending of the process unique ID which load it. - -3) Run the command, and don't leave for a coffee, it s already finished. - -Then run `php app/console paratest:run` - -( Run in test environnement by default ) - - - -Options -======= - -You can modify process amount and phpunit location with the following: - -```yaml -# app/config/config_test.yml -liip_functional_test: - paratest: - process:5 #default is 5 - phpunit:'./bin/phpunit' #default is ./bin/phpunit -``` -Ensure that the framework is using the filesystem for session storage: - - -Concerning Phpunit settings, Paratest will read phpunit.xml defined in ./app by default diff --git a/src/Command/RunParatestCommand.php b/src/Command/RunParatestCommand.php deleted file mode 100644 index 99cf79ba..00000000 --- a/src/Command/RunParatestCommand.php +++ /dev/null @@ -1,89 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Liip\FunctionalTestBundle\Command; - -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; -use Symfony\Component\DependencyInjection\ContainerAwareTrait; -use Symfony\Component\Process\Process; - -/** - * Command used to update the project. - */ -class RunParatestCommand extends Command implements ContainerAwareInterface -{ - use ContainerAwareTrait; - - private $output; - - private $process; - - private $testDbPath; - - private $phpunit; - - /** - * Configuration of the command. - */ - protected function configure(): void - { - $this - ->setName('paratest:run') - ->setDescription('Run phpunit tests with multiple processes') - // Pass arguments from this command "paratest:run" to the paratest command. - ->addArgument('options', InputArgument::OPTIONAL, 'Options') - ; - } - - protected function prepare(): void - { - $this->phpunit = $this->container->getParameter('liip_functional_test.paratest.phpunit'); - $this->process = $this->container->getParameter('liip_functional_test.paratest.process'); - } - - /** - * Content of the command. - * - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $this->output = $output; - $this->prepare(); - if (true !== is_file('vendor/bin/paratest')) { - $this->output->writeln('Error : Install paratest first'); - - return 1; - } else { - $this->output->writeln('Done...Running test.'); - $runProcess = new Process(['vendor/bin/paratest '. - '-c phpunit.xml.dist '. - '--phpunit '.$this->phpunit.' '. - '-p '.$this->process.' '. - $input->getArgument('options'), - ]); - $runProcess->run(function ($type, $buffer) use ($output): void { - $output->write($buffer); - }); - - return 0; - } - } -} diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 67ad46cb..b9f8637a 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -58,17 +58,6 @@ public function getConfigTreeBuilder(): TreeBuilder ->end() ->end() ->end() - ->arrayNode('paratest') - ->addDefaultsIfNotSet() - ->children() - ->scalarNode('process') - ->defaultValue(5) - ->end() - ->scalarNode('phpunit') - ->defaultValue('./bin/phpunit') - ->end() - ->end() - ->end() ->end() ; diff --git a/src/DependencyInjection/LiipFunctionalTestExtension.php b/src/DependencyInjection/LiipFunctionalTestExtension.php index 218f88c7..f4d1d5f4 100644 --- a/src/DependencyInjection/LiipFunctionalTestExtension.php +++ b/src/DependencyInjection/LiipFunctionalTestExtension.php @@ -31,7 +31,6 @@ public function load(array $configs, ContainerBuilder $container): void $config = $this->processConfiguration(new Configuration(), $configs); $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); - $loader->load('commands.xml'); $loader->load('functional_test.xml'); if (interface_exists('Symfony\Component\Validator\Validator\ValidatorInterface')) { diff --git a/src/Resources/config/commands.xml b/src/Resources/config/commands.xml deleted file mode 100644 index c2d60030..00000000 --- a/src/Resources/config/commands.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - diff --git a/tests/AppConfig/config.yml b/tests/AppConfig/config.yml index 60ae0691..f10ccd04 100644 --- a/tests/AppConfig/config.yml +++ b/tests/AppConfig/config.yml @@ -14,6 +14,3 @@ liip_functional_test: authentication: username: "foobar" password: "12341234" - paratest: - process: 3 - phpunit: 'vendor/bin/phpunit' diff --git a/tests/Command/ParatestCommandTest.php b/tests/Command/ParatestCommandTest.php deleted file mode 100644 index e2e26b0d..00000000 --- a/tests/Command/ParatestCommandTest.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Liip\Acme\Tests\Command; - -use Liip\FunctionalTestBundle\Test\WebTestCase; -use Liip\Acme\Tests\AppConfig\AppConfigKernel; -use Symfony\Bundle\FrameworkBundle\Console\Application; - -/** - * Use Tests/AppConfig/AppConfigKernel.php instead of - * Tests/App/AppKernel.php. - * So it must be loaded in a separate process. - * - * @runTestsInSeparateProcesses - * @preserveGlobalState disabled - */ -class ParatestCommandTest extends WebTestCase -{ - protected static function getKernelClass() - { - return AppConfigKernel::class; - } - - /** - * Test paratestCommand. - */ - public function testParatest(): void - { - $this->markTestSkipped('Fix compatibility of paratest and Symfony 5'); - - $kernel = $this->getContainer()->get('kernel'); - $application = new Application($kernel); - $application->setAutoExit(false); - - $this->isDecorated(false); - $content = $this->runCommand('paratest:run', [ - // Only launch one test class, launching more classes may start an infinite loop. - 'options' => 'tests/Test/WebTestCaseTest.php', - ])->getDisplay(); - - $this->assertStringContainsString('Running phpunit in 3 processes with vendor/bin/phpunit', $content); - $this->assertStringContainsString('Initial schema created', $content); - $this->assertStringNotContainsString('Error : Install paratest first', $content); - $this->assertStringContainsString('Done...Running test.', $content); - - $this->assertStringContainsString( - 'OK (17 tests, 45 assertions)', - $content - ); - } -} diff --git a/tests/DependencyInjection/ConfigurationConfigTest.php b/tests/DependencyInjection/ConfigurationConfigTest.php index 80e71d51..dceb2d98 100644 --- a/tests/DependencyInjection/ConfigurationConfigTest.php +++ b/tests/DependencyInjection/ConfigurationConfigTest.php @@ -44,8 +44,6 @@ public function parametersProvider(): array ['query.max_query_count', 1], ['authentication.username', 'foobar'], ['authentication.password', '12341234'], - ['paratest.process', 3], - ['paratest.phpunit', 'vendor/bin/phpunit'], ]; } } diff --git a/tests/DependencyInjection/ConfigurationTest.php b/tests/DependencyInjection/ConfigurationTest.php index d29b1532..aad77eb7 100644 --- a/tests/DependencyInjection/ConfigurationTest.php +++ b/tests/DependencyInjection/ConfigurationTest.php @@ -60,8 +60,6 @@ public function parametersProvider(): array ['query.max_query_count', null], ['authentication.username', ''], ['authentication.password', ''], - ['paratest.process', 5], - ['paratest.phpunit', './bin/phpunit'], ]; } }