protected function putCode($path, Method $method) { // In the generated class, the repository is passed as argument. // Create a repository here so that we can run the code successfully. $method->getClass()->addImport(new Import('Puli\\Manager\\Tests\\Factory\\Generator\\Fixtures\\TestRepository')); $method->setBody(<<<EOF \$repo = new TestRepository(); {$method->getBody()} EOF ); parent::putCode($path, $method); }