more unit-tests
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -10,10 +10,69 @@ use PHPUnit\Framework\TestCase;
|
||||
class CustomerBackupsTest extends TestCase
|
||||
{
|
||||
|
||||
public function testAdminCustomerBackupsNotEnabled()
|
||||
{
|
||||
global $admin_userdata;
|
||||
|
||||
Settings::Set('system.backupenabled', 0, true);
|
||||
|
||||
// get customer
|
||||
$json_result = Customers::getLocal($admin_userdata, array(
|
||||
'loginname' => 'test1'
|
||||
))->get();
|
||||
$customer_userdata = json_decode($json_result, true)['data'];
|
||||
$this->expectExceptionCode(405);
|
||||
$this->expectExceptionMessage("You cannot access this resource");
|
||||
CustomerBackups::getLocal($customer_userdata)->add();
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testAdminCustomerBackupsNotEnabled
|
||||
*/
|
||||
public function testAdminCustomerBackupsExtrasHidden()
|
||||
{
|
||||
global $admin_userdata;
|
||||
|
||||
Settings::Set('system.backupenabled', 1, true);
|
||||
Settings::Set('panel.customer_hide_options', 'extras', true);
|
||||
|
||||
// get customer
|
||||
$json_result = Customers::getLocal($admin_userdata, array(
|
||||
'loginname' => 'test1'
|
||||
))->get();
|
||||
$customer_userdata = json_decode($json_result, true)['data'];
|
||||
$this->expectExceptionCode(405);
|
||||
$this->expectExceptionMessage("You cannot access this resource");
|
||||
CustomerBackups::getLocal($customer_userdata)->add();
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testAdminCustomerBackupsExtrasHidden
|
||||
*/
|
||||
public function testAdminCustomerBackupsExtrasBackupHidden()
|
||||
{
|
||||
global $admin_userdata;
|
||||
|
||||
Settings::Set('panel.customer_hide_options', 'extras.backup', true);
|
||||
|
||||
// get customer
|
||||
$json_result = Customers::getLocal($admin_userdata, array(
|
||||
'loginname' => 'test1'
|
||||
))->get();
|
||||
$customer_userdata = json_decode($json_result, true)['data'];
|
||||
$this->expectExceptionCode(405);
|
||||
$this->expectExceptionMessage("You cannot access this resource");
|
||||
CustomerBackups::getLocal($customer_userdata)->add();
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testAdminCustomerBackupsExtrasBackupHidden
|
||||
*/
|
||||
public function testCustomerCustomerBackupsAdd()
|
||||
{
|
||||
global $admin_userdata;
|
||||
|
||||
Settings::Set('panel.customer_hide_options', '', true);
|
||||
Database::query("TRUNCATE TABLE `panel_tasks`;");
|
||||
|
||||
// get customer
|
||||
@@ -24,16 +83,16 @@ class CustomerBackupsTest extends TestCase
|
||||
|
||||
$data = [
|
||||
'path' => '/my-backup',
|
||||
'backup_dbs' => 1,
|
||||
'backup_mail' => 2,
|
||||
'backup_web' => 1
|
||||
'backup_dbs' => 2,
|
||||
'backup_mail' => 3,
|
||||
'backup_web' => 4
|
||||
];
|
||||
$json_result = CustomerBackups::getLocal($customer_userdata, $data)->add();
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
$this->assertEquals($customer_userdata['documentroot'] . 'my-backup/', $result['destdir']);
|
||||
$this->assertEquals('1', $result['backup_dbs']);
|
||||
$this->assertEquals('0', $result['backup_dbs']);
|
||||
$this->assertEquals('0', $result['backup_mail']);
|
||||
$this->assertEquals('1', $result['backup_web']);
|
||||
$this->assertEquals('0', $result['backup_web']);
|
||||
}
|
||||
|
||||
public function testAdminCustomerBackupsGet()
|
||||
@@ -61,9 +120,9 @@ class CustomerBackupsTest extends TestCase
|
||||
$json_result = CustomerBackups::getLocal($admin_userdata)->listing();
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
$this->assertEquals(1, $result['count']);
|
||||
$this->assertEquals('1', $result['list'][0]['data']['backup_dbs']);
|
||||
$this->assertEquals('0', $result['list'][0]['data']['backup_dbs']);
|
||||
$this->assertEquals('0', $result['list'][0]['data']['backup_mail']);
|
||||
$this->assertEquals('1', $result['list'][0]['data']['backup_web']);
|
||||
$this->assertEquals('0', $result['list'][0]['data']['backup_web']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user