|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
class CollectionExtensionTest extends FunctionalTest |
|
4
|
|
|
{ |
|
5
|
|
|
/** |
|
6
|
|
|
* @var string |
|
7
|
|
|
*/ |
|
8
|
|
|
protected static $fixture_file = array( |
|
9
|
|
|
'collection/tests/fixtures.yml', |
|
10
|
|
|
); |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @var bool |
|
14
|
|
|
*/ |
|
15
|
|
|
protected static $disable_themes = true; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @var bool |
|
19
|
|
|
*/ |
|
20
|
|
|
protected static $use_draft_site = false; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var array |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $extraDataObjects = array( |
|
26
|
|
|
'TestCollection', |
|
27
|
|
|
'TestCollection_Controller', |
|
28
|
|
|
'TestCollectionObject', |
|
29
|
|
|
); |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* |
|
33
|
|
|
*/ |
|
34
|
|
|
public function setUp() |
|
35
|
|
|
{ |
|
36
|
|
|
parent::setUp(); |
|
37
|
|
|
|
|
38
|
|
|
ini_set('display_errors', 1); |
|
39
|
|
|
ini_set('log_errors', 1); |
|
40
|
|
|
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* |
|
45
|
|
|
*/ |
|
46
|
|
|
public function logOut() |
|
47
|
|
|
{ |
|
48
|
|
|
$this->session()->clear('loggedInAs'); |
|
49
|
|
|
$this->session()->clear('logInWithPermission'); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* |
|
54
|
|
|
*/ |
|
55
|
|
|
public function testGetCollection() |
|
56
|
|
|
{ |
|
57
|
|
|
$object = $this->objFromFixture('TestCollection', 'default'); |
|
58
|
|
|
$controller = new TestCollection_Controller($object); |
|
59
|
|
|
$this->assertInstanceOf('DataList', $controller->getCollection()); |
|
60
|
|
|
|
|
61
|
|
|
$object = $controller->config()->managed_object; |
|
62
|
|
|
$this->assertInstanceOf($object, $controller->getCollection()->first()); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* |
|
67
|
|
|
*/ |
|
68
|
|
|
public function testGetManagedObject() |
|
69
|
|
|
{ |
|
70
|
|
|
$object = TestCollection_Controller::create(); |
|
71
|
|
|
$expected = 'TestCollectionObject'; |
|
72
|
|
|
$this->assertEquals($expected, $object->getCollectionObject()); |
|
|
|
|
|
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* |
|
77
|
|
|
*/ |
|
78
|
|
|
public function testGetPageSize() |
|
79
|
|
|
{ |
|
80
|
|
|
$object = TestCollection_Controller::create(); |
|
81
|
|
|
$expected = 10; |
|
82
|
|
|
$this->assertEquals($expected, $object->getCollectionSize()); |
|
|
|
|
|
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* |
|
87
|
|
|
*/ |
|
88
|
|
|
public function testPaginatedList() |
|
89
|
|
|
{ |
|
90
|
|
|
$object = $this->objFromFixture('TestCollection', 'default'); |
|
91
|
|
|
$controller = new TestCollection_Controller($object); |
|
92
|
|
|
$this->assertInstanceOf('PaginatedList', $controller->PaginatedList()); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* |
|
97
|
|
|
*/ |
|
98
|
|
|
public function testGroupedList() |
|
99
|
|
|
{ |
|
100
|
|
|
$object = $this->objFromFixture('TestCollection', 'default'); |
|
101
|
|
|
$controller = new TestCollection_Controller($object); |
|
102
|
|
|
$this->assertInstanceOf('GroupedList', $controller->GroupedList()); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* |
|
107
|
|
|
*/ |
|
108
|
|
|
public function testCollectionSearchForm() |
|
109
|
|
|
{ |
|
110
|
|
|
$object = $this->objFromFixture('TestCollection', 'default'); |
|
111
|
|
|
$controller = new TestCollection_Controller($object); |
|
112
|
|
|
$this->assertInstanceOf('Form', $controller->CollectionSearchForm()); |
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* Class TestCollection. |
|
118
|
|
|
*/ |
|
119
|
|
|
class TestCollection extends Page implements TestOnly |
|
|
|
|
|
|
120
|
|
|
{ |
|
121
|
|
|
|
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
class TestCollection_Controller extends Page_Controller implements TestOnly |
|
|
|
|
|
|
125
|
|
|
{ |
|
126
|
|
|
private static $managed_object = 'TestCollectionObject'; |
|
|
|
|
|
|
127
|
|
|
|
|
128
|
|
|
private static $extensions = ['CollectionExtension']; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
class TestCollectionObject extends Dataobject implements TestOnly |
|
|
|
|
|
|
132
|
|
|
{ |
|
133
|
|
|
private static $db = [ |
|
134
|
|
|
'Title' => 'Varchar(255)', |
|
135
|
|
|
]; |
|
136
|
|
|
|
|
137
|
|
|
public function getSortOptions() |
|
138
|
|
|
{ |
|
139
|
|
|
return array( |
|
140
|
|
|
'Created' => 'Date', |
|
141
|
|
|
'Title' => 'Name A-Z', |
|
142
|
|
|
'Title DESC' => 'Name Z-A', |
|
143
|
|
|
); |
|
144
|
|
|
} |
|
145
|
|
|
} |
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.