1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class GalleryImageTest extends TestWithImage { |
|
|
|
|
4
|
|
|
protected static $fixture_file = 'ss3gallery/tests/ss3gallery.yml'; |
5
|
|
|
|
6
|
|
|
public function testCMSFields() { |
7
|
|
|
$gi = new GalleryImage(); |
8
|
|
|
$fields = $gi->getCMSFields(); |
9
|
|
|
$tab = $fields->findOrMakeTab('Root.Main'); |
10
|
|
|
$fields = $tab->FieldList(); |
11
|
|
|
|
12
|
|
|
$names = array(); |
13
|
|
|
foreach ($fields as $field) { |
14
|
|
|
array_push($names, $field->getName()); |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
$expected = array('Title', 'Caption', 'Aperture', 'ShutterSpeed', |
18
|
|
|
'TakenAt', 'ISO', 'Orientation', 'Image'); |
19
|
|
|
$this->assertEquals($expected, $names); |
20
|
|
|
|
21
|
|
|
$fields = $gi->getCMSFields(); |
22
|
|
|
$tab = $fields->findOrMakeTab('Root.Location'); |
23
|
|
|
$fields = $tab->FieldList(); |
24
|
|
|
|
25
|
|
|
$names = array(); |
26
|
|
|
foreach ($fields as $field) { |
27
|
|
|
array_push($names, $field->getName()); |
28
|
|
|
} |
29
|
|
|
$expected = array('LatLonZoomLevel', 'MapPinIcon'); |
30
|
|
|
$this->assertEquals($expected, $names); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function testGetThumbnail() { |
34
|
|
|
$gi = $this->objFromFixture('GalleryImage', 'gi01'); |
35
|
|
|
$thumbnail = $gi->getThumbnail(); |
36
|
|
|
$this->assertEquals(100, $thumbnail->Width); |
37
|
|
|
$this->assertEquals(100, $thumbnail->Height); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function testGetPortletTitle() { |
|
|
|
|
41
|
|
|
$gi = $this->objFromFixture('GalleryImage', 'gi01'); |
42
|
|
|
$this->assertEquals($gi->Title, $gi->getPortletTitle()); |
43
|
|
|
$gi->Title = 'Another title'; |
44
|
|
|
$this->assertEquals($gi->Title, $gi->getPortletTitle()); |
45
|
|
|
} |
|
|
|
|
46
|
|
|
|
47
|
|
|
public function testGetPortletImage() { |
|
|
|
|
48
|
|
|
$gi = $this->objFromFixture('GalleryImage', 'gi01'); |
|
|
|
|
49
|
|
|
$this->assertEquals($gi->getPortletImage()->Filename, |
|
|
|
|
50
|
|
|
'assets/TestImageSS3Gallery/test.jpg'); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function testGetPortletCaption() { |
54
|
|
|
$gi = $this->objFromFixture('GalleryImage', 'gi01'); |
55
|
|
|
$this->assertEquals('', $gi->getPortletCaption()); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
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.