public function test_old_cache_is_cleared() { $this->assertFalse($this->size->is_site_size_cached()); $this->size = new Site_Size('file'); $this->size->recursive_filesize_scanner(); $this->assertTrue($this->size->is_site_size_cached()); // Set the filemtime to over a week ago touch(PATH::get_path() . '/.files', time() - WEEK_IN_SECONDS - 10); clearstatcache(); $this->assertFalse($this->size->is_site_size_cached()); }
public function test_only_database_zipped_up() { $this->backup->set_type('database'); Path::get_instance()->reset_path(); file_put_contents(PATH::get_path() . '/foo.zip.SmuhtP', 'bar'); file_put_contents(PATH::get_path() . '/zicBotXQ', 'baz'); $this->backup->run(); $this->assertFileExists($this->backup->get_backup_filepath()); $this->assertArchiveContains($this->backup->get_backup_filepath(), array(basename($this->backup->get_database_backup_filepath()))); $this->assertArchiveNotContains($this->backup->get_backup_filepath(), array('zicBotXQ', 'foo.zip.SmuhtP')); $this->assertArchiveFileCount($this->backup->get_backup_filepath(), 1); }
public function get_cached_filesizes($max_age = WEEK_IN_SECONDS) { $cache = PATH::get_path() . '/.files'; $files = false; if (file_exists($cache)) { // If the file is old then regenerate it if (time() - filemtime($cache) <= $max_age) { $files = json_decode(gzuncompress(file_get_contents($cache)), 'ARRAY_A'); } } return $files; }
public function test_cleanup() { // Should be cleaned up file_put_contents(PATH::get_path() . '/foo.zip.SmuhtP', 'bar'); file_put_contents(PATH::get_path() . '/foo.sql', 'bar'); file_put_contents(PATH::get_path() . '/zicBotXQ', 'baz'); // Existing backups shouldn't be cleaned up file_put_contents(PATH::get_path() . '/backup.zip', 'baz'); Path::get_instance()->cleanup(); $this->assertFileNotExists(PATH::get_path() . '/foo.zip.SmuhtP'); $this->assertFileNotExists(PATH::get_path() . '/foo.sql'); $this->assertFileNotExists(PATH::get_path() . '/zicBotXQ'); $this->assertFileExists(PATH::get_path() . '/index.html'); $this->assertFileExists(PATH::get_path() . '/backup.zip'); }