1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class BlogTagsCloudWidgetTest extends SapphireTest { |
|
|
|
|
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @var string |
7
|
|
|
*/ |
8
|
|
|
public static $fixture_file = 'blog.yml'; |
9
|
|
|
|
10
|
|
|
public function testGetCMSFields() { |
11
|
|
|
if (!class_exists('Widget')) { |
12
|
|
|
$this->markTestSkipped('Widgets module not installed'); |
|
|
|
|
13
|
|
|
} |
14
|
|
|
|
15
|
|
|
$widget = new BlogTagsCloudWidget(); |
16
|
|
|
$fields = $widget->getCMSFields(); |
17
|
|
|
$names = array(); |
18
|
|
|
foreach ($fields as $field) { |
19
|
|
|
array_push($names, $field->getName()); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
$expected = array('Title', 'Enabled', 'BlogID'); |
23
|
|
|
$this->assertEquals($expected, $names); |
|
|
|
|
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function testGetTags() { |
27
|
|
|
if (!class_exists('Widget')) { |
28
|
|
|
$this->markTestSkipped('Widgets module not installed'); |
|
|
|
|
29
|
|
|
} |
30
|
|
|
$widget = new BlogTagsCloudWidget(); |
31
|
|
|
$blog = $this->objFromFixture('Blog', 'FourthBlog'); |
32
|
|
|
$widget->BlogID = $blog->ID; |
33
|
|
|
$widget->write(); |
34
|
|
|
$tags = $widget->getTags()->toArray(); |
35
|
|
|
|
36
|
|
|
$tag = $tags[0]; |
37
|
|
|
$this->assertEquals('Cat', $tag->TagName); |
|
|
|
|
38
|
|
|
$this->assertEquals('/fourth-blog/tag/cat', $tag->Link); |
|
|
|
|
39
|
|
|
$this->assertEquals(2, $tag->TagCount); |
|
|
|
|
40
|
|
|
$this->assertEquals(5, $tag->NormalizedTag); |
|
|
|
|
41
|
|
|
|
42
|
|
|
$tag = $tags[1]; |
43
|
|
|
$this->assertEquals('Cool', $tag->TagName); |
|
|
|
|
44
|
|
|
$this->assertEquals('/fourth-blog/tag/cool', $tag->Link); |
|
|
|
|
45
|
|
|
$this->assertEquals(3, $tag->TagCount); |
|
|
|
|
46
|
|
|
$this->assertEquals(8, $tag->NormalizedTag); |
|
|
|
|
47
|
|
|
|
48
|
|
|
$tag = $tags[2]; |
49
|
|
|
$this->assertEquals('Kiwi', $tag->TagName); |
|
|
|
|
50
|
|
|
$this->assertEquals('/fourth-blog/tag/kiwi', $tag->Link); |
|
|
|
|
51
|
|
|
$this->assertEquals(1, $tag->TagCount); |
|
|
|
|
52
|
|
|
$this->assertEquals(3, $tag->NormalizedTag); |
|
|
|
|
53
|
|
|
|
54
|
|
|
$tag = $tags[3]; |
55
|
|
|
$this->assertEquals('Popular', $tag->TagName); |
|
|
|
|
56
|
|
|
$this->assertEquals('/fourth-blog/tag/popular', $tag->Link); |
|
|
|
|
57
|
|
|
$this->assertEquals(4, $tag->TagCount); |
|
|
|
|
58
|
|
|
$this->assertEquals(10, $tag->NormalizedTag); |
|
|
|
|
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|
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.