1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Class ManageableDataObjectExtensionTest |
5
|
|
|
*/ |
6
|
|
|
class ManageableDataObjectExtensionTest extends FunctionalTest |
|
|
|
|
7
|
|
|
{ |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @var string |
11
|
|
|
*/ |
12
|
|
|
protected static $fixture_file = 'fixtures.yml'; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @var array |
16
|
|
|
*/ |
17
|
|
|
protected $extraDataObjects = [ |
18
|
|
|
SampleManageableDataObject::class, |
19
|
|
|
SampleManageableObjectPage::class, |
20
|
|
|
]; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* |
24
|
|
|
*/ |
25
|
|
|
public function setUp() |
26
|
|
|
{ |
27
|
|
|
parent::setUp(); |
28
|
|
|
// Suppress themes |
29
|
|
|
Config::inst()->remove(SSViewer::class, 'theme'); |
|
|
|
|
30
|
|
|
}//*/ |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Ensure any current member is logged out |
34
|
|
|
*/ |
35
|
|
|
public function logOut() |
36
|
|
|
{ |
37
|
|
|
if ($member = Member::currentUser()) { |
|
|
|
|
38
|
|
|
$member->logOut(); |
39
|
|
|
} |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* |
44
|
|
|
*/ |
45
|
|
|
public function testAdd() |
46
|
|
|
{ |
47
|
|
|
$this->logInWithPermission('MDO_Create'); |
48
|
|
|
$response = $this->get('/SampleManageableObjectPage_Controller/add'); |
49
|
|
|
$this->assertEquals(200, $response->getStatusCode()); |
50
|
|
|
$this->logOut(); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* |
55
|
|
|
*/ |
56
|
|
|
public function testEdit() |
57
|
|
|
{ |
58
|
|
|
$this->logInWithPermission('MDO_Edit'); |
59
|
|
|
$object = $this->objFromFixture(SampleManageableDataObject::class, 'one'); |
60
|
|
|
$response = $this->get('/SampleManageableObjectPage_Controller/edit/' . $object->ID); |
61
|
|
|
$this->assertEquals(200, $response->getStatusCode()); |
62
|
|
|
$this->logOut(); |
63
|
|
|
|
64
|
|
|
$response2 = $this->get('/SampleManageableObjectPage_Controller/edit/' . 0); |
65
|
|
|
$this->assertEquals(404, $response2->getStatusCode()); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* |
70
|
|
|
*/ |
71
|
|
|
public function testDelete() |
72
|
|
|
{ |
73
|
|
|
$newObject = SampleManageableDataObject::create(); |
74
|
|
|
$newObject->Title = 'Foo'; |
75
|
|
|
$newObject->write(); |
76
|
|
|
|
77
|
|
|
$id = $newObject->ID; |
78
|
|
|
|
79
|
|
|
$this->logInWithPermission('MDO_Delete'); |
80
|
|
|
|
81
|
|
|
$response404 = $this->get('/SampleManageableObjectPage_Controller/delete/' . 0); |
82
|
|
|
$this->assertEquals(404, $response404->getStatusCode()); |
83
|
|
|
|
84
|
|
|
$success = $this->get('/SampleManageableObjectPage_Controller/delete/' . $id); |
85
|
|
|
$this->assertEquals(200, $success->getStatusCode()); |
86
|
|
|
$this->assertNull(SampleManageableDataObject::get()->byID($id)); |
87
|
|
|
|
88
|
|
|
$this->logOut(); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* |
93
|
|
|
*/ |
94
|
|
|
public function testDoSaveObject() |
95
|
|
|
{ |
96
|
|
|
$this->logInWithPermission('MDO_Create'); |
97
|
|
|
|
98
|
|
|
$controller = SamplemanageableObjectPage_Controller::create($this->objFromFixture(SampleManageableObjectPage::class, 'one')); |
99
|
|
|
$form = $controller->Form(); |
|
|
|
|
100
|
|
|
|
101
|
|
|
$response = $this->get('/SampleManageableObjectPage_Controller/add'); |
102
|
|
|
$this->assertEquals(200, $response->getStatusCode(), 'Submission successful'); |
103
|
|
|
|
104
|
|
|
$data = ['Title' => 'Foobar']; |
105
|
|
|
$responseSubmission = $this->submitForm('ManageableDataObjectForm_Form', 'action_doSaveObject', $data); |
|
|
|
|
106
|
|
|
|
107
|
|
|
$record = SampleManageableDataObject::get()->filter($data)->first(); |
108
|
|
|
$this->assertInstanceOf(SampleManageableDataObject::class, $record); |
109
|
|
|
$this->assertTrue($record->exists());//*/ |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths