Completed
Push — master ( 2858aa...73eec7 )
by Jeroen De
65:15
created

SkinSettingsTest::testSetSkinValid()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace WMDE\Fundraising\Frontend\Tests\Unit\Presentation;
6
7
use WMDE\Fundraising\Frontend\Presentation\SkinSettings;
8
use PHPUnit\Framework\TestCase;
9
use InvalidArgumentException;
10
11
/**
12
 * @covers \WMDE\Fundraising\Frontend\Presentation\SkinSettings
13
 */
14
class SkinSettingsTest extends TestCase {
15
16
	public function testDefaultSkinIsSet(): void {
17
		$manager = new SkinSettings( ['a', 'b'], 'a', 500 );
18
		$this->assertSame( 'a', $manager->getDefaultSkin() );
19
	}
20
21
	public function testDefaultSkinGetsUsedOnConstruct(): void {
22
		$manager = new SkinSettings( ['a', 'c', 'b'], 'b', 500 );
23
		$this->assertSame( 'b', $manager->getSkin() );
24
	}
25
26
	public function testCookieLifetimeIsSet(): void {
27
		$manager = new SkinSettings( ['a', 'b'], 'a', 500 );
28
		$this->assertSame( 500, $manager->getCookieLifetime() );
29
	}
30
31
	public function testValidateSkin(): void {
32
		$manager = new SkinSettings( ['c', 'd'], 'd', 300 );
33
		$this->assertTrue( $manager->isValidSkin( 'c' ) );
34
		$this->assertFalse( $manager->isValidSkin( 'f' ) );
35
	}
36
37
	public function testSetSkinValid(): void {
38
		$manager = new SkinSettings( ['c', 'd'], 'd', 300 );
39
		$manager->setSkin( 'c' );
40
		$this->assertSame( 'c', $manager->getSkin() );
41
	}
42
43
	/**
44
	 * @expectedException InvalidArgumentException
45
	 * @expectedExceptionMessage 'z' is not a valid skin name
46
	 */
47
	public function testSetSkinInvalid(): void {
48
		$manager = new SkinSettings( ['x', 'y'], 'y', 100 );
49
		$manager->setSkin( 'z' );
50
	}
51
52
	/**
53
	 * @expectedException InvalidArgumentException
54
	 * @expectedExceptionMessage 'init' is not a valid skin name
55
	 */
56
	public function testInvalidDefaultSkin(): void {
57
		new SkinSettings( ['f', 'g'], 'init', 700 );
58
	}
59
60
}
61