{"record":{"id":"32fdbc714ea3c90a","repo":"twigphp/Twig","slug":"test-s-is-not-valid","errorCode":null,"errorMessage":"Test \"%s\" is not valid.","messagePattern":"Test \"(.+?)\" is not valid\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Test/IntegrationTestCase.php","lineNumber":206,"sourceCode":"\n            $test = file_get_contents($file->getRealpath());\n\n            if (preg_match('/--TEST--\\s*(.*?)\\s*(?:--CONDITION--\\s*(.*))?\\s*(?:--DEPRECATION--\\s*(.*?))?\\s*((?:--TEMPLATE(?:\\(.*?\\))?--(?:.*?))+)\\s*(?:--DATA--\\s*(.*))?\\s*--EXCEPTION--\\s*(.*)/sx', $test, $match)) {\n                $message = $match[1];\n                $condition = $match[2];\n                $deprecation = $match[3];\n                $templates = self::parseTemplates($match[4]);\n                $exception = $match[6];\n                $outputs = [[null, $match[5], null, '']];\n            } elseif (preg_match('/--TEST--\\s*(.*?)\\s*(?:--CONDITION--\\s*(.*))?\\s*(?:--DEPRECATION--\\s*(.*?))?\\s*((?:--TEMPLATE(?:\\(.*?\\))?--(?:.*?))+)--DATA--.*?--EXPECT--.*/s', $test, $match)) {\n                $message = $match[1];\n                $condition = $match[2];\n                $deprecation = $match[3];\n                $templates = self::parseTemplates($match[4]);\n                $exception = false;\n                preg_match_all('/--DATA--(.*?)(?:--CONFIG--(.*?))?--EXPECT--(.*?)(?=\\-\\-DATA\\-\\-|$)/s', $test, $outputs, \\PREG_SET_ORDER);\n            } else {\n                throw new \\InvalidArgumentException(\\sprintf('Test \"%s\" is not valid.', str_replace($fixturesDir.'/', '', $file)));\n            }\n\n            $tests[str_replace($fixturesDir.'/', '', $file)] = [str_replace($fixturesDir.'/', '', $file), $message, $condition, $templates, $exception, $outputs, $deprecation];\n        }\n\n        if ($legacyTests && !$tests) {\n            // add a dummy test to avoid a PHPUnit message\n            return [['not', '-', '', [], '', []]];\n        }\n\n        return $tests;\n    }\n\n    /**\n     * @final since Twig 3.13\n     *\n     * @return iterable\n     */","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/twigphp/Twig/blob/a414c3a491defb5a60f2fc88ef79ff37c90010cd/src/Test/IntegrationTestCase.php#L188-L224","documentation":"IntegrationTestCase::assembleTests() parses fixture files using --TEST--, --CONDITION--, --TEMPLATE(--TEMPLATE VARIATION--)--, --DATA--/--CONFIG--/--EXPECT-- section markers. A file whose contents do not match the expected overall pattern (the initial --TEST--/--TEMPLATE-- regex) produces this InvalidArgumentException naming the offending file relative to the fixtures directory.","triggerScenarios":"A fixture file in getFixturesDirectory() missing required sections (no --TEST-- or --TEMPLATE--), misspelled markers (e.g. --TEHST--, --EXCEPT--), markers with wrong casing, or a file that only matches neither the template nor data/config variant regex.","commonSituations":"Hand-written fixtures with typos in section names; truncated fixture files; copying fixtures from other test suites with slightly different marker conventions; adding binary or unrelated files into the fixtures directory.","solutions":["Open the file named in the message and fix/complete the required sections: --TEST--, --TEMPLATE-- (or --DATA--/--EXPECT-- pairs).","Check marker spelling and casing exactly (--EXPECT--, --DATA--, --CONFIG--, --TEMPLATE VARIATION--).","Remove non-fixture files from the fixtures directory or move them elsewhere.","Validate the fixture against an existing working one as a template."],"exampleFix":"// before (broken fixture)\nName of test\n{{ 1 + 1 }}\n\n// after (valid fixture)\n--TEST--\nName of test\n--TEMPLATE--\n{{ 1 + 1 }}\n--EXPECT--\n2","handlingStrategy":"validation","validationCode":"$contents = file_get_contents($fixtureFile);\nif (!preg_match('/^--TEST--/m', $contents) || !str_contains($contents, '--TEMPLATE--') && !str_contains($contents, '--DATA--')) {\n    throw new \\Exception(\"Invalid fixture: $fixtureFile\");\n}","typeGuard":null,"tryCatchPattern":"try { $tests = $this->getTests(); } catch (\\InvalidArgumentException $e) { if (str_contains($e->getMessage(), 'is not valid')) { fwrite(STDERR, $e->getMessage()); } throw $e; }","preventionTips":["Start every fixture with --TEST-- and include --TEMPLATE-- (or --DATA--/--EXPECT--)","Keep marker spelling/casing exact and copy from a known-good fixture","Keep only fixture files in the fixtures directory"],"tags":["twig","php","testing","fixtures","parsing"],"backgroundTag":"invalid-argument-format","analyzedSha":"a414c3a491defb5a60f2fc88ef79ff37c90010cd","analyzedAt":"2026-09-13T15:10:46.849Z","contentChangedAt":"2026-09-13T15:10:46.849Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}