comparison vendor/symfony/phpunit-bridge/Tests/ClockMockTest.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
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 <dominic.tubach@to.com>
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 }