Issue #27 - Changed deltas for CLI from minutes to seconds.

This commit is contained in:
Daniel Thee Roperto
2016-09-19 15:55:57 +10:00
parent f569157368
commit 2670485341
3 changed files with 18 additions and 18 deletions

View File

@@ -139,11 +139,11 @@ class create extends clibase {
$this->becomeadmin();
// Create the outage.
$start = $this->time + ($options['start'] * 60);
$start = $this->time + $options['start'];
$outage = new outage([
'warntime' => $start - ($options['warn'] * 60),
'warntime' => $start - $options['warn'],
'starttime' => $start,
'stoptime' => $start + ($options['duration'] * 60),
'stoptime' => $start + $options['duration'],
'title' => $options['title'],
'description' => $options['description'],
]);
@@ -167,8 +167,8 @@ class create extends clibase {
$outage = outagedb::get_by_id((int)$id);
$this->set_defaults([
'warn' => (int)($outage->get_warning_duration() / 60),
'duration' => (int)($outage->get_duration() / 60),
'warn' => $outage->get_warning_duration(),
'duration' => $outage->get_duration(),
'title' => $outage->title,
'description' => $outage->description,
]);

View File

@@ -28,12 +28,12 @@ $string['clicreatehelp'] = 'Creates a new outage.';
$string['clicreateparamblock'] = 'blocks until outage starts.';
$string['clicreateparamclone'] = 'clone another outage except for the start time.';
$string['clicreateparamdescription'] = 'the description of the outage.';
$string['clicreateparamduration'] = 'how many minutes should the outage last.';
$string['clicreateparamduration'] = 'how many seconds should the outage last.';
$string['clicreateparamhelp'] = 'shows parameters help.';
$string['clicreateparamonlyid'] = 'only outputs the new outage id, useful for scripts.';
$string['clicreateparamstart'] = 'in how many minutes should this outage start. Required.';
$string['clicreateparamstart'] = 'in how many seconds should this outage start. Required.';
$string['clicreateparamtitle'] = 'the title of the outage.';
$string['clicreateparamwarn'] = 'how many minutes before it starts to display a warning.';
$string['clicreateparamwarn'] = 'how many seconds before it starts to display a warning.';
$string['clifinishhelp'] = 'Finishes an ongoing outage.';
$string['clifinishnotongoing'] = 'Outage is not ongoing.';
$string['clifinishparamhelp'] = 'shows parameters help.';

View File

@@ -147,8 +147,8 @@ class create_test extends cli_testcase {
$id = (int)$id;
$outage = outagedb::get_by_id($id);
self::assertSame($now, $outage->starttime);
self::assertSame(10 * 60, $outage->get_warning_duration());
self::assertSame(30 * 60, $outage->get_duration());
self::assertSame(10, $outage->get_warning_duration());
self::assertSame(30, $outage->get_duration());
self::assertNull($outage->finished);
self::assertSame('A Title', $outage->title);
self::assertSame('A Description', $outage->description);
@@ -174,8 +174,8 @@ class create_test extends cli_testcase {
// Check creted outage.
$outage = outagedb::get_by_id($id);
self::assertSame($now, $outage->starttime);
self::assertSame($outage->starttime - (10 * 60), $outage->warntime);
self::assertSame($outage->starttime + (30 * 60), $outage->stoptime);
self::assertSame($outage->starttime - 10, $outage->warntime);
self::assertSame($outage->starttime + 30, $outage->stoptime);
self::assertNull($outage->finished);
self::assertSame('Title', $outage->title);
self::assertSame('Description', $outage->description);
@@ -202,9 +202,9 @@ class create_test extends cli_testcase {
list(, $id) = explode(':', $text);
$id = (int)$id;
$outage = outagedb::get_by_id($id);
self::assertSame($now + (50 * 60), $outage->starttime, 'Wrong starttime.');
self::assertSame($outage->starttime - (100 * 60), $outage->warntime, 'Wrong warntime.');
self::assertSame($outage->starttime + (300 * 60), $outage->stoptime, 'Wrong stoptime.');
self::assertSame($now + 50, $outage->starttime, 'Wrong starttime.');
self::assertSame($outage->starttime - 100, $outage->warntime, 'Wrong warntime.');
self::assertSame($outage->starttime + 300, $outage->stoptime, 'Wrong stoptime.');
self::assertNull($outage->finished);
self::assertSame('Default Title', $outage->title);
self::assertSame('Default Description', $outage->description);
@@ -233,7 +233,7 @@ class create_test extends cli_testcase {
$id = trim($this->execute($cli));
// Check cloned data.
$cloned = outagedb::get_by_id((int)$id);
self::assertSame($now + (60 * 60), $cloned->starttime);
self::assertSame($now + 60, $cloned->starttime);
self::assertSame($original->get_warning_duration(), $cloned->get_warning_duration());
self::assertSame($original->get_duration(), $cloned->get_duration());
self::assertSame($original->title, $cloned->title);
@@ -254,9 +254,9 @@ class create_test extends cli_testcase {
// Not an extensive test in the blocking API, cliwaitforit tests should cover them deeper.
$this->set_parameters([
'--block',
'--warn=10',
'--warn=60',
'--start=0',
'--duration=30',
'--duration=600',
'--title=Title',
'--description=Description',
]);