Completed
Push — master ( 6ca4bd...61c879 )
by mw
06:26
created

IcalTimezoneFormatterTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

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 3
nc 1
nop 0
1
<?php
2
3
namespace SRF\Tests\iCalendar;
4
5
use SRF\iCalendar\IcalTimezoneFormatter;
6
use SMW\Tests\TestEnvironment;
7
8
/**
9
 * @covers \SRF\iCalendar\IcalTimezoneFormatter
10
 * @group semantic-result-formats
11
 *
12
 * @license GNU GPL v2+
13
 * @since 3.0
14
 *
15
 * @author mwjames
16
 */
17
class IcalTimezoneFormatterTest extends \PHPUnit_Framework_TestCase {
18
19
	private $stringValidator;
20
21
	protected function setUp() {
22
		parent::setUp();
23
24
		$this->stringValidator = TestEnvironment::newValidatorFactory()->newStringValidator();
25
	}
26
27
	public function testCanConstruct() {
28
29
		$this->assertInstanceOf(
30
			IcalTimezoneFormatter::class,
31
			new IcalTimezoneFormatter()
32
		);
33
	}
34
35
	/**
36
	 * @dataProvider transitionsProvider
37
	 */
38
	public function testGetTransitions( $tz, $from, $to, $expected ) {
39
40
		$instance = new IcalTimezoneFormatter();
41
		$instance->setLocalTimezones( $tz );
42
		$instance->calcTransitions(  $from, $to );
43
44
		$this->stringValidator->assertThatStringContains(
45
			$expected,
46
			$instance->getTransitions()
47
		);
48
	}
49
50
	public function transitionsProvider() {
51
52
		// DTSTART can be different pending the OS hence use .*
53
54
		yield [
55
			'UTC',
56
			1,
57
			2,
58
			"BEGIN:VTIMEZONE\r\nTZID:UTC\r\nBEGIN:STANDARD\r\nDTSTART:.*\r\nTZOFFSETFROM:+0000\r\nTZOFFSETTO:+0000\r\nTZNAME:UTC\r\nEND:STANDARD\r\nEND:VTIMEZONE\r\n"
59
		];
60
	}
61
62
}
63