コード例 #1
0
ファイル: DumpControllerTest.php プロジェクト: naxel/zfctool
 /**
  * @depends testCreateDumpSuccess
  */
 public function testImportDumpSuccess()
 {
     $dumpFullPath = self::$manager->getDumpsDirectoryPath() . DIRECTORY_SEPARATOR . self::DUMP_FILE_NAME;
     if (is_file($dumpFullPath)) {
         // dispatch url
         $this->dispatch('import dump ' . self::DUMP_FILE_NAME);
         $this->assertResponseStatusCode(0);
         $this->assertActionName('import');
         $this->assertControllerName('ZFCTool\\Controller\\Dump');
         $this->assertControllerClass('DumpController');
         $this->assertMatchedRouteName('import-dump');
         $result = self::$db->query("SHOW TABLES LIKE '" . self::TABLE_NAME . "';", Adapter::QUERY_MODE_EXECUTE);
         $this->assertEquals(1, $result->count());
         $db = new Mysql(self::$db);
         $db->dropTable(self::TABLE_NAME);
     } else {
         $this->fail('Dump file not exist!');
     }
 }
コード例 #2
0
 /**
  * Test for method `generate`
  */
 public function testGenerateMigrationSuccess()
 {
     $tableName = 'test_table';
     //Test empty diff
     $result = self::$manager->generateMigration(null, '', $tableName);
     $this->assertFalse($result);
     $db = new Mysql(self::$db);
     $db->createTable($tableName);
     $db->createColumn($tableName, 'col1', AbstractMigration::TYPE_INT);
     $db->createColumn($tableName, 'col2', AbstractMigration::TYPE_VARCHAR, 50);
     //Test diff
     $diff = self::$manager->generateMigration(null, '', $tableName, true);
     $compareTo = array('down' => array(Database::dropTable($tableName)), 'up' => array(Database::dropTable($tableName), Database::createTable($tableName)));
     $this->assertEquals($compareTo, $diff);
     //Test create
     $migrationPath = self::$manager->generateMigration(null, '', $tableName);
     $this->assertTrue(is_file($migrationPath));
     $migrationFile = file_get_contents($migrationPath);
     $this->assertContains('CREATE TABLE `' . $tableName . '`', $migrationFile);
     $this->assertContains('$this->query("DROP TABLE IF EXISTS `' . $tableName . '`");', $migrationFile);
     unlink($migrationPath);
     $db->dropTable($tableName);
 }
コード例 #3
0
ファイル: DumpManagerTest.php プロジェクト: naxel/zfctool
 /**
  * @depends testCreateSuccess
  */
 public function testImportSuccess()
 {
     $dumpFullPath = self::$manager->getDumpsDirectoryPath(self::FIXTURE_MODULE) . DIRECTORY_SEPARATOR . self::DUMP_FILE_NAME;
     if (is_file($dumpFullPath)) {
         self::$manager->import(self::DUMP_FILE_NAME, self::FIXTURE_MODULE);
         $result = self::$db->query("SHOW TABLES LIKE '" . self::TABLE_NAME . "';", Adapter::QUERY_MODE_EXECUTE);
         $this->assertEquals(1, $result->count());
         unlink($dumpFullPath);
         $db = new Mysql(self::$db);
         $db->dropTable(self::TABLE_NAME);
     } else {
         $this->fail('Dump file not exist!');
     }
 }
コード例 #4
0
 public function testDiffModuleDb()
 {
     $db = new Mysql(self::$db);
     $db->query(Database::dropTable(self::TABLE_NAME));
     $db->createTable(self::TABLE_NAME);
     $db->createColumn(self::TABLE_NAME, 'col1', AbstractMigration::TYPE_INT);
     $db->createColumn(self::TABLE_NAME, 'col2', AbstractMigration::TYPE_TEXT);
     // dispatch url
     $this->dispatch('diff db --module=' . self::FIXTURE_MODULE . ' --whitelist=' . self::TABLE_NAME);
     $this->assertResponseStatusCode(0);
     $this->assertActionName('diff');
     $this->assertControllerName('ZFCTool\\Controller\\Migration');
     $this->assertControllerClass('MigrationController');
     $this->assertMatchedRouteName('diff-db');
     $response = ob_get_contents();
     $this->assertContains('Queries (2) :', $response);
     $db->query(Database::dropTable(self::TABLE_NAME));
 }