Skip to content

Commit

Permalink
[PhpUnitBridge] ClockMock does not mock gmdate()
Browse files Browse the repository at this point in the history
  • Loading branch information
Amrouche Hamza committed Apr 12, 2019
1 parent a36fbe3 commit 4046438
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Symfony/Bridge/PhpUnit/ClockMock.php
Expand Up @@ -79,6 +79,14 @@ public static function date($format, $timestamp = null)
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)
{
$self = \get_called_class();
Expand Down Expand Up @@ -122,6 +130,10 @@ function date(\$format, \$timestamp = null)
return \\$self::date(\$format, \$timestamp);
}
function gmdate(\$format, \$timestamp = null)
{
return \\$self::gmdate(\$format, \$timestamp);
}
EOPHP
);
}
Expand Down
7 changes: 7 additions & 0 deletions src/Symfony/Bridge/PhpUnit/Tests/ClockMockTest.php
Expand Up @@ -62,4 +62,11 @@ public function testDate()
{
$this->assertSame('1234567890', date('U'));
}

public function testGmDate()
{
ClockMock::withClockMock(1555075769);

$this->assertSame('1555075769', gmdate('U'));
}
}

0 comments on commit 4046438

Please sign in to comment.