From b725fddc6c01c6efb22e07dcdecf1164923410c0 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Tue, 24 Apr 2018 14:54:50 -0400 Subject: [PATCH] Clean up Robofile --- RoboFile.php | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/RoboFile.php b/RoboFile.php index c6eb0ed..89773a7 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -12,7 +12,7 @@ class RoboFile extends \Robo\Tasks { const BASE_TEST = self::BASE."tests".\DIRECTORY_SEPARATOR; /** - * Runs the full test suite + * Runs the typical test suite * * Arguments passed to the task are passed on to PHPUnit. Thus one may, for * example, run the following command and get the expected results: @@ -22,18 +22,17 @@ class RoboFile extends \Robo\Tasks { * Please see the PHPUnit documentation for available options. */ public function test(array $args): Result { - $execpath = realpath(self::BASE."vendor-bin/phpunit/vendor/phpunit/phpunit/phpunit"); - $confpath = realpath(self::BASE_TEST."phpunit.xml"); - return $this->taskExec("php")->arg($execpath)->option("-c", $confpath)->args($args)->run(); + return $this->runTests("php", "typical", $args); } /** * Runs the full test suite * - * This is an alias of the "test" task. + * This includes pedantic tests which may help to identify problems. + * See help for the "test" task for more details. */ public function testFull(array $args): Result { - return $this->test($args); + return $this->runTests("php", "full", $args); } /** @@ -42,7 +41,7 @@ class RoboFile extends \Robo\Tasks { * See help for the "test" task for more details. */ public function testQuick(array $args): Result { - return $this->test(array_merge(["--exclude-group", "slow,optional"], $args)); + return $this->runTests("php", "quick", $args); } /** Produces a code coverage report @@ -58,9 +57,7 @@ class RoboFile extends \Robo\Tasks { public function coverage(array $args): Result { // run tests with code coverage reporting enabled $exec = $this->findCoverageEngine(); - $execpath = realpath(self::BASE."vendor-bin/phpunit/vendor/phpunit/phpunit/phpunit"); - $confpath = realpath(self::BASE_TEST."phpunit.xml"); - return $this->taskExec($exec)->arg($execpath)->option("-c", $confpath)->option("--coverage-html", self::BASE_TEST."coverage")->args($args)->run(); + return $this->runTests($exec, "typical", array_merge(["--coverage-html", self::BASE_TEST."coverage"], $args)); } protected function findCoverageEngine(): string { @@ -73,4 +70,24 @@ class RoboFile extends \Robo\Tasks { return "php"; } } + + protected function runTests(string $executor, string $set, array $args) : Result { + switch ($set) { + case "typical": + $set = ["--exclude-group", "optional"]; + break; + case "quick": + $set = ["--exclude-group", "optional,slow"]; + break; + case "full": + $set = []; + break; + default: + throw new \Exception; + } + $execpath = realpath(self::BASE."vendor-bin/phpunit/vendor/phpunit/phpunit/phpunit"); + $confpath = realpath(self::BASE_TEST."phpunit.xml"); + return $this->taskExec($executor)->arg($execpath)->option("-c", $confpath)->args(array_merge($set,$args))->run(); + + } }