|
@ -12,7 +12,7 @@ class RoboFile extends \Robo\Tasks { |
|
|
const BASE_TEST = self::BASE."tests".\DIRECTORY_SEPARATOR; |
|
|
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 |
|
|
* Arguments passed to the task are passed on to PHPUnit. Thus one may, for |
|
|
* example, run the following command and get the expected results: |
|
|
* 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. |
|
|
* Please see the PHPUnit documentation for available options. |
|
|
*/ |
|
|
*/ |
|
|
public function test(array $args): Result { |
|
|
public function test(array $args): Result { |
|
|
$execpath = realpath(self::BASE."vendor-bin/phpunit/vendor/phpunit/phpunit/phpunit"); |
|
|
return $this->runTests("php", "typical", $args); |
|
|
$confpath = realpath(self::BASE_TEST."phpunit.xml"); |
|
|
|
|
|
return $this->taskExec("php")->arg($execpath)->option("-c", $confpath)->args($args)->run(); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Runs the full test suite |
|
|
* 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 { |
|
|
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. |
|
|
* See help for the "test" task for more details. |
|
|
*/ |
|
|
*/ |
|
|
public function testQuick(array $args): Result { |
|
|
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 |
|
|
/** Produces a code coverage report |
|
@ -58,9 +57,7 @@ class RoboFile extends \Robo\Tasks { |
|
|
public function coverage(array $args): Result { |
|
|
public function coverage(array $args): Result { |
|
|
// run tests with code coverage reporting enabled |
|
|
// run tests with code coverage reporting enabled |
|
|
$exec = $this->findCoverageEngine(); |
|
|
$exec = $this->findCoverageEngine(); |
|
|
$execpath = realpath(self::BASE."vendor-bin/phpunit/vendor/phpunit/phpunit/phpunit"); |
|
|
return $this->runTests($exec, "typical", array_merge(["--coverage-html", self::BASE_TEST."coverage"], $args)); |
|
|
$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(); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected function findCoverageEngine(): string { |
|
|
protected function findCoverageEngine(): string { |
|
@ -73,4 +70,24 @@ class RoboFile extends \Robo\Tasks { |
|
|
return "php"; |
|
|
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(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|