Example #1
0
 protected function writeMigration($name, $table, $create)
 {
     $with_prefix = $this->input->getOption('no-prefix') === false;
     $name = $with_prefix ? sprintf('migration_%s', $name) : $name;
     $path = $this->getMigrationPath();
     $target = $this->makeName($name, $path);
     $class = studly_case($name);
     $t = new \Bugotech\IO\Template();
     $t->file($this->getStub($table, $create), $target);
     $t->param('class', $class);
     $t->param('table', $table);
     $file = pathinfo($target, PATHINFO_FILENAME);
     $this->line("<info>Created Migration:</info> {$file}");
     return true;
 }
Example #2
0
 public function testSoFile()
 {
     $arquivo_template = __DIR__ . '/../../src/Database/Migration/Templates/blank.php.txt';
     $arquivo_target = __DIR__ . '/blank.txt';
     $t = new \Bugotech\IO\Template();
     try {
         $t->file($arquivo_template, $arquivo_target);
         // Verificar se o arquivo target foi criado
         $this->assertFileExists($arquivo_target);
         // Verificar se foi criado exatamente igual ao template
         $cont_temp = file_get_contents($arquivo_template);
         $cont_targ = file_get_contents($arquivo_target);
         $this->assertEquals($cont_temp, $cont_targ);
         // Atribuir o parametro class
         $t->param('class', 'OlaMundo');
         $cont_temp = str_replace('{{class}}', 'OlaMundo', $cont_temp);
         $cont_targ = file_get_contents($arquivo_target);
         $this->assertEquals($cont_temp, $cont_targ);
         $this->file->delete($arquivo_target);
     } catch (Exception $e) {
         $this->file->delete($arquivo_target);
     }
 }