/** * test import data */ public function testImportData() { $dao = new BackupMySQLDAO(); $export_file = $dao->export(); //$this->pdo->query("drop table tu_plugin_options"); $this->assertTrue( $dao->import($export_file) ); $stmt = $this->pdo->query("show create table tu_plugins"); $data = $stmt->fetch(); $stmt->closeCursor(); $this->assertEqual($data['Table'], 'tu_plugins'); $stmt = $this->pdo->query("select * from tu_plugins"); $data = $stmt->fetch(); $this->assertEqual($data['id'], 1); $this->assertEqual($data['name'], 'Twitter'); }
public function testRestore() { // create export $dao = new BackupMySQLDAO(); $export_file = $dao->export(); $this->pdo->query("drop table tu_plugins"); $this->simulateLogin('*****@*****.**', true); $controller = new BackupController(true); $_FILES['backup_file']['name'] = "name"; $_FILES['backup_file']['type'] = "application/zip"; $_FILES['backup_file']["error"] = 0; $_FILES["backup_file"]["tmp_name"] = $export_file; $results = $controller->go(); $this->assertPattern("/Data Import Successfull/is", $results); $stmt = $this->pdo->query("show create table tu_plugins"); $data = $stmt->fetch(); $stmt->closeCursor(); $this->assertEqual($data['Table'], 'tu_plugins'); $stmt = $this->pdo->query("select * from tu_plugins"); $data = $stmt->fetch(); $this->assertEqual($data['id'], 1); $this->assertEqual($data['name'], 'Twitter'); }
/** * test import data, drop new tables not in backup */ public function testImportDataDropNewTables() { $dao = new BackupMySQLDAO(); $stmt = $this->pdo->query("show tables"); $data = $stmt->fetchAll(); $pre_import = count($data); $export_file = $dao->export(); $this->pdo->query("drop table tu_plugins"); $this->pdo->query("create table tu_dropme (`value` int(11) NOT NULL)"); $this->assertTrue($dao->import($export_file)); $stmt = $this->pdo->query("show create table tu_plugins"); $data = $stmt->fetch(); $stmt->closeCursor(); $this->assertEqual($data['Table'], 'tu_plugins'); $stmt = $this->pdo->query("show tables like '%dropme'"); $data = $stmt->fetch(); $this->assertFalse($data); // table should be dropped $stmt = $this->pdo->query("show tables"); $data = $stmt->fetchAll(); $post_import = count($data); $this->assertEqual($pre_import, $post_import); }