2015-07-16 11:32:42 +02:00
|
|
|
<?php
|
2016-06-23 01:37:22 +02:00
|
|
|
|
|
|
|
use SilverStripe\Security\Permission;
|
|
|
|
use SilverStripe\Security\Security;
|
2015-07-16 11:32:42 +02:00
|
|
|
/**
|
|
|
|
* Cleans up leftover databases from aborted test executions (starting with ss_tmpdb)
|
|
|
|
* Task is restricted to users with administrator rights or running through CLI.
|
|
|
|
*
|
|
|
|
* @package framework
|
|
|
|
* @subpackage tasks
|
|
|
|
*/
|
2016-03-09 22:15:19 +01:00
|
|
|
class CleanupTestDatabasesTask extends BuildTask {
|
2015-07-16 11:32:42 +02:00
|
|
|
protected $title = 'Deletes all temporary test databases';
|
|
|
|
|
|
|
|
protected $description = 'Cleans up leftover databases from aborted test executions (starting with ss_tmpdb)';
|
|
|
|
|
2016-03-09 22:15:19 +01:00
|
|
|
public function run($request) {
|
2015-07-16 11:32:42 +02:00
|
|
|
if(!Permission::check('ADMIN') && !Director::is_cli()) {
|
2016-05-23 18:11:52 +02:00
|
|
|
$response = Security::permissionFailure();
|
2016-03-09 22:15:19 +01:00
|
|
|
if($response) {
|
|
|
|
$response->output();
|
|
|
|
}
|
|
|
|
die;
|
2015-07-16 11:32:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
SapphireTest::delete_all_temp_dbs();
|
|
|
|
}
|
|
|
|
|
2016-03-08 21:50:18 +01:00
|
|
|
}
|