Example #1
0
 /**
  * Test RenderTo method.
  */
 public function testRenderTo()
 {
     $target = __DIR__ . '/../Cli/Migrations/Version_8_7_5/MigrationClass.php';
     $this->given($template = new Template($this->filename()))->and($values = array('namespace' => 'namespace Some\\ClassNamespace;', 'migrationClassName' => 'FooMigration', 'use' => 'use Some\\AggregateRoot\\ClassName;', 'aggregateClassName' => 'ClassName', 'date' => '2016-08-16', 'time' => '11:31:00'))->and($template->setVar($values))->and($keys = array_map(function ($key) {
         return '{' . $key . '}';
     }, array_keys($values)))->then()->exception(function () use($template, $target) {
         $template->renderTo($target);
     })->isInstanceOf(\RuntimeException::class)->and()->when(mkdir(dirname($target), 0777, true))->and($template->renderTo($target))->then()->string(file_get_contents($target))->isEqualTo(str_replace($keys, $values, file_get_contents($this->filename() . '.dist')));
 }