Skip to content

Commit

Permalink
Do not depend on RB for utility test
Browse files Browse the repository at this point in the history
  • Loading branch information
driusan committed Dec 16, 2020
1 parent 3bf3057 commit 81deef5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion php/libraries/Utility.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -851,8 +851,10 @@ class Utility
"Input must be a valid date/time string: $e"
);
}

$factory = \NDB_Factory::singleton();
return $dt->format(
\NDB_Config::singleton()->getSetting('dateDisplayFormat')
$factory->config()->getSetting('dateDisplayFormat')
?? DateTime::ATOM
);
}
Expand Down
7 changes: 7 additions & 0 deletions test/unittests/UtilityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,13 @@ public function testRandomString()
public function testToDateDisplayFormat()
{
$this->_setMockDB();

$config = $this->getMockBuilder("\NDB_Config")->getMock();
$config->expects($this->any())
->method('getSetting')
->willReturn('Y-m-d H:i:s');
$this->_mockFactory->setConfig($config);

$date = "2000-01-01";
$this->assertEquals(
"2000-01-01 00:00:00",
Expand Down

0 comments on commit 81deef5

Please sign in to comment.