Use ModuleResourceLoader for fixtures path

This adds the ability to refer to a fixture file path by the ModuleResourceLoader path (e.g  protected static $fixture_file = 'vendor/module:tests/fixtures.yml')
This commit is contained in:
Will Rossiter 2018-03-28 10:36:56 +13:00 committed by GitHub
parent 89866d2323
commit 20c6ddd354
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,6 +37,7 @@ use SilverStripe\Security\Member;
use SilverStripe\Security\Permission;
use SilverStripe\Security\Security;
use SilverStripe\View\SSViewer;
use SilverStripe\Core\Manifest\ModuleResourceLoader;
if (!class_exists(PHPUnit_Framework_TestCase::class)) {
return;
@ -1169,6 +1170,11 @@ class SapphireTest extends PHPUnit_Framework_TestCase implements TestOnly
*/
protected function resolveFixturePath($fixtureFilePath)
{
// support loading via composer name path.
if (strpos($fixtureFilePath, ':') !== false) {
return ModuleResourceLoader::singleton()->resolvePath($fixtureFilePath);
}
// Support fixture paths relative to the test class, rather than relative to webroot
// String checking is faster than file_exists() calls.
$isRelativeToFile