mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Graphing cleanup (#14492)
* WIP * Fixes and cleanups * Move parseAtTime to Time util class * lint fixes, explicitly define variables * Style fixes
This commit is contained in:
@@ -27,6 +27,7 @@ namespace LibreNMS\Tests;
|
||||
|
||||
use LibreNMS\Device\YamlDiscovery;
|
||||
use LibreNMS\Util\Rewrite;
|
||||
use LibreNMS\Util\Time;
|
||||
|
||||
class FunctionsTest extends TestCase
|
||||
{
|
||||
@@ -102,20 +103,20 @@ class FunctionsTest extends TestCase
|
||||
|
||||
public function testParseAtTime()
|
||||
{
|
||||
$this->assertEquals(time(), parse_at_time('now'), 'now did not match');
|
||||
$this->assertEquals(time() + 180, parse_at_time('+3m'), '+3m did not match');
|
||||
$this->assertEquals(time() + 7200, parse_at_time('+2h'), '+2h did not match');
|
||||
$this->assertEquals(time() + 172800, parse_at_time('+2d'), '+2d did not match');
|
||||
$this->assertEquals(time() + 63115200, parse_at_time('+2y'), '+2y did not match');
|
||||
$this->assertEquals(time() - 180, parse_at_time('-3m'), '-3m did not match');
|
||||
$this->assertEquals(time() - 7200, parse_at_time('-2h'), '-2h did not match');
|
||||
$this->assertEquals(time() - 172800, parse_at_time('-2d'), '-2d did not match');
|
||||
$this->assertEquals(time() - 63115200, parse_at_time('-2y'), '-2y did not match');
|
||||
$this->assertEquals(429929439, parse_at_time('429929439'));
|
||||
$this->assertEquals(212334234, parse_at_time(212334234));
|
||||
$this->assertEquals(time() - 43, parse_at_time('-43'), '-43 did not match');
|
||||
$this->assertEquals(0, parse_at_time('invalid'));
|
||||
$this->assertEquals(606614400, parse_at_time('March 23 1989 UTC'));
|
||||
$this->assertEquals(time() + 86400, parse_at_time('+1 day'));
|
||||
$this->assertEquals(time(), Time::parseAt('now'), 'now did not match');
|
||||
$this->assertEquals(time() + 180, Time::parseAt('+3m'), '+3m did not match');
|
||||
$this->assertEquals(time() + 7200, Time::parseAt('+2h'), '+2h did not match');
|
||||
$this->assertEquals(time() + 172800, Time::parseAt('+2d'), '+2d did not match');
|
||||
$this->assertEquals(time() + 63115200, Time::parseAt('+2y'), '+2y did not match');
|
||||
$this->assertEquals(time() - 180, Time::parseAt('-3m'), '-3m did not match');
|
||||
$this->assertEquals(time() - 7200, Time::parseAt('-2h'), '-2h did not match');
|
||||
$this->assertEquals(time() - 172800, Time::parseAt('-2d'), '-2d did not match');
|
||||
$this->assertEquals(time() - 63115200, Time::parseAt('-2y'), '-2y did not match');
|
||||
$this->assertEquals(429929439, Time::parseAt('429929439'));
|
||||
$this->assertEquals(212334234, Time::parseAt(212334234));
|
||||
$this->assertEquals(time() - 43, Time::parseAt('-43'), '-43 did not match');
|
||||
$this->assertEquals(0, Time::parseAt('invalid'));
|
||||
$this->assertEquals(606614400, Time::parseAt('March 23 1989 UTC'));
|
||||
$this->assertEquals(time() + 86400, Time::parseAt('+1 day'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user