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
Push — live ( 4e4fab...8952b2 )
by Dan
05:48 queued 46s
created

RouteIteratorTest::test_iterator_states()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 32
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 20
nc 2
nop 0
dl 0
loc 32
rs 9.6
c 1
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace SmrTest\lib\DefaultGame\Routes;
4
5
use PHPUnit\Framework\TestCase;
6
use Smr\Path;
7
use Smr\Routes\MultiplePortRoute;
8
use Smr\Routes\OneWayRoute;
9
use Smr\Routes\RouteIterator;
10
11
/**
12
 * @covers Smr\Routes\RouteIterator
13
 */
14
class RouteIteratorTest extends TestCase {
15
16
	public function test_iterator_states(): void {
17
		// Create a 2-port route from 1->2, 2->1
18
		$path1 = new Path(1);
19
		$path1->addLink(2);
20
		$route1 = new OneWayRoute(1, 2, RACE_HUMAN, RACE_HUMAN, 1, 1, $path1, GOODS_WOOD);
21
		$path2 = new Path(2);
22
		$path2->addLink(1);
23
		$route2 = new OneWayRoute(2, 1, RACE_HUMAN, RACE_HUMAN, 1, 1, $path2, GOODS_ORE);
24
		$mpr = new MultiplePortRoute($route1, $route2);
25
26
		$iterator = new RouteIterator($mpr);
27
28
		// Check that the input route can be returned
29
		self::assertSame($mpr, $iterator->getEntireRoute());
30
31
		// Check each state of the iterator until it rewinds
32
		$expectedStates = [
33
			[$route1, $route1->getBuySectorId(), TRADER_BUYS], // initial state
34
			[$route1, $route1->getSellSectorId(), TRADER_SELLS],
35
			[$route2, $route2->getBuySectorId(), TRADER_BUYS],
36
			[$route2, $route2->getSellSectorId(), TRADER_SELLS],
37
			[$route1, $route1->getBuySectorId(), TRADER_BUYS], // return to initial
38
		];
39
40
		foreach ($expectedStates as [$route, $sectorID, $transaction]) {
41
			// Check the state of the iterator
42
			self::assertSame($route, $iterator->getCurrentRoute());
43
			self::assertSame($sectorID, $iterator->getCurrentSectorID());
44
			self::assertSame($transaction, $iterator->getCurrentTransaction());
45
46
			// Advance the iterator
47
			$iterator->next();
48
		}
49
	}
50
51
}
52