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

Passed
Pull Request — master (#942)
by Dan
03:56
created

test_getTime_getMicroTime_equality()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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