8000 [PhpUnitBridge] ClockMock does not mock gmdate() · symfony/symfony@4046438 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4046438

Browse files
author
Amrouche Hamza
committed
[PhpUnitBridge] ClockMock does not mock gmdate()
1 parent a36fbe3 commit 4046438

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/Symfony/Bridge/PhpUnit/ClockMock.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ public static function date($format, $timestamp = null)
7979
return \date($format, $timestamp);
8080
}
8181

82+
public static function gmdate($format, $timestamp = null)
83+
{
84+
if (null === $timestamp) {
85+
$timestamp = self::time();
86+
}
87+
return \gmdate($format, $timestamp);
88+
}
89+
8290
public static function register($class)
8391
{
8492
$self = \get_called_class();
@@ -122,6 +130,10 @@ function date(\$format, \$timestamp = null)
122130
return \\$self::date(\$format, \$timestamp);
123131
}
124132
133+
function gmdate(\$format, \$timestamp = null)
134+
{
135+
return \\$self::gmdate(\$format, \$timestamp);
136+
}
125137
EOPHP
126138
);
127139
}

src/Symfony/Bridge/PhpUnit/Tests/ClockMockTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,11 @@ public function testDate()
6262
{
6363
$this->assertSame('1234567890', date('U'));
6464
}
65+
66+
public function testGmDate()
67+
{
68+
ClockMock::withClockMock(1555075769);
69+
70+
$this->assertSame('1555075769', gmdate('U'));
71+
}
6572
}

0 commit comments

Comments
 (0)
0