Passed
Push — main ( 40d4d0...b1f2dd )
by N.
05:04
created

SpelAjaxTest::testSpelAjax()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 42
Code Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 29
nc 1
nop 0
dl 0
loc 42
rs 9.456
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Klass SpelAjaxTest.
5
 * Författare: Niklas Dougherty
6
 */
7
8
declare(strict_types=1);
9
10
namespace Tips\Tests\Ajax;
11
12
use PHPUnit\Framework\TestCase;
13
use Tips\Klasser\Spel;
14
use Tips\Ajax\SpelAjax;
15
use Tips\Klasser\Utdelning;
16
use Tips\Klasser\Preludium;
17
use Tips\Klasser\Tips;
18
use Tips\Moduler\TT;
19
20
/**
21
 * Klass SpelAjaxTest.
22
 */
23
class SpelAjaxTest extends TestCase
24
{
25
	/**
26
	 * Construct object with argument and verify that the object has the expected properties.
27
	 */
28
	public function testSpelAjax(): void
29
	{
30
		new Preludium();
31
32
		/**
33
		 * Preparera.
34
		 */
35
		$_REQUEST['ändra_speltyp'] = '1';
36
		new SpelAjax();
37
		unset($_REQUEST['ändra_speltyp']);
38
39
		$_REQUEST['ändra_omgång'] = '4905';
40
		$spelajax = new SpelAjax();
41
		$spel = new Spel();
42
		$this->assertInstanceOf("\Tips\Ajax\SpelAjax", $spelajax);
43
		$this->assertInstanceOf("\Tips\Klasser\Spel", $spel);
44
		$this->assertEquals($spel->speltyp->value, 1);
45
		unset($_REQUEST['ändra_omgång']);
46
47
		// Ändra till Europatips
48
		$_REQUEST['ändra_speltyp'] = '2';
49
		new SpelAjax();
50
		$spel = new Spel();
51
		$this->assertEquals($spel->speltyp->value, 2);
52
		unset($_REQUEST['ändra_speltyp']);
53
54
		// Ändra till Stryktips
55
		$_REQUEST['ändra_speltyp'] = '1';
56
		new SpelAjax();
57
		$spel = new Spel();
58
		$this->assertEquals($spel->speltyp->value, 1);
59
		unset($_REQUEST['ändra_speltyp']);
60
61
		$utd = new Utdelning($spel);
62
		$utd->hämta_utdelning();
63
		$this->assertEquals($utd->utdelning[0], 21112);
64
65
		$_REQUEST['ändra_omgång'] = '0';
66
		new SpelAjax();
67
		$spel = new Spel();
68
		$this->assertEquals($spel->omgång, 4905);
69
		unset($_REQUEST['ändra_omgång']);
70
	}
71
}
72