mirror of
https://github.com/catalyst/moodle-auth_outage.git
synced 2026-05-16 21:41:31 +02:00
WR#334284 fixing unit tests
This commit is contained in:
@@ -102,6 +102,15 @@ abstract class clibase {
|
||||
$this->time = $time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the reference time for creating outages.
|
||||
*/
|
||||
public function get_referencetime()
|
||||
{
|
||||
return $this->time;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates all options (parameters) available for the CLI command.
|
||||
* @return mixed[] Options.
|
||||
|
||||
@@ -95,6 +95,8 @@ class outagedb_test extends auth_outage_base_testcase {
|
||||
$outage = $this->createoutage(2);
|
||||
$outage->id = $id;
|
||||
outagedb::save($outage);
|
||||
// Ensure an id was given.
|
||||
self::assertNotEquals(0, $id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -44,14 +44,16 @@ class forms_test extends auth_outage_base_testcase {
|
||||
* Create a delete form.
|
||||
*/
|
||||
public function test_delete() {
|
||||
new delete();
|
||||
$form = new delete();
|
||||
self::assertNotNull($form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a finish form.
|
||||
*/
|
||||
public function test_finish() {
|
||||
new finish();
|
||||
$form = new finish();
|
||||
self::assertNotNull($form);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,6 +166,7 @@ class forms_test extends auth_outage_base_testcase {
|
||||
]);
|
||||
$edit = new edit();
|
||||
$edit->set_data($outage);
|
||||
self::assertTrue(true, "set_data did not return any error");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -61,8 +61,12 @@ class cli_test extends auth_outage_cli_testcase {
|
||||
*/
|
||||
public function test_setreferencetime() {
|
||||
$cli = new create(['start' => 0]);
|
||||
|
||||
$cli->set_referencetime(1);
|
||||
self::assertEquals(1, $cli->get_referencetime());
|
||||
|
||||
$cli->set_referencetime(60 * 60 * 24 * 7);
|
||||
self::assertEquals(604800, $cli->get_referencetime());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -121,10 +121,16 @@ class finish_test extends auth_outage_cli_testcase {
|
||||
'title' => 'Title',
|
||||
'description' => 'Description',
|
||||
]));
|
||||
$outage = outagedb::get_by_id($id);
|
||||
self::assertNull($outage->finished, "outage should not be finished");
|
||||
|
||||
$this->set_parameters(['-id='.$id]);
|
||||
$cli = new finish();
|
||||
$cli->set_referencetime($now);
|
||||
$this->execute($cli);
|
||||
|
||||
$outage = outagedb::get_by_id($id);
|
||||
self::assertNotNull($outage->finished, "outage should be finished");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,7 +43,8 @@ class infopagecontroller_test extends auth_outage_base_testcase {
|
||||
* Tests the constructor.
|
||||
*/
|
||||
public function test_constructor() {
|
||||
new infopage();
|
||||
$infopage = new infopage();
|
||||
self::assertNotNull($infopage);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,7 +52,8 @@ class infopagecontroller_test extends auth_outage_base_testcase {
|
||||
*/
|
||||
public function test_constructor_withparams() {
|
||||
$_GET = ['id' => 1, 'static' => 'true'];
|
||||
new infopage();
|
||||
$infopage = new infopage();
|
||||
self::assertNotNull($infopage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -60,7 +60,7 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
}
|
||||
|
||||
public function test_createfromoutage() {
|
||||
// How to fetch a page from PHPUnit environment?
|
||||
self::markTestSkipped("How to fetch a page from PHPUnit environment?");
|
||||
}
|
||||
|
||||
public function test_createfromhtml() {
|
||||
@@ -403,7 +403,6 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
$page->set_max_refresh_time(5);
|
||||
$page->generate();
|
||||
$generated = trim(file_get_contents($page->get_io()->get_template_file()));
|
||||
return $generated;
|
||||
|
||||
self::assertContains('<meta http-equiv="refresh" content="5">', $generated);
|
||||
}
|
||||
@@ -412,7 +411,7 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
* Data provider for test_get_urls_from_stylesheet
|
||||
* @return array
|
||||
*/
|
||||
public function test_get_urls_from_stylesheet_provider() {
|
||||
public function get_urls_from_stylesheet_provider() {
|
||||
return [
|
||||
// Empty string.
|
||||
["", 0],
|
||||
@@ -434,7 +433,7 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
/**
|
||||
* Tests get_urls_from_stylesheet() method to get all appropriate URLS from the file.
|
||||
*
|
||||
* @dataProvider test_get_urls_from_stylesheet_provider
|
||||
* @dataProvider get_urls_from_stylesheet_provider
|
||||
* @param string $filecontent Content of the file
|
||||
* @param int $count Expected quantity of found URLs
|
||||
* @throws coding_exception
|
||||
|
||||
@@ -187,7 +187,8 @@ class outagelib_test extends auth_outage_base_testcase {
|
||||
*/
|
||||
public function test_inject_noactive() {
|
||||
outagelib::reset_injectcalled();
|
||||
outagelib::get_inject_code();
|
||||
$code = outagelib::get_inject_code();
|
||||
self::assertNull($code);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user