function it_compiles_a_template(Filesystem $file, TemplateCompiler $compiler) { $template = 'class $NAME$ {}'; $data = ['NAME' => 'Bar']; $compiledTemplate = 'class Bar {}'; $file->get('template.txt')->shouldBeCalled()->willReturn($template); $compiler->compile($template, $data)->shouldBeCalled()->willReturn($compiledTemplate); // When we call compile, we expect the method to // fetch the given template, compile it down, // and return the results $this->compile('template.txt', $data, $compiler)->shouldBe($compiledTemplate); }
/** * Compile the file * * @param $templatePath * @param array $data * @param TemplateCompiler $compiler * @throws UndefinedTemplate * @return mixed */ public function compile($templatePath, array $data, TemplateCompiler $compiler) { return $compiler->compile($this->file->get($templatePath), $data); }