コード例 #1
0
ファイル: DumpControllerTest.php プロジェクト: naxel/zfctool
 public function testCreateDumpSuccess()
 {
     $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('create dump --name=' . self::DUMP_FILE_NAME . ' --whitelist=' . self::TABLE_NAME);
     $this->assertResponseStatusCode(0);
     $this->assertActionName('create');
     $this->assertControllerName('ZFCTool\\Controller\\Dump');
     $this->assertControllerClass('DumpController');
     $this->assertMatchedRouteName('create-dump');
     $path = self::$manager->getDumpsDirectoryPath();
     $this->assertTrue(is_file($path . DIRECTORY_SEPARATOR . self::DUMP_FILE_NAME));
 }
コード例 #2
0
ファイル: DumpManagerTest.php プロジェクト: naxel/zfctool
 public function testCreateSuccess()
 {
     $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);
     $db->query(Database::dropTable('test_black_table1'));
     $db->createTable('test_black_table1');
     $db->query(Database::dropTable('test_black_table2'));
     $db->createTable('test_black_table2');
     $testData = array('id' => '1', 'col1' => '11', 'col2' => '<p>ZFCTool - Zend Framework 2 command line Tool</p>');
     $db->insert(self::TABLE_NAME, $testData);
     $dumpName = self::$manager->create(self::FIXTURE_MODULE, self::DUMP_FILE_NAME, self::TABLE_NAME, 'test_black_table1,test_black_table2');
     $compareTo = Database::getDisableChecksNotation() . Database::dropTable(self::TABLE_NAME) . ';' . PHP_EOL . Database::createTable(self::TABLE_NAME) . ';' . PHP_EOL . Database::insert(self::TABLE_NAME, $testData) . ';' . PHP_EOL;
     $this->assertEquals(self::DUMP_FILE_NAME, $dumpName);
     $dumpFullPath = self::$manager->getDumpsDirectoryPath(self::FIXTURE_MODULE) . DIRECTORY_SEPARATOR . $dumpName;
     if (file_exists($dumpFullPath)) {
         $dump = file_get_contents($dumpFullPath);
         $this->assertEquals($compareTo, $dump);
     } else {
         $this->fail('Dump file not exist!');
     }
     //Test generate name and creating file
     $dumpName = self::$manager->create(null, null, self::TABLE_NAME, 'test_black_table1,test_black_table2');
     $dumpFullPath = self::$manager->getDumpsDirectoryPath() . DIRECTORY_SEPARATOR . $dumpName;
     if (file_exists($dumpFullPath)) {
         $dump = file_get_contents($dumpFullPath);
         $this->assertEquals($compareTo, $dump);
         unlink($dumpFullPath);
     } else {
         $this->fail('Dump file not exist!');
     }
     $db->dropTable(self::TABLE_NAME);
     $db->dropTable('test_black_table1');
     $db->dropTable('test_black_table2');
 }
コード例 #3
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));
 }