Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Push — master ( 64adfe...7d96ad )
by Dan
34s queued 16s
created

EpochTest::test_update_cli()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 14
rs 10
1
<?php declare(strict_types=1);
2
3
namespace SmrTest\lib\DefaultGame;
4
5
use Smr\Epoch;
6
7
/**
8
 * @covers Smr\Epoch
9
 */
10
class EpochTest extends \PHPUnit\Framework\TestCase {
11
12
	/**
13
	 * Test that the `update` function works properly when NPC_SCRIPT is set.
14
	 * We run in a separate process so that the constant doesn't propagate into
15
	 * other tests.
16
	 * @runInSeparateProcess
17
	 */
18
	public function test_update_cli() {
19
		// Set the NPC_SCRIPT variable as if this were a CLI program
20
		define('NPC_SCRIPT', true);
21
22
		$time = Epoch::time();
23
		$microtime = Epoch::microtime();
24
25
		// Sleep 1 second to ensure that the integer time has incremented
26
		sleep(1);
27
		Epoch::update();
28
29
		// Make sure the times have changed
30
		$this->assertNotEquals($time, Epoch::time());
31
		$this->assertNotEquals($microtime, Epoch::microtime());
32
	}
33
34
	/**
35
	 * update should throw if called without NPC_SCRIPT defined.
36
	 */
37
	public function test_update() {
38
		$this->expectException(\Exception::class);
39
		$this->expectExceptionMessage('Only call this function from CLI programs');
40
		Epoch::update();
41
	}
42
43
	/**
44
	 * We can't check the time/microtime values, but we can ensure that
45
	 * the rounded values are identical.
46
	 */
47
	public function test_time_microtime_equality() {
48
		$this->assertEquals(Epoch::time(), floor(Epoch::microtime()));
49
	}
50
51
}
52