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