Unit tests: Using $fixture_file makes tests crash


Silverstripe Version: 4.3.3


Hi, consider the following simple test class:

class MyTest extends SapphireTest
	protected static $fixture_file = [
	public function testSomething()
		$this->assertTrue(true); // Do whatever here, as we will never make it to this point.

If I run this test, I will get the following error message:
PHP Catchable fatal error: Argument 1 passed to SilverStripe\View\Requirements::set_backend() must be an instance of SilverStripe\View\Requirements_Backend, null given, called in /var/www/html/myproject/vendor/silverstripe/framework/src/View/Dev/RequirementsTestState.php on line 29 and defined in /var/www/html/myproject/vendor/silverstripe/framework/src/View/Requirements.php on line 116

If I remove the $fixture_file definition, the test works without any issues. And if I set $fixture_file to point to a non-existent file, the same error happens again, so I think that the content of the fixture file does not matter here.

This is really strange and I’ve been struggling with this for many hours now. Maybe it has something to do with my particular project (installed modules, custom code, whatever) but I really have no clue. Or then it’s a bug in SilverStripe, but then again it seems unlikely because $fixture_file seems to be a very common feature, so probably there would already be bug reports about it if it wouldn’t work for others. I even tried to downgrade to SilverStripe 4.2.0 to check if the issue was caused by some change in the recent version history of SilverStripe, but the same problem occurred with 4.2.0 too.

Thank you for your support!


Did you try to include the fixture file relatively? I normally put it in the same folder as my tests. It might also make problems, when the yml is not valid. This drove me crazy sometimes in the past. You can put it in a yml validator to find potential errors.


Thanks wmk! I need to try to put the file to the same folder. Maybe I already tried it, but I don’t remember. And thanks for the tip about the yml validator too, I need to check that too when I work on this issue again. I’ll post again if I’m not able to solve the problem :).


Now I validated the YAML file (was ok) and moved it to the same folder with the test and removed the file directory part from $fixture_file. Unfortunately it didn’t help.