diff --git a/doc/tasks/phpunit.md b/doc/tasks/phpunit.md index 82f0fd0bf..b930b65c4 100644 --- a/doc/tasks/phpunit.md +++ b/doc/tasks/phpunit.md @@ -9,6 +9,7 @@ parameters: tasks: phpunit: config_file: ~ + testsuite: ~ group: [] always_execute: false ``` @@ -21,6 +22,15 @@ If your phpunit.xml file is located at an exotic location, you can specify your This option is set to `null` by default. This means that `phpunit.xml` or `phpunit.xml.dist` are automatically loaded if one of them exist in the current directory. + +**testsuite** + +*Default: null + +If you wish to only run tests from a certain Suite. +`testsuite: unit` + + **group** *Default: array()* @@ -28,8 +38,10 @@ This means that `phpunit.xml` or `phpunit.xml.dist` are automatically loaded if If you wish to only run tests from a certain Group. `group: [fast,quick,small]` + **always_execute** *Default: false* Always run the whole test suite, even if no PHP files were changed. + diff --git a/spec/Task/PhpunitSpec.php b/spec/Task/PhpunitSpec.php index 1499ba699..f7bea3f6f 100644 --- a/spec/Task/PhpunitSpec.php +++ b/spec/Task/PhpunitSpec.php @@ -41,6 +41,7 @@ function it_should_have_configurable_options() $options = $this->getConfigurableOptions(); $options->shouldBeAnInstanceOf(OptionsResolver::class); $options->getDefinedOptions()->shouldContain('config_file'); + $options->getDefinedOptions()->shouldContain('testsuite'); $options->getDefinedOptions()->shouldContain('group'); $options->getDefinedOptions()->shouldContain('always_execute'); } diff --git a/src/Task/Phpunit.php b/src/Task/Phpunit.php index 21f1c4c51..ca2141041 100644 --- a/src/Task/Phpunit.php +++ b/src/Task/Phpunit.php @@ -29,11 +29,13 @@ public function getConfigurableOptions() $resolver = new OptionsResolver(); $resolver->setDefaults([ 'config_file' => null, + 'testsuite' => null, 'group' => [], 'always_execute' => false, ]); $resolver->addAllowedTypes('config_file', ['null', 'string']); + $resolver->addAllowedTypes('testsuite', ['null', 'string']); $resolver->addAllowedTypes('group', ['array']); $resolver->addAllowedTypes('always_execute', ['bool']); @@ -62,6 +64,7 @@ public function run(ContextInterface $context) $arguments = $this->processBuilder->createArgumentsForCommand('phpunit'); $arguments->addOptionalArgument('--configuration=%s', $config['config_file']); + $arguments->addOptionalArgument('--testsuite=%s', $config['testsuite']); $arguments->addOptionalCommaSeparatedArgument('--group=%s', $config['group']); $process = $this->processBuilder->buildProcess($arguments);