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

  1. Override protected static function getFixturesDirectory(): string in your test subclass to return the fixtures path.
  2. If supporting older Twig, keep the legacy getFixturesDir() override (it takes precedence) until the minimum is 3.13.
  3. 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

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


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)