1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class ShortlistTest extends FunctionalTest |
4
|
|
|
{ |
5
|
|
|
protected static $fixture_file = 'fixtures.yml'; |
6
|
|
|
|
7
|
|
|
public function testShortlistCreation() |
8
|
|
|
{ |
9
|
|
|
$shortlists = ShortList::get(); |
10
|
|
|
|
11
|
|
|
$this->get('shortlist'); |
12
|
|
|
|
13
|
|
|
$this->assertNotEquals($shortlists->Count(), 0); |
|
|
|
|
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
public function testAddItemtoShortList() |
17
|
|
|
{ |
18
|
|
|
$testpage = $this->objFromFixture('Page', 'page1'); |
19
|
|
|
|
20
|
|
|
// create the shortlist |
21
|
|
|
$shortlist = new ShortList(); |
22
|
|
|
$shortlist->write(); |
23
|
|
|
|
24
|
|
|
$this->assertEquals($shortlist->ShortListItems()->Count(), 0); |
|
|
|
|
25
|
|
|
|
26
|
|
|
// create the item. |
27
|
|
|
$item = new ShortListItem(); |
28
|
|
|
$item->ItemType = $testpage->ClassName; |
|
|
|
|
29
|
|
|
$item->ItemID = $testpage->ID; |
|
|
|
|
30
|
|
|
$item->write(); |
31
|
|
|
|
32
|
|
|
// add to the shortlist. |
33
|
|
|
$shortlist->ShortListItems()->add($item); |
|
|
|
|
34
|
|
|
$shortlist->write(); |
35
|
|
|
|
36
|
|
|
// do we have an item added? |
37
|
|
|
$this->assertNotEquals($shortlist->ShortListItems()->Count(), 0); |
|
|
|
|
38
|
|
|
// what about the reverse side? |
39
|
|
|
$this->assertNotEquals($item->ShortList()->ID, 0); |
|
|
|
|
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function testRemoveItemFromShortList() |
43
|
|
|
{ |
44
|
|
|
$testpage = $this->objFromFixture('Page', 'page1'); |
45
|
|
|
|
46
|
|
|
// create the shortlist |
47
|
|
|
$shortlist = new ShortList(); |
48
|
|
|
$shortlist->write(); |
49
|
|
|
|
50
|
|
|
$this->assertEquals($shortlist->ShortListItems()->Count(), 0); |
|
|
|
|
51
|
|
|
|
52
|
|
|
// create the item. |
53
|
|
|
$item = new ShortListItem(); |
54
|
|
|
$item->ItemType = $testpage->ClassName; |
|
|
|
|
55
|
|
|
$item->ItemID = $testpage->ID; |
|
|
|
|
56
|
|
|
$item->write(); |
57
|
|
|
|
58
|
|
|
// add to the shortlist. |
59
|
|
|
$shortlist->ShortListItems()->add($item); |
|
|
|
|
60
|
|
|
$shortlist->write(); |
61
|
|
|
|
62
|
|
|
// do we have an item added? |
63
|
|
|
$this->assertNotEquals($shortlist->ShortListItems()->Count(), 0); |
|
|
|
|
64
|
|
|
// what about the reverse side? |
65
|
|
|
$this->assertNotEquals($item->ShortList()->ID, 0); |
|
|
|
|
66
|
|
|
|
67
|
|
|
$shortlist->ShortListItems()->remove($item); |
|
|
|
|
68
|
|
|
|
69
|
|
|
// do we have an item removed? |
70
|
|
|
$this->assertEquals($shortlist->ShortListItems()->Count(), 0); |
|
|
|
|
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.