@@ -9,100 +9,100 @@ |
||
9 | 9 | |
10 | 10 | class EventHolderTest extends SapphireTest |
11 | 11 | { |
12 | - protected static $fixture_file = 'EventHolderTest.yml'; |
|
13 | - |
|
14 | - public function testEventTags() |
|
15 | - { |
|
16 | - $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
17 | - |
|
18 | - $tags = $holder->UpdateTags(); |
|
19 | - $this->assertNotNull($tags->find('Name', 'Future'), 'Finds present terms.'); |
|
20 | - $this->assertNull($tags->find('Name', 'Event types', 'Does not find top level taxonomy.')); |
|
21 | - $this->assertNull($tags->find('Name', 'Carrot'), 'Does not find terms that are not applied.'); |
|
22 | - } |
|
23 | - |
|
24 | - public function testEventWithParentFilter() |
|
25 | - { |
|
26 | - $holder = $this->objFromFixture(EventHolder::class, 'EventHolder2'); |
|
27 | - |
|
28 | - $items = $holder->Updates(); |
|
29 | - |
|
30 | - $this->assertNotNull($items->find('URLSegment', 'other-holder'), 'Event from the holder is shown.'); |
|
31 | - $this->assertNull($items->find('URLSegment', 'future-event-1'), 'Events from other holders are not shown.'); |
|
32 | - } |
|
33 | - |
|
34 | - public function testEventsWithTagFilter() |
|
35 | - { |
|
36 | - $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
37 | - |
|
38 | - //Get the "Future" tag. |
|
39 | - $tag = $this->objFromFixture(TaxonomyTerm::class, 'TaxonomyTerm1'); |
|
40 | - |
|
41 | - $items = $holder->Updates($tag->ID); |
|
42 | - |
|
43 | - $this->assertNotNull($items->find('URLSegment', 'future-event-1'), 'Finds the tagged page.'); |
|
44 | - $this->assertNull($items->find('URLSegment', 'past-event-1'), 'Does not find pages that are not tagged.'); |
|
45 | - } |
|
46 | - |
|
47 | - public function testEventsWithMonthFilter() |
|
48 | - { |
|
49 | - $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
50 | - |
|
51 | - $items = $holder->Updates(null, null, null, 2013, 7); |
|
52 | - |
|
53 | - $this->assertNotNull($items->find('URLSegment', 'future-event-1'), 'Finds the event in 2013-07.'); |
|
54 | - $this->assertNull($items->find('URLSegment', 'past-event-1'), 'Does not find events at other dates.'); |
|
55 | - } |
|
56 | - |
|
57 | - public function testEventsWithDateRangeFilter() |
|
58 | - { |
|
59 | - $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
60 | - |
|
61 | - $items = $holder->Updates(null, '2013-01-19', null); |
|
62 | - $this->assertNotNull($items->find('URLSegment', 'past-event-2'), 'Finds the event at the date'); |
|
63 | - $this->assertNull($items->find('URLSegment', 'future-event-1'), 'Does not find the event at another date'); |
|
64 | - |
|
65 | - $items = $holder->Updates(null, '2013-01-01', '2013-01-19'); |
|
66 | - $this->assertNotNull($items->find('URLSegment', 'past-event-2'), 'Finds events in the date range'); |
|
67 | - $this->assertNull($items->find('URLSegment', 'future-event-1'), 'Does not find event out of range'); |
|
68 | - } |
|
69 | - |
|
70 | - public function testExtractMonths() |
|
71 | - { |
|
72 | - // skip test on PGSQL CI, CWP was only designed to work on MySQL |
|
73 | - // DatedUpdateHolder::ExtractMonths contains date functions e.g. YEAR("Date") which don't work in PGSQL |
|
74 | - if (strpos(strtolower(get_class(DB::get_connector())), 'mysql') === false) { |
|
75 | - $this->markTestSkipped('Not running MySQL'); |
|
76 | - } |
|
77 | - |
|
78 | - $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
79 | - |
|
80 | - $months = EventHolder::ExtractMonths( |
|
81 | - $holder->Updates(), |
|
82 | - 'http://mybase.org/?tag=12&start=10&from=2010-10-10&to=2010-10-11', // Used for link generation |
|
83 | - 2013, // Currently selected |
|
84 | - 1 // Currently selected |
|
85 | - ); |
|
86 | - |
|
87 | - // Check which years are generated. |
|
88 | - $this->assertNotNull($months->find('YearName', 2013), 'Generates existing year'); |
|
89 | - $this->assertNull($months->find('YearName', 1990), 'Does not generate non-present year'); |
|
90 | - |
|
91 | - $year = $months->find('YearName', 2013); |
|
92 | - |
|
93 | - // Check which months come up in 2013 |
|
94 | - $this->assertNotNull($year['Months']->find('MonthNumber', 7), 'Generates existing month'); |
|
95 | - $this->assertNull($year['Months']->find('MonthNumber', 12), 'Does not generate non-present month'); |
|
96 | - |
|
97 | - $month = $year['Months']->find('MonthNumber', 7); |
|
98 | - $this->assertEquals( |
|
99 | - $month['MonthLink'], |
|
100 | - 'http://mybase.org/?tag=12&from=2010-10-10&to=2010-10-11&month=7&year=2013', |
|
101 | - 'Selection link is built properly - start is removed, and tag, from and to retained.' |
|
102 | - ); |
|
103 | - |
|
104 | - // Check if these months are marked properly. |
|
105 | - $month = $year['Months']->find('MonthNumber', 1); |
|
106 | - $this->assertEquals($month['Active'], true, 'Correctly marks active link'); |
|
107 | - } |
|
12 | + protected static $fixture_file = 'EventHolderTest.yml'; |
|
13 | + |
|
14 | + public function testEventTags() |
|
15 | + { |
|
16 | + $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
17 | + |
|
18 | + $tags = $holder->UpdateTags(); |
|
19 | + $this->assertNotNull($tags->find('Name', 'Future'), 'Finds present terms.'); |
|
20 | + $this->assertNull($tags->find('Name', 'Event types', 'Does not find top level taxonomy.')); |
|
21 | + $this->assertNull($tags->find('Name', 'Carrot'), 'Does not find terms that are not applied.'); |
|
22 | + } |
|
23 | + |
|
24 | + public function testEventWithParentFilter() |
|
25 | + { |
|
26 | + $holder = $this->objFromFixture(EventHolder::class, 'EventHolder2'); |
|
27 | + |
|
28 | + $items = $holder->Updates(); |
|
29 | + |
|
30 | + $this->assertNotNull($items->find('URLSegment', 'other-holder'), 'Event from the holder is shown.'); |
|
31 | + $this->assertNull($items->find('URLSegment', 'future-event-1'), 'Events from other holders are not shown.'); |
|
32 | + } |
|
33 | + |
|
34 | + public function testEventsWithTagFilter() |
|
35 | + { |
|
36 | + $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
37 | + |
|
38 | + //Get the "Future" tag. |
|
39 | + $tag = $this->objFromFixture(TaxonomyTerm::class, 'TaxonomyTerm1'); |
|
40 | + |
|
41 | + $items = $holder->Updates($tag->ID); |
|
42 | + |
|
43 | + $this->assertNotNull($items->find('URLSegment', 'future-event-1'), 'Finds the tagged page.'); |
|
44 | + $this->assertNull($items->find('URLSegment', 'past-event-1'), 'Does not find pages that are not tagged.'); |
|
45 | + } |
|
46 | + |
|
47 | + public function testEventsWithMonthFilter() |
|
48 | + { |
|
49 | + $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
50 | + |
|
51 | + $items = $holder->Updates(null, null, null, 2013, 7); |
|
52 | + |
|
53 | + $this->assertNotNull($items->find('URLSegment', 'future-event-1'), 'Finds the event in 2013-07.'); |
|
54 | + $this->assertNull($items->find('URLSegment', 'past-event-1'), 'Does not find events at other dates.'); |
|
55 | + } |
|
56 | + |
|
57 | + public function testEventsWithDateRangeFilter() |
|
58 | + { |
|
59 | + $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
60 | + |
|
61 | + $items = $holder->Updates(null, '2013-01-19', null); |
|
62 | + $this->assertNotNull($items->find('URLSegment', 'past-event-2'), 'Finds the event at the date'); |
|
63 | + $this->assertNull($items->find('URLSegment', 'future-event-1'), 'Does not find the event at another date'); |
|
64 | + |
|
65 | + $items = $holder->Updates(null, '2013-01-01', '2013-01-19'); |
|
66 | + $this->assertNotNull($items->find('URLSegment', 'past-event-2'), 'Finds events in the date range'); |
|
67 | + $this->assertNull($items->find('URLSegment', 'future-event-1'), 'Does not find event out of range'); |
|
68 | + } |
|
69 | + |
|
70 | + public function testExtractMonths() |
|
71 | + { |
|
72 | + // skip test on PGSQL CI, CWP was only designed to work on MySQL |
|
73 | + // DatedUpdateHolder::ExtractMonths contains date functions e.g. YEAR("Date") which don't work in PGSQL |
|
74 | + if (strpos(strtolower(get_class(DB::get_connector())), 'mysql') === false) { |
|
75 | + $this->markTestSkipped('Not running MySQL'); |
|
76 | + } |
|
77 | + |
|
78 | + $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1'); |
|
79 | + |
|
80 | + $months = EventHolder::ExtractMonths( |
|
81 | + $holder->Updates(), |
|
82 | + 'http://mybase.org/?tag=12&start=10&from=2010-10-10&to=2010-10-11', // Used for link generation |
|
83 | + 2013, // Currently selected |
|
84 | + 1 // Currently selected |
|
85 | + ); |
|
86 | + |
|
87 | + // Check which years are generated. |
|
88 | + $this->assertNotNull($months->find('YearName', 2013), 'Generates existing year'); |
|
89 | + $this->assertNull($months->find('YearName', 1990), 'Does not generate non-present year'); |
|
90 | + |
|
91 | + $year = $months->find('YearName', 2013); |
|
92 | + |
|
93 | + // Check which months come up in 2013 |
|
94 | + $this->assertNotNull($year['Months']->find('MonthNumber', 7), 'Generates existing month'); |
|
95 | + $this->assertNull($year['Months']->find('MonthNumber', 12), 'Does not generate non-present month'); |
|
96 | + |
|
97 | + $month = $year['Months']->find('MonthNumber', 7); |
|
98 | + $this->assertEquals( |
|
99 | + $month['MonthLink'], |
|
100 | + 'http://mybase.org/?tag=12&from=2010-10-10&to=2010-10-11&month=7&year=2013', |
|
101 | + 'Selection link is built properly - start is removed, and tag, from and to retained.' |
|
102 | + ); |
|
103 | + |
|
104 | + // Check if these months are marked properly. |
|
105 | + $month = $year['Months']->find('MonthNumber', 1); |
|
106 | + $this->assertEquals($month['Active'], true, 'Correctly marks active link'); |
|
107 | + } |
|
108 | 108 | } |