Skip to content

Commit 2474c5d

Browse files
Merge branch '3.4' into 4.1
* 3.4: [php_cs] disable fopen_flags [DI] fix error in dumped container [CS] Remove unused variables passed to closures [DI] fix dumping setters before their inlined instances [CS] Remove empty comment [CS] Enforces null type hint on last position in phpDocs [CS] Use combined assignment operators when possible Fix a typo in error messages Don't return early as this bypasses the auto exit feature [Console] Add missing null to input values allowed types [PHPUnitBridge] Fix microtime() format bumped Symfony version to 3.4.17 updated VERSION for 3.4.16 updated CHANGELOG for 3.4.16 bumped Symfony version to 2.8.47 update CONTRIBUTORS for 2.8.46 updated VERSION for 2.8.46 updated CHANGELOG for 2.8.46
2 parents 9b0165e + 76e013a commit 2474c5d

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

ClockMock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static function microtime($asFloat = false)
6666
return self::$now;
6767
}
6868

69-
return sprintf('%0.6f %d', self::$now - (int) self::$now, (int) self::$now);
69+
return sprintf('%0.6f00 %d', self::$now - (int) self::$now, (int) self::$now);
7070
}
7171

7272
public static function register($class)

Tests/ClockMockTest.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\PhpUnit\Tests;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ClockMock;
16+
17+
/**
18+
* @author Dominic Tubach <[email protected]>
19+
*
20+
* @covers \Symfony\Bridge\PhpUnit\ClockMock
21+
*/
22+
class ClockMockTest extends TestCase
23+
{
24+
public static function setUpBeforeClass()
25+
{
26+
ClockMock::register(__CLASS__);
27+
}
28+
29+
protected function setUp()
30+
{
31+
ClockMock::withClockMock(1234567890.125);
32+
}
33+
34+
public function testTime()
35+
{
36+
$this->assertSame(1234567890, time());
37+
}
38+
39+
public function testSleep()
40+
{
41+
sleep(2);
42+
$this->assertSame(1234567892, time());
43+
}
44+
45+
public function testMicrotime()
46+
{
47+
$this->assertSame('0.12500000 1234567890', microtime());
48+
}
49+
50+
public function testMicrotimeAsFloat()
51+
{
52+
$this->assertSame(1234567890.125, microtime(true));
53+
}
54+
55+
public function testUsleep()
56+
{
57+
usleep(2);
58+
$this->assertSame(1234567890.125002, microtime(true));
59+
}
60+
}

0 commit comments

Comments
 (0)