Completed
Push — master ( b9f247...ba3c73 )
by mw
12:20
created

testParseDate_Year_Month_Day_Time()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 9.456
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace SRF\Tests\iCalendar;
4
5
use SRF\iCalendar\DateParser;
6
7
/**
8
 * @covers \SRF\iCalendar\DateParser
9
 * @group semantic-result-formats
10
 *
11
 * @license GNU GPL v2+
12
 * @since 3.1
13
 *
14
 * @author mwjames
15
 */
16
class DateParserTest extends \PHPUnit_Framework_TestCase {
17
18
	public function testCanConstruct() {
19
20
		$this->assertInstanceOf(
21
			DateParser::class,
22
			new DateParser()
23
		);
24
	}
25
26
	public function testParseDate_Year() {
27
28
		$timeValue = $this->getMockBuilder( '\SMWTimeValue' )
29
			->disableOriginalConstructor()
30
			->getMock();
31
32
		$timeValue->expects( $this->any() )
33
			->method( 'getYear' )
34
			->will( $this->returnValue( 2000 ) );
35
36
		$instance = new DateParser();
37
38
		$this->assertSame(
39
			'20000101',
40
			$instance->parseDate( $timeValue, true )
41
		);
42
	}
43
44
	public function testParseDate_Year_Month_Day_Time() {
45
46
		$timeValue = $this->getMockBuilder( '\SMWTimeValue' )
47
			->disableOriginalConstructor()
48
			->getMock();
49
50
		$timeValue->expects( $this->any() )
51
			->method( 'getYear' )
52
			->will( $this->returnValue( 2000 ) );
53
54
		$timeValue->expects( $this->any() )
55
			->method( 'getMonth' )
56
			->will( $this->returnValue( 12 ) );
57
58
		$timeValue->expects( $this->any() )
59
			->method( 'getDay' )
60
			->will( $this->returnValue( 12 ) );
61
62
		$timeValue->expects( $this->any() )
63
			->method( 'getTimeString' )
64
			->will( $this->returnValue( '12:01:01' ) );
65
66
		$instance = new DateParser();
67
68
		$this->assertSame(
69
			'20001212T120101',
70
			$instance->parseDate( $timeValue, true )
71
		);
72
	}
73
74
}
75