public function test_backup_with_errors() { $this->assertTrue($this->backup->backup()); $this->assertFileExists($this->backup->get_backup_filepath()); $this->backup->error(get_class($this->backup), 'foobar'); $this->assertFalse($this->backup->verify_backup()); }
/** * Make sure setting a custom path + archive filename correctly sets the archive filepath * */ public function testCustomBackupPath() { HM\BackUpWordPress\Path::get_instance()->set_path(WP_CONTENT_DIR . '/custom'); $this->backup->set_archive_filename('backup.zip'); $this->assertEquals(wp_normalize_path(WP_CONTENT_DIR . '/custom/backup.zip'), $this->backup->get_archive_filepath()); $this->backup->backup(); $this->assertFileExists($this->backup->get_archive_filepath()); }
/** * Make sure setting a custom path + archive filename correctly sets the archive filepath * * @access public */ public function testCustomBackupPath() { $this->backup->set_path(WP_CONTENT_DIR . '/custom'); $this->backup->set_archive_filename('backup.zip'); $this->assertEquals(HM_Backup::conform_dir(WP_CONTENT_DIR . '/custom/backup.zip'), $this->backup->get_archive_filepath()); $this->backup->backup(); $this->assertFileExists($this->backup->get_archive_filepath()); }
/** * Test a full backup with the ZipArchive * * @group pathTest */ public function testFullBackupWithZipArchive() { $this->backup->set_zip_command_path(false); $this->backup->backup(); $this->assertEquals('ziparchive', $this->backup->get_archive_method()); $this->assertFileExists($this->backup->get_archive_filepath()); $files = $this->backup->get_included_files(); $files[] = $this->backup->get_database_dump_filename(); $this->assertArchiveContains($this->backup->get_archive_filepath(), $files, $this->backup->get_root()); $this->assertArchiveFileCount($this->backup->get_archive_filepath(), count($files)); $this->assertEmpty($this->backup->get_errors()); }
/** * Test a files only backup with PclZip * * @access public */ public function testFileOnlyWithPclZip() { $this->backup->set_type('file'); $this->backup->set_zip_command_path(false); $this->backup->skip_zip_archive = true; $this->backup->backup(); $this->assertEquals($this->backup->get_archive_method(), 'pclzip'); $this->assertFileExists($this->backup->get_archive_filepath()); $this->assertArchiveContains($this->backup->get_archive_filepath(), array('test-data.txt')); $this->assertArchiveFileCount($this->backup->get_archive_filepath(), 3); $this->assertEmpty($this->backup->get_errors()); }
/** * Test a files only backup with ZipArchive */ public function testFileOnlyWithZipArchive() { $this->backup->set_type('file'); $this->backup->set_zip_command_path(false); $this->assertTrue(class_exists('ZipArchive')); $this->backup->backup(); $this->assertEquals($this->backup->get_archive_method(), 'ziparchive'); $this->assertFileExists($this->backup->get_archive_filepath()); $this->assertArchiveContains($this->backup->get_archive_filepath(), array('test-data.txt')); $this->assertArchiveFileCount($this->backup->get_archive_filepath(), 3); $this->assertEmpty($this->backup->get_errors()); }
/** * Test a full backup with PclZip * * @access public * @return null */ function testFullBackupWithPclZip() { $this->backup->zip_command_path = false; $this->backup->skip_zip_archive = true; $this->backup->backup(); $this->assertEquals($this->backup->archive_method(), 'pclzip'); $this->assertFileExists($this->backup->archive_filepath()); $files = $this->backup->files(); $files[] = $this->backup->database_dump_filename; $this->assertArchiveContains($this->backup->archive_filepath(), $files); $this->assertArchiveFileCount($this->backup->archive_filepath(), count($files)); $this->assertEmpty($this->backup->errors()); }
/** * If the HMBKP_PATH constant is defined and the new directory is writable then everything should be moved there * * @access public * @return void */ public function testUnWritableDefinedBackupPath() { $this->assertEquals(hmbkp_path(), HMBKP_PATH); $this->backup->backup(); $this->assertFileExists($this->backup->get_archive_filepath()); chmod($this->custom_path, 0555); if (is_writable($this->custom_path)) { $this->markTestSkipped('The custom path was still writable'); } hmbkp_constant_changes(); $this->assertEquals(hmbkp_path(), hmbkp_path_default()); $this->assertFileExists(str_replace($this->backup->get_path(), hmbkp_path_default(), $this->backup->get_archive_filepath())); // They should both exist because we didn't have permission to remove the old file $this->assertFileExists($this->backup->get_archive_filepath()); }
public function test_adding_files_to_existing_backup() { $this->backup->backup(); $filepath = $this->backup->get_backup_filepath(); $this->assertFileExists($this->backup->get_backup_filepath()); $this->assertArchiveContains($this->backup->get_backup_filepath(), array('test-data.txt', 'exclude', 'exclude/exclude.exclude')); $this->assertArchiveFileCount($this->backup->get_backup_filepath(), 3); // create a new file if (!file_put_contents(Path::get_root() . '/new.file', 'test')) { $this->markTestSkipped('new.file couldn\'t be created'); } $this->backup->backup(); $this->assertEquals($filepath, $this->backup->get_backup_filepath()); $this->assertFileExists($this->backup->get_backup_filepath()); $this->assertArchiveContains($this->backup->get_backup_filepath(), array('new.file')); $this->assertArchiveFileCount($this->backup->get_backup_filepath(), 4); }
public function test_backup() { $this->assertTrue($this->backup->backup()); $this->assertFileExists($this->backup->get_backup_filepath()); }