Browse Source

Clean up Robofile

labels
J. King 6 years ago
parent
commit
b725fddc6c
  1. 37
      RoboFile.php

37
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();
}
}

Loading…
Cancel
Save