From 20c6ddd354916faab96019f705455bb5d50add66 Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Wed, 28 Mar 2018 10:36:56 +1300 Subject: [PATCH] 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') --- src/Dev/SapphireTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Dev/SapphireTest.php b/src/Dev/SapphireTest.php index 55f1d78c3..3e6805c05 100644 --- a/src/Dev/SapphireTest.php +++ b/src/Dev/SapphireTest.php @@ -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