[PhpUnitBridge] ClockMock does not mock gmdate()
This commit is contained in:
parent
2f73c2f66b
commit
b34738bba6
@ -79,11 +79,20 @@ class ClockMock
|
|||||||
return \date($format, $timestamp);
|
return \date($format, $timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function gmdate($format, $timestamp = null)
|
||||||
|
{
|
||||||
|
if (null === $timestamp) {
|
||||||
|
$timestamp = self::time();
|
||||||
|
}
|
||||||
|
|
||||||
|
return \gmdate($format, $timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
public static function register($class)
|
public static function register($class)
|
||||||
{
|
{
|
||||||
$self = \get_called_class();
|
$self = \get_called_class();
|
||||||
|
|
||||||
$mockedNs = array(substr($class, 0, strrpos($class, '\\')));
|
$mockedNs = [substr($class, 0, strrpos($class, '\\'))];
|
||||||
if (0 < strpos($class, '\\Tests\\')) {
|
if (0 < strpos($class, '\\Tests\\')) {
|
||||||
$ns = str_replace('\\Tests\\', '\\', $class);
|
$ns = str_replace('\\Tests\\', '\\', $class);
|
||||||
$mockedNs[] = substr($ns, 0, strrpos($ns, '\\'));
|
$mockedNs[] = substr($ns, 0, strrpos($ns, '\\'));
|
||||||
@ -122,6 +131,10 @@ function date(\$format, \$timestamp = null)
|
|||||||
return \\$self::date(\$format, \$timestamp);
|
return \\$self::date(\$format, \$timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function gmdate(\$format, \$timestamp = null)
|
||||||
|
{
|
||||||
|
return \\$self::gmdate(\$format, \$timestamp);
|
||||||
|
}
|
||||||
EOPHP
|
EOPHP
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -62,4 +62,11 @@ class ClockMockTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->assertSame('1234567890', date('U'));
|
$this->assertSame('1234567890', date('U'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGmDate()
|
||||||
|
{
|
||||||
|
ClockMock::withClockMock(1555075769);
|
||||||
|
|
||||||
|
$this->assertSame('1555075769', gmdate('U'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user