|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
class GalleryPageTest extends SapphireTest |
|
|
|
|
|
|
4
|
|
|
{ |
|
5
|
|
|
protected static $fixture_file = 'ss3gallery/tests/ss3gallery.yml'; |
|
6
|
|
|
|
|
7
|
|
View Code Duplication |
public function testGetCMSFields() |
|
|
|
|
|
|
8
|
|
|
{ |
|
9
|
|
|
$gp = new GalleryPage(); |
|
10
|
|
|
$tab = $gp->getCMSFields()->fieldByName('Root.Main'); |
|
11
|
|
|
$fields = $tab->FieldList(); |
|
12
|
|
|
$names = array(); |
|
13
|
|
|
foreach ($fields as $field) { |
|
14
|
|
|
array_push($names, $field->getName()); |
|
15
|
|
|
} |
|
16
|
|
|
$expected = array('InstallWarningHeader', 'Title', 'URLSegment', |
|
17
|
|
|
'MenuTitle', 'BriefIntroduction', 'Content'); |
|
18
|
|
|
$this->assertEquals($expected, $names); |
|
|
|
|
|
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
public function testGalleryWithMappedImages() |
|
22
|
|
|
{ |
|
23
|
|
|
$gp = $this->objFromFixture('GalleryPage', 'gp01'); |
|
24
|
|
|
$map = $gp->Map()->forTemplate()->getValue(); |
|
25
|
|
|
|
|
26
|
|
|
// Use assert contains to check for map related HTML |
|
27
|
|
|
$this->assertContains('div id="google_map_1" data-google-map-lang="en" style="width:100%; height: 400px;"', $map); |
|
28
|
|
|
$this->assertContains('class="fullWidthMap mappable', $map); |
|
29
|
|
|
$this->assertContains('data-map', $map); |
|
30
|
|
|
$this->assertContains('data-centre=\'{"lat":48.856614,"lng":2.3522219}\'', $map); |
|
31
|
|
|
// Markers are tricky as SQLite does not have trailing zeroes. Assert sig dig only |
|
32
|
|
|
$this->assertContains('13.2', $map); |
|
33
|
|
|
$this->assertContains('13.14', $map); |
|
34
|
|
|
$this->assertContains('13.4', $map); |
|
35
|
|
|
$this->assertContains('100.1', $map); |
|
36
|
|
|
$this->assertContains('99.7', $map); |
|
37
|
|
|
$this->assertContains('104.2', $map); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function testGalleryWithMoMappedImages() |
|
41
|
|
|
{ |
|
42
|
|
|
// zeroed coordinates mean no location |
|
43
|
|
|
foreach (GalleryImage::get() as $gi) { |
|
44
|
|
|
$gi->Lat = 0; |
|
45
|
|
|
$gi->Lon = 0; |
|
46
|
|
|
$gi->write(); |
|
47
|
|
|
} |
|
48
|
|
|
$gp = $this->objFromFixture('GalleryPage', 'gp01'); |
|
49
|
|
|
$map = $gp->Map(); |
|
50
|
|
|
|
|
51
|
|
|
$this->assertEquals('<!-- no image locations found -->', $map); |
|
|
|
|
|
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function testGetGalleryImages() |
|
55
|
|
|
{ |
|
56
|
|
|
$this->markTestSkipped('TODO'); |
|
|
|
|
|
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.