lsfilter: Add support for non-timestamp date formats
[ninja.git] / test / unit_test / tests / backup_Test.php
blobbb06bac8853e3ec05a6ed17f308371a64c898417
1 <?php
2 /**
3 * @package NINJA
4 * @author op5
5 * @license GPL
6 */
7 class Backup_Test extends PHPUnit_Framework_TestCase {
8 public function setUp() {
9 $this->markTestSkipped(
10 'I think there was something about permissions that was a problem'
12 Auth::instance(array('session_key' => false))->force_user(new Op5User_AlwaysAuth());
13 $this->pre_backups = array();
14 $this->backup_location = "/var/www/html/backup";
15 if ($handle = opendir($this->backup_location)) {
16 while (false !== ($entry = readdir($handle))) {
17 $this->pre_backups[] = $entry;
22 public function tearDown() {
23 #Remove any backups created since we started
24 if ($handle = opendir($this->backup_location)) {
25 while (false !== ($entry = readdir($handle))) {
26 if(!in_array($entry, $this->pre_backups))
27 unlink($this->backup_location.'/'.$entry);
32 public function test_backup() {
33 $controller = new Backup_Controller();
34 $controller->backup();
35 $this->ok(isset($controller->template->status) && $controller->template->status,
36 "asserting backup success: returned {$controller->template->message}\nFull output: ".$controller->debug);
37 $this->ok($controller->template->file != '', "asserting backup file has been set");
40 public function test_backup_restore() {
41 $controller = new Backup_Controller();
42 $controller->backup();
43 $this->ok(isset($controller->template->status) && $controller->template->status,
44 "asserting backup success: returned {$controller->template->message}\nFull output: ".$controller->debug);
45 $this->ok($controller->template->file != '', "asserting backup file has been set");
46 $this_backup = $controller->template->file;
47 $controller->restore($this_backup);
48 $this->ok(isset($controller->template->status) && $controller->template->status,
49 "asserting restore success: returned {$controller->template->message}\nFull output: ".$controller->debug);
50 sleep(5); // *sigh* Wait for nagios to start again...
53 public function test_backup_delete() {
54 $controller = new Backup_Controller();
55 $controller->backup();
56 $this_backup = $controller->template->file;
58 $this->ok(file_exists($this->backup_location . '/' . $this_backup . '.tar.gz'), "asserting backup file exists where we expect it");
59 $controller->delete($this_backup);
60 $this->ok(!file_exists($this->backup_location . '/' . $this_backup . '.tar.gz'), "asserting backup file has been deleted");