Allow —no-dev install via a PHPUnit shim

Partially reinstates the 3.x style PhpUnitWrapper which was removed in d1af214ef5.
While we no longer need the full wrapper, the part which creates a fake class is still useful.

The preferred alternative would be to remove any references to SapphireTest from non-dev files,
which mostly applies to SapphireTest::is_running_test(). This should be solved in a larger refactor
of SapphireTest into optional traits and more fine grained functionality.
This commit is contained in:
Ingo Schommer 2017-04-24 11:30:37 +12:00 committed by Sam Minnée
parent ff3ad6eb6b
commit 5a7c6d4f60
2 changed files with 18 additions and 1 deletions

View File

@ -74,7 +74,10 @@
"SilverStripe\\View\\": "src/View/",
"SilverStripe\\View\\Tests\\": "tests/php/View/"
},
"files": ["src/Core/Constants.php"],
"files": [
"src/Core/Constants.php",
"src/Dev/PhpUnitShim.php"
],
"classmap": ["tests/behat/features/bootstrap"]
},
"include-path": [

14
src/Dev/PhpUnitShim.php Normal file
View File

@ -0,0 +1,14 @@
<?php
// Ensure this class can be autoloaded when installed without dev dependencies.
// It's included by default through composer's autoloading.
// class_exists() triggers PSR-4 autoloaders, which should discover if PHPUnit is installed.
// TODO Factor out SapphireTest references from non-dev core code (avoid autoloading in the first place)
namespace {
if (!class_exists('PHPUnit_Framework_TestCase')) {
class PHPUnit_Framework_TestCase
{
}
}
}