twigphp/Twig · error · BadMethodCallException
Not implemented.
Error message
Not implemented.
What it means
IntegrationTestCase::getFixturesDir() is the old hook that test subclasses override to point the integration test framework at its fixture files. Since Twig 3.13 it is deprecated in favor of getFixturesDirectory(); the base implementation throws BadMethodCallException('Not implemented.') to force subclasses to override one of the two hooks.
Solutions
- Override protected static function getFixturesDirectory(): string in your test subclass to return the fixtures path.
- If supporting older Twig, keep the legacy getFixturesDir() override (it takes precedence) until the minimum is 3.13.
- Migrate existing suites from getFixturesDir() to getFixturesDirectory() to silence the deprecation.
Example fix
// before
class MyIntegrationTest extends IntegrationTestCase
{
// no fixture directory override
}
// after
class MyIntegrationTest extends IntegrationTestCase
{
protected static function getFixturesDirectory(): string
{
return __DIR__.'/Fixtures/';
}
} Defensive patterns
Strategy: validation
Prevention
- Override getFixturesDirectory() in every IntegrationTestCase subclass
- Migrate off the deprecated getFixturesDir() hook when requiring Twig 3.13+
- Run the test suite once with zero tests configured to catch the missing hook early
When it happens
Trigger: Subclassing IntegrationTestCase without overriding getFixturesDirectory() (or the deprecated getFixturesDir()), then running the tests: getTests() calls getFixturesDir() and hits the base throw.
Common situations: Writing a new integration test suite for a Twig extension and forgetting the fixture-directory hook; running test suites from libraries that were upgraded to Twig 3.13+ but kept only the legacy method in a broken state.
Understand the failure class
Background: "NotImplementedError: Subclasses should override this method" / "must be implemented" — abstract method errors explained — this error's family across 40 libraries.
Related errors
- %s: %s
- Test " " is not valid.
- The "format_list" filter requires the "IntlListFormatter"…
- SpanishInflector is not available.
- The " " filter is part of the , which is not…
AI-assisted analysis of twigphp/Twig@a414c3a491 (2026-09-13).
Data as JSON: /api/errors/efe8e8ed5e9de4a9.
Report an issue: GitHub.
Appendix: source
Thrown at src/Test/IntegrationTestCase.php:42
use Twig\TwigFunction;
use Twig\TwigTest;
/**
* Integration test helper.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Karma Dordrak <drak@zikula.org>
*/
abstract class IntegrationTestCase extends TestCase
{
/**
* @deprecated since Twig 3.13, use getFixturesDirectory() instead.
*
* @return string
*/
protected function getFixturesDir()
{
throw new \BadMethodCallException('Not implemented.');
}
protected static function getFixturesDirectory(): string
{
throw new \BadMethodCallException('Not implemented.');
}
/**
* @return RuntimeLoaderInterface[]
*/
protected function getRuntimeLoaders()
{
return [];
}
/**
* @return ExtensionInterface[]
*/View on GitHub (pinned to a414c3a491)