1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
<?php
declare( strict_types = 1 );
namespace ModernTimeline\Tests\Unit\SlidePresenter;
use ModernTimeline\ResultFacade\PropertyValueCollection;
use ModernTimeline\ResultFacade\Subject;
use ModernTimeline\SlidePresenter\TemplateSlidePresenter;
use PHPUnit\Framework\TestCase;
use SMW\DIWikiPage;
use SMW\Query\PrintRequest;
use SMWDITime;
/**
* @covers \ModernTimeline\SlidePresenter\TemplateSlidePresenter
*/
class TemplateSlidePresenterTest extends TestCase {
private const PAGE_NAME = 'Some Page';
public function testTemplate() {
$this->assertSame(
'{{TemplateName|title=Some Page|Has date=2 August 2019 16:07:42|End date=5 August 2019 17:39:23}}',
( new TemplateSlidePresenter( 'TemplateName' ) )->getTemplateText( $this->newSinglePageWithStartAndEndDate() )
);
}
private function newSinglePageWithStartAndEndDate(): Subject {
return new Subject(
$this->newDiWikiPage(),
[
new PropertyValueCollection(
$this->newDatePrintRequestWithLabel( 'Has date' ),
[
new SMWDITime(
SMWDITime::CM_GREGORIAN,
2019,
8,
2,
16,
7,
42
)
]
),
new PropertyValueCollection(
$this->newDatePrintRequestWithLabel( 'End date' ),
[
new SMWDITime(
SMWDITime::CM_GREGORIAN,
2019,
8,
5,
17,
39,
23
)
]
)
]
);
}
private function newDiWikiPage(): DIWikiPage {
$page = $this->createMock( DIWikiPage::class );
$page->method( 'getTitle' )->willReturn( \Title::newFromText( self::PAGE_NAME ) );
return $page;
}
private function newDatePrintRequestWithLabel( string $label ): PrintRequest {
$pr = $this->createMock( PrintRequest::class );
$pr->method( 'getLabel' )->willReturn( $label );
$pr->method( 'getText' )->willReturn( $label );
$pr->method( 'getTypeID' )->willReturn( '_dat' );
return $pr;
}
}
|