public function test_createBackupFile() { $res = Backup::createBackupFile(['conf'], true); $this->assertRegExp('/' . 'mybackup--' . date('Y-m-d_H-i-s') . '--\\w{7}\\.zip/', $res['filename']); $this->assertTrue($res['status']); $this->assertFileExists(sys_get_temp_dir() . '/' . $res['filename'], 'backup file was not created.'); $this->assertTrue((new \ZipArchive())->open(sys_get_temp_dir() . '/' . $res['filename']), 'backup file is not valid zip archive'); }
/** * * @param array $form * @throws Exception * @return unknown */ public function doAction($form) { if (!checkSecurityToken($form['sectok'])) { throw new Exception('bad security token. Refresh your page'); } if (!auth_isadmin()) { throw new Exception('you must have AUTH_ADMIN permissions to perform backups'); } return Backup::createBackupFile($form['dirs'], isset($form['verbose']) ? true : false, $form['archive_format']); }