public function test_housekeep_backup_dir() { $tree = new Signalfire_Cloud_Backup_Filetree($this->paths['backup']); $files = $tree->get_file_list_as_iterator(); $this->assertCount(5, $files); $this->cron->housekeep_backup_directory($this->paths); $files = $tree->get_file_list_as_iterator(); $this->assertCount(0, $files); }
public function tearDown() { parent::tearDown(); $tree = new Signalfire_Cloud_Backup_Filetree($this->paths['backup']); $files = $tree->get_file_list_as_iterator(); foreach ($files as $file) { unlink($file); } rmdir($this->paths['backup']); }
function tearDown() { parent::tearDown(); if (file_exists(WP_CONTENT_DIR . '/backups')) { $tree = new Signalfire_Cloud_Backup_Filetree(WP_CONTENT_DIR . '/backups'); foreach ($tree->get_file_list_as_iterator() as $file) { unlink($file->getRealPath()); } rmdir(WP_CONTENT_DIR . '/backups'); } }
/** * Iterates files in backup directory and removes to keep directory empty between runs. * * @since 1.0.0 * @access public */ public function housekeep_backup_directory($paths) { //Get instance of the file tree component for the backup path $tree = new Signalfire_Cloud_Backup_Filetree($paths['backup']); //Get a list of files in the backup directory $finder = $tree->get_file_list_as_iterator(); //Iterate each file foreach ($finder as $file) { //Delete a stray local file unlink($file->getRealPath()); } }