|
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
|
|
|
Session::start(); |
|
20
|
|
|
$sessionID = session_id(); |
|
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
// create the shortlist |
|
23
|
|
|
$shortlist = new ShortList(); |
|
24
|
|
|
$shortlist->write(); |
|
25
|
|
|
|
|
26
|
|
|
$this->assertEquals($shortlist->ShortListItems()->Count(), 0); |
|
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
// create the item. |
|
29
|
|
|
$item = new ShortListItem(); |
|
30
|
|
|
$item->ItemType = $testpage->ClassName; |
|
|
|
|
|
|
31
|
|
|
$item->ItemID = $testpage->ID; |
|
|
|
|
|
|
32
|
|
|
$item->write(); |
|
33
|
|
|
|
|
34
|
|
|
// add to the shortlist. |
|
35
|
|
|
$shortlist->ShortListItems()->add($item); |
|
|
|
|
|
|
36
|
|
|
$shortlist->write(); |
|
37
|
|
|
|
|
38
|
|
|
// do we have an item added? |
|
39
|
|
|
$this->assertNotEquals($shortlist->ShortListItems()->Count(), 0); |
|
|
|
|
|
|
40
|
|
|
// what about the reverse side? |
|
41
|
|
|
$this->assertNotEquals($item->ShortList()->ID, 0); |
|
|
|
|
|
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function testAddPageToShortlist() { |
|
45
|
|
|
$testpage = $this->objFromFixture('Page', 'page1'); |
|
46
|
|
|
Session::start(); |
|
47
|
|
|
$sessionID = session_id(); |
|
48
|
|
|
|
|
49
|
|
|
$response = $this->get('shortlist/add?id=' . $testpage->ID . '&type=Page&s=' . $sessionID); |
|
|
|
|
|
|
50
|
|
|
|
|
51
|
|
|
$shortlist = DataObject::get_one('ShortList', array('SessionID' => $sessionID)); |
|
52
|
|
|
|
|
53
|
|
|
$this->assertNotEquals($shortlist->ShortListItems()->Count(), 0); |
|
|
|
|
|
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function testRemovePageFromShortlist() { |
|
57
|
|
|
$shortlist = $this->objFromFixture('ShortList', 'test'); |
|
|
|
|
|
|
58
|
|
|
$testpage = $this->objFromFixture('Page', 'page1'); |
|
59
|
|
|
|
|
60
|
|
|
$this->get('shortlist/add?id=' . $testpage->ID . '&type=Page&s=' . session_id() . '&output=0'); |
|
61
|
|
|
|
|
62
|
|
|
$shortlist = DataObject::get_one('ShortList', array('SessionID' => session_id())); |
|
63
|
|
|
|
|
64
|
|
|
$this->get('shortlist/remove?id=' . $testpage->ID . '&type=Page&s=' . session_id() . '&output=0'); |
|
65
|
|
|
|
|
66
|
|
|
$this->assertEquals($shortlist->ShortListItems()->Count(), 0); |
|
|
|
|
|
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
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.