diff --git a/src/Dev/SapphireTest.php b/src/Dev/SapphireTest.php index 2e30f0c2e..c4c39ddd4 100644 --- a/src/Dev/SapphireTest.php +++ b/src/Dev/SapphireTest.php @@ -1191,15 +1191,9 @@ class SapphireTest extends PHPUnit_Framework_TestCase implements TestOnly // Support fixture paths relative to the test class, rather than relative to webroot // String checking is faster than file_exists() calls. - $isRelativeToFile - = (strpos('/', $fixtureFilePath) === false) - || preg_match('/^(\.){1,2}/', $fixtureFilePath); - - if ($isRelativeToFile) { - $resolvedPath = realpath($this->getCurrentAbsolutePath() . '/' . $fixtureFilePath); - if ($resolvedPath) { - return $resolvedPath; - } + $resolvedPath = realpath($this->getCurrentAbsolutePath() . '/' . $fixtureFilePath); + if ($resolvedPath) { + return $resolvedPath; } // Check if file exists relative to base dir diff --git a/src/Dev/State/FixtureTestState.php b/src/Dev/State/FixtureTestState.php index b4987aef6..ccbe67f1a 100644 --- a/src/Dev/State/FixtureTestState.php +++ b/src/Dev/State/FixtureTestState.php @@ -155,15 +155,9 @@ class FixtureTestState implements TestState { // Support fixture paths relative to the test class, rather than relative to webroot // String checking is faster than file_exists() calls. - $isRelativeToFile - = (strpos($fixtureFilePath, '/') === false) - || preg_match('/^(\.){1,2}/', $fixtureFilePath); - - if ($isRelativeToFile) { - $resolvedPath = realpath($this->getTestAbsolutePath($test) . '/' . $fixtureFilePath); - if ($resolvedPath) { - return $resolvedPath; - } + $resolvedPath = realpath($this->getTestAbsolutePath($test) . '/' . $fixtureFilePath); + if ($resolvedPath) { + return $resolvedPath; } // Check if file exists relative to base dir @@ -199,6 +193,17 @@ class FixtureTestState implements TestState */ protected function testNeedsDB(SapphireTest $test) { + // test class explicitly enables DB + if ($test->getUsesDatabase()) { + return true; + } + + // presence of fixture file implicitly enables DB + $fixtures = $test::get_fixture_file(); + if (!empty($fixtures)) { + return true; + } + $annotations = $test->getAnnotations(); // annotation explicitly disables the DB @@ -213,17 +218,6 @@ class FixtureTestState implements TestState return true; } - // test class explicitly enables DB - if ($test->getUsesDatabase()) { - return true; - } - - // presence of fixture file implicitly enables DB - $fixtures = $test::get_fixture_file(); - if (!empty($fixtures)) { - return true; - } - return false; } }