MDL-44596 logging: Add some tests to log stores to test the new support methods

This commit is contained in:
Ankit Agarwal
2014-03-26 09:12:43 +08:00
parent 8ead8802fb
commit 96c8d59dea
3 changed files with 69 additions and 0 deletions
@@ -224,4 +224,25 @@ class logstore_database_store_testcase extends advanced_testcase {
set_config('enabled_stores', '', 'tool_log');
get_log_manager(true);
}
/**
* Test logmanager::get_supported_reports returns all reports that require this store.
*/
public function test_get_supported_reports() {
$logmanager = get_log_manager();
$allreports = \core_component::get_plugin_list('report');
$supportedreports = array(
'log' => '/report/log',
'loglive' => '/report/loglive'
);
// Make sure all supported reports are installed.
$expectedreports = array_keys(array_intersect_key($allreports, $supportedreports));
$reports = $logmanager->get_supported_reports('logstore_database');
$reports = array_keys($reports);
foreach ($expectedreports as $expectedreport) {
$this->assertContains($expectedreport, $reports);
}
}
}
@@ -249,4 +249,28 @@ class logstore_legacy_store_testcase extends advanced_testcase {
\logstore_legacy\test\unittest_logstore_legacy::replace_sql_legacy($selectwhere, $params, $sort);
$this->assertSame('ip DESC', $sort);
}
/*
* Test logmanager::get_supported_reports returns all reports that require this store.
*/
public function test_get_supported_reports() {
$logmanager = get_log_manager();
$allreports = \core_component::get_plugin_list('report');
$supportedreports = array(
'log' => '/report/log',
'loglive' => '/report/loglive',
'outline' => '/report/outline',
'participation' => '/report/participation',
'stats' => '/report/stats'
);
// Make sure all supported reports are installed.
$expectedreports = array_keys(array_intersect_key($allreports, $supportedreports));
$reports = $logmanager->get_supported_reports('logstore_legacy');
$reports = array_keys($reports);
foreach ($expectedreports as $expectedreport) {
$this->assertContains($expectedreport, $reports);
}
}
}
@@ -195,4 +195,28 @@ class logstore_standard_store_testcase extends advanced_testcase {
set_config('enabled_stores', '', 'tool_log');
get_log_manager(true);
}
/**
* Test logmanager::get_supported_reports returns all reports that require this store.
*/
public function test_get_supported_reports() {
$logmanager = get_log_manager();
$allreports = \core_component::get_plugin_list('report');
$supportedreports = array(
'log' => '/report/log',
'loglive' => '/report/loglive',
'outline' => '/report/outline',
'participation' => '/report/participation',
'stats' => '/report/stats'
);
// Make sure all supported reports are installed.
$expectedreports = array_keys(array_intersect_key($allreports, $supportedreports));
$reports = $logmanager->get_supported_reports('logstore_standard');
$reports = array_keys($reports);
foreach ($expectedreports as $expectedreport) {
$this->assertContains($expectedreport, $reports);
}
}
}