silverstripe-framework/Dev/Tasks/CleanupTestDatabasesTask.php

36 lines
921 B
PHP
Raw Normal View History

<?php
2016-06-23 01:37:22 +02:00
namespace SilverStripe\Dev\Tasks;
use SilverStripe\Control\Director;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\Dev\BuildTask;
2016-06-23 01:37:22 +02:00
use SilverStripe\Security\Permission;
use SilverStripe\Security\Security;
/**
* Cleans up leftover databases from aborted test executions (starting with ss_tmpdb)
* Task is restricted to users with administrator rights or running through CLI.
*/
2016-03-09 22:15:19 +01:00
class CleanupTestDatabasesTask extends BuildTask {
private static $segment = 'CleanupTestDatabasesTask';
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) {
if(!Permission::check('ADMIN') && !Director::is_cli()) {
$response = Security::permissionFailure();
2016-03-09 22:15:19 +01:00
if($response) {
$response->output();
}
die;
}
SapphireTest::delete_all_temp_dbs();
}
2016-03-08 21:50:18 +01:00
}