Completed
Push — master ( f4c8b4...9b7bf9 )
by Daniel
16s queued 11s
created

testInheritCanEditFromSiteConfig()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 42
Code Lines 33

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 33
nc 1
nop 0
dl 0
loc 42
rs 8.8571
c 0
b 0
f 0
1
<?php
2
3
namespace SilverStripe\CMS\Tests\Model;
4
5
use SilverStripe\CMS\Model\SiteTree;
6
use SilverStripe\Control\HTTPResponse_Exception;
7
use SilverStripe\Dev\FunctionalTest;
8
use SilverStripe\Security\Group;
9
use SilverStripe\Security\Member;
10
use SilverStripe\Security\Security;
11
use SilverStripe\SiteConfig\SiteConfig;
12
use SilverStripe\Versioned\Versioned;
13
14
/**
15
 * @todo Test canAddChildren()
16
 * @todo Test canCreate()
17
 */
18
class SiteTreePermissionsTest extends FunctionalTest
19
{
20
    protected static $fixture_file = "SiteTreePermissionsTest.yml";
21
22
    protected static $illegal_extensions = [
23
        SiteTree::class => ['SiteTreeSubsites'],
24
    ];
25
26
    public function setUp()
27
    {
28
        parent::setUp();
29
30
        // we're testing HTTP status codes before being redirected to login forms
31
        $this->autoFollowRedirection = false;
32
33
        // Ensure all pages are published
34
        /** @var SiteTree $page */
35
        foreach (SiteTree::get() as $page) {
36
            if ($page->URLSegment !== 'draft-only') {
37
                $page->publishSingle();
38
            }
39
        }
40
    }
41
42
43
    public function testAccessingStageWithBlankStage()
44
    {
45
        $this->autoFollowRedirection = false;
46
47
        /** @var SiteTree $draftOnlyPage */
48
        $draftOnlyPage = $this->objFromFixture(SiteTree::class, 'draftOnlyPage');
49
        $this->logOut();
50
51
        $response = $this->get($draftOnlyPage->URLSegment . '?stage=Live');
52
        $this->assertEquals($response->getStatusCode(), '404');
53
54
        $response = $this->get($draftOnlyPage->URLSegment);
55
        $this->assertEquals($response->getStatusCode(), '404');
56
57
        // should be prompted for a login
58
        try {
59
            $response = $this->get($draftOnlyPage->URLSegment . '?stage=Stage');
60
        } catch (HTTPResponse_Exception $responseException) {
61
            $response = $responseException->getResponse();
62
        }
63
        $this->assertEquals($response->getStatusCode(), '302');
64
        $this->assertContains(
65
            Security::config()->get('login_url'),
66
            $response->getHeader('Location')
67
        );
68
69
        $this->logInWithPermission('ADMIN');
70
71
        $response = $this->get($draftOnlyPage->URLSegment . '?stage=Live');
72
        $this->assertEquals('404', $response->getStatusCode());
73
74
        $response = $this->get($draftOnlyPage->URLSegment . '?stage=Stage');
75
        $this->assertEquals('200', $response->getStatusCode());
76
77
        $draftOnlyPage->publishSingle();
78
        $response = $this->get($draftOnlyPage->URLSegment);
79
        $this->assertEquals('200', $response->getStatusCode());
80
    }
81
82
    public function testPermissionCheckingWorksOnDeletedPages()
83
    {
84
        // Set up fixture - a published page deleted from draft
85
        $this->logInWithPermission("ADMIN");
86
        $page = $this->objFromFixture(SiteTree::class, 'restrictedEditOnlySubadminGroup');
87
        $pageID = $page->ID;
88
        $this->assertTrue($page->publishRecursive());
89
        $page->delete();
90
91
        // Re-fetch the page from the live site
92
        $page = Versioned::get_one_by_stage(SiteTree::class, 'Live', "\"SiteTree\".\"ID\" = $pageID");
93
94
        // subadmin has edit rights on that page
95
        $member = $this->objFromFixture(Member::class, 'subadmin');
96
        Security::setCurrentUser($member);
97
98
        // Test can_edit_multiple
99
        $this->assertEquals(
100
            [ $pageID => true ],
101
            SiteTree::getPermissionChecker()->canEditMultiple([$pageID], $member)
102
        );
103
104
        // Test canEdit
105
        Security::setCurrentUser($member);
106
        $this->assertTrue($page->canEdit());
107
    }
108
109
    public function testPermissionCheckingWorksOnUnpublishedPages()
110
    {
111
        // Set up fixture - an unpublished page
112
        $this->logInWithPermission("ADMIN");
113
        $page = $this->objFromFixture(SiteTree::class, 'restrictedEditOnlySubadminGroup');
114
        $pageID = $page->ID;
115
        $page->doUnpublish();
116
117
        // subadmin has edit rights on that page
118
        $member = $this->objFromFixture(Member::class, 'subadmin');
119
        Security::setCurrentUser($member);
120
121
        // Test can_edit_multiple
122
        $this->assertEquals(
123
            [ $pageID => true ],
124
            SiteTree::getPermissionChecker()->canEditMultiple([$pageID], $member)
125
        );
126
127
        // Test canEdit
128
        Security::setCurrentUser($member);
129
        $this->assertTrue($page->canEdit());
130
    }
131
132
    public function testCanEditOnPageDeletedFromStageAndLiveReturnsFalse()
133
    {
134
        // Find a page that exists and delete it from both stage and published
135
        $this->logInWithPermission("ADMIN");
136
        $page = $this->objFromFixture(SiteTree::class, 'restrictedEditOnlySubadminGroup');
137
        $pageID = $page->ID;
138
        $page->doUnpublish();
139
        $page->delete();
140
141
        // We'll need to resurrect the page from the version cache to test this case
142
        $page = Versioned::get_latest_version(SiteTree::class, $pageID);
143
144
        // subadmin had edit rights on that page, but now it's gone
145
        $member = $this->objFromFixture(Member::class, 'subadmin');
146
        Security::setCurrentUser($member);
147
148
        $this->assertFalse($page->canEdit());
149
    }
150
151
    public function testCanViewStage()
152
    {
153
        // Get page & make sure it exists on Live
154
        /** @var SiteTree $page */
155
        $page = $this->objFromFixture(SiteTree::class, 'standardpage');
156
        $page->publishSingle();
157
158
        // Then make sure there's a new version on Stage
159
        $page->Title = 1;
160
        $page->write();
161
162
        $editor = $this->objFromFixture(Member::class, 'editor');
163
        $websiteuser = $this->objFromFixture(Member::class, 'websiteuser');
164
165
        $this->assertTrue($page->canViewStage('Live', $websiteuser));
166
        $this->assertFalse($page->canViewStage('Stage', $websiteuser));
167
168
        $this->assertTrue($page->canViewStage('Live', $editor));
169
        $this->assertTrue($page->canViewStage('Stage', $editor));
170
    }
171
172
    public function testAccessTabOnlyDisplaysWithGrantAccessPermissions()
173
    {
174
        $page = $this->objFromFixture(SiteTree::class, 'standardpage');
175
176
        $subadminuser = $this->objFromFixture(Member::class, 'subadmin');
177
        Security::setCurrentUser($subadminuser);
178
        $fields = $page->getSettingsFields();
179
        $this->assertFalse(
180
            $fields->dataFieldByName('CanViewType')->isReadonly(),
181
            'Users with SITETREE_GRANT_ACCESS permission can change "view" permissions in cms fields'
182
        );
183
        $this->assertFalse(
184
            $fields->dataFieldByName('CanEditType')->isReadonly(),
185
            'Users with SITETREE_GRANT_ACCESS permission can change "edit" permissions in cms fields'
186
        );
187
188
        $editoruser = $this->objFromFixture(Member::class, 'editor');
189
        Security::setCurrentUser($editoruser);
190
        $fields = $page->getSettingsFields();
191
        $this->assertTrue(
192
            $fields->dataFieldByName('CanViewType')->isReadonly(),
193
            'Users without SITETREE_GRANT_ACCESS permission cannot change "view" permissions in cms fields'
194
        );
195
        $this->assertTrue(
196
            $fields->dataFieldByName('CanEditType')->isReadonly(),
197
            'Users without SITETREE_GRANT_ACCESS permission cannot change "edit" permissions in cms fields'
198
        );
199
200
        $this->session()->set('loggedInAs', null);
201
    }
202
203
    public function testRestrictedViewLoggedInUsers()
204
    {
205
        $page = $this->objFromFixture(SiteTree::class, 'restrictedViewLoggedInUsers');
206
207
        // unauthenticated users
208
        $this->assertFalse(
209
            $page->canView(false),
0 ignored issues
show
Bug introduced by
false of type false is incompatible with the type SilverStripe\Security\Member expected by parameter $member of SilverStripe\ORM\DataObject::canView(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

209
            $page->canView(/** @scrutinizer ignore-type */ false),
Loading history...
210
            'Unauthenticated members cant view a page marked as "Viewable for any logged in users"'
211
        );
212
        Security::setCurrentUser(null);
213
        $response = $this->get($page->RelativeLink());
214
        $this->assertEquals(
215
            $response->getStatusCode(),
216
            302,
217
            'Unauthenticated members cant view a page marked as "Viewable for any logged in users"'
218
        );
219
220
        // website users
221
        $websiteuser = $this->objFromFixture(Member::class, 'websiteuser');
222
        $this->assertTrue(
223
            $page->canView($websiteuser),
224
            'Authenticated members can view a page marked as "Viewable for any logged in users" even if they dont ' .
225
            'have access to the CMS'
226
        );
227
        Security::setCurrentUser($websiteuser);
228
        $response = $this->get($page->RelativeLink());
229
        $this->assertEquals(
230
            $response->getStatusCode(),
231
            200,
232
            'Authenticated members can view a page marked as "Viewable for any logged in users" even if they dont ' .
233
            'have access to the CMS'
234
        );
235
        Security::setCurrentUser(null);
236
    }
237
238
    public function testRestrictedViewOnlyTheseUsers()
239
    {
240
        $page = $this->objFromFixture(SiteTree::class, 'restrictedViewOnlyWebsiteUsers');
241
242
        // unauthenticcated users
243
        $this->assertFalse(
244
            $page->canView(false),
0 ignored issues
show
Bug introduced by
false of type false is incompatible with the type SilverStripe\Security\Member expected by parameter $member of SilverStripe\ORM\DataObject::canView(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

244
            $page->canView(/** @scrutinizer ignore-type */ false),
Loading history...
245
            'Unauthenticated members cant view a page marked as "Viewable by these groups"'
246
        );
247
        Security::setCurrentUser(null);
248
        $response = $this->get($page->RelativeLink());
249
        $this->assertEquals(
250
            $response->getStatusCode(),
251
            302,
252
            'Unauthenticated members cant view a page marked as "Viewable by these groups"'
253
        );
254
255
        // subadmin users
256
        $subadminuser = $this->objFromFixture(Member::class, 'subadmin');
257
        $this->assertFalse(
258
            $page->canView($subadminuser),
259
            'Authenticated members cant view a page marked as "Viewable by these groups" if theyre not in the listed ' .
260
            'groups'
261
        );
262
        Security::setCurrentUser($subadminuser);
263
        $response = $this->get($page->RelativeLink());
264
        $this->assertEquals(
265
            $response->getStatusCode(),
266
            403,
267
            'Authenticated members cant view a page marked as "Viewable by these groups" if theyre not in the listed ' .
268
            'groups'
269
        );
270
        Security::setCurrentUser(null);
271
272
        // website users
273
        $websiteuser = $this->objFromFixture(Member::class, 'websiteuser');
274
        $this->assertTrue(
275
            $page->canView($websiteuser),
276
            'Authenticated members can view a page marked as "Viewable by these groups" if theyre in the listed groups'
277
        );
278
        Security::setCurrentUser($websiteuser);
279
        $response = $this->get($page->RelativeLink());
280
        $this->assertEquals(
281
            $response->getStatusCode(),
282
            200,
283
            'Authenticated members can view a page marked as "Viewable by these groups" if theyre in the listed groups'
284
        );
285
        Security::setCurrentUser(null);
286
    }
287
288
    public function testRestrictedEditLoggedInUsers()
289
    {
290
        $page = $this->objFromFixture(SiteTree::class, 'restrictedEditLoggedInUsers');
291
292
        // unauthenticcated users
293
        $this->assertFalse(
294
            $page->canEdit(false),
0 ignored issues
show
Bug introduced by
false of type false is incompatible with the type SilverStripe\Security\Member expected by parameter $member of SilverStripe\ORM\DataObject::canEdit(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

294
            $page->canEdit(/** @scrutinizer ignore-type */ false),
Loading history...
295
            'Unauthenticated members cant edit a page marked as "Editable by logged in users"'
296
        );
297
298
        // website users
299
        $websiteuser = $this->objFromFixture(Member::class, 'websiteuser');
300
        Security::setCurrentUser($websiteuser);
301
        $this->assertFalse(
302
            $page->canEdit($websiteuser),
303
            'Authenticated members cant edit a page marked as "Editable by logged in users" if they dont have cms ' .
304
            'permissions'
305
        );
306
307
        // subadmin users
308
        $subadminuser = $this->objFromFixture(Member::class, 'subadmin');
309
        $this->assertTrue(
310
            $page->canEdit($subadminuser),
311
            'Authenticated members can edit a page marked as "Editable by logged in users" if they have cms ' .
312
            'permissions and belong to any of these groups'
313
        );
314
    }
315
316
    public function testRestrictedEditOnlySubadminGroup()
317
    {
318
        $page = $this->objFromFixture(SiteTree::class, 'restrictedEditOnlySubadminGroup');
319
320
        // unauthenticated users
321
        $this->assertFalse(
322
            $page->canEdit(false),
0 ignored issues
show
Bug introduced by
false of type false is incompatible with the type SilverStripe\Security\Member expected by parameter $member of SilverStripe\ORM\DataObject::canEdit(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

322
            $page->canEdit(/** @scrutinizer ignore-type */ false),
Loading history...
323
            'Unauthenticated members cant edit a page marked as "Editable by these groups"'
324
        );
325
326
        // subadmin users
327
        $subadminuser = $this->objFromFixture(Member::class, 'subadmin');
328
        $this->assertTrue(
329
            $page->canEdit($subadminuser),
330
            'Authenticated members can view a page marked as "Editable by these groups" if theyre in the listed groups'
331
        );
332
333
        // website users
334
        $websiteuser = $this->objFromFixture(Member::class, 'websiteuser');
335
        $this->assertFalse(
336
            $page->canEdit($websiteuser),
337
            'Authenticated members cant edit a page marked as "Editable by these groups" if theyre not in the listed ' .
338
            'groups'
339
        );
340
    }
341
342
    public function testRestrictedViewInheritance()
343
    {
344
        $parentPage = $this->objFromFixture(SiteTree::class, 'parent_restrictedViewOnlySubadminGroup');
0 ignored issues
show
Unused Code introduced by
The assignment to $parentPage is dead and can be removed.
Loading history...
345
        $childPage = $this->objFromFixture(SiteTree::class, 'child_restrictedViewOnlySubadminGroup');
346
347
        // unauthenticated users
348
        $this->assertFalse(
349
            $childPage->canView(false),
0 ignored issues
show
Bug introduced by
false of type false is incompatible with the type SilverStripe\Security\Member expected by parameter $member of SilverStripe\ORM\DataObject::canView(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

349
            $childPage->canView(/** @scrutinizer ignore-type */ false),
Loading history...
350
            'Unauthenticated members cant view a page marked as "Viewable by these groups" by inherited permission'
351
        );
352
        Security::setCurrentUser(null);
353
        $response = $this->get($childPage->RelativeLink());
354
        $this->assertEquals(
355
            $response->getStatusCode(),
356
            302,
357
            'Unauthenticated members cant view a page marked as "Viewable by these groups" by inherited permission'
358
        );
359
360
        // subadmin users
361
        $subadminuser = $this->objFromFixture(Member::class, 'subadmin');
362
        $this->assertTrue(
363
            $childPage->canView($subadminuser),
364
            'Authenticated members can view a page marked as "Viewable by these groups" if theyre in the listed ' .
365
            'groups by inherited permission'
366
        );
367
        Security::setCurrentUser($subadminuser);
368
        $response = $this->get($childPage->RelativeLink());
369
        $this->assertEquals(
370
            $response->getStatusCode(),
371
            200,
372
            'Authenticated members can view a page marked as "Viewable by these groups" if theyre in the listed ' .
373
            'groups by inherited permission'
374
        );
375
        Security::setCurrentUser(null);
376
    }
377
378
    public function testRestrictedEditInheritance()
379
    {
380
        $parentPage = $this->objFromFixture(SiteTree::class, 'parent_restrictedEditOnlySubadminGroup');
0 ignored issues
show
Unused Code introduced by
The assignment to $parentPage is dead and can be removed.
Loading history...
381
        $childPage = $this->objFromFixture(SiteTree::class, 'child_restrictedEditOnlySubadminGroup');
382
383
        // unauthenticated users
384
        $this->assertFalse(
385
            $childPage->canEdit(false),
0 ignored issues
show
Bug introduced by
false of type false is incompatible with the type SilverStripe\Security\Member expected by parameter $member of SilverStripe\ORM\DataObject::canEdit(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

385
            $childPage->canEdit(/** @scrutinizer ignore-type */ false),
Loading history...
386
            'Unauthenticated members cant edit a page marked as "Editable by these groups" by inherited permission'
387
        );
388
389
        // subadmin users
390
        $subadminuser = $this->objFromFixture(Member::class, 'subadmin');
391
        $this->assertTrue(
392
            $childPage->canEdit($subadminuser),
393
            'Authenticated members can edit a page marked as "Editable by these groups" if theyre in the listed ' .
394
            'groups by inherited permission'
395
        );
396
    }
397
398
    public function testDeleteRestrictedChild()
399
    {
400
        $parentPage = $this->objFromFixture(SiteTree::class, 'deleteTestParentPage');
401
        $childPage = $this->objFromFixture(SiteTree::class, 'deleteTestChildPage');
402
403
        // unauthenticated users
404
        $this->assertFalse(
405
            $parentPage->canDelete(false),
0 ignored issues
show
Bug introduced by
false of type false is incompatible with the type SilverStripe\Security\Member expected by parameter $member of SilverStripe\ORM\DataObject::canDelete(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

405
            $parentPage->canDelete(/** @scrutinizer ignore-type */ false),
Loading history...
406
            'Unauthenticated members cant delete a page if it doesnt have delete permissions on any of its descendants'
407
        );
408
        $this->assertFalse(
409
            $childPage->canDelete(false),
410
            'Unauthenticated members cant delete a child page marked as "Editable by these groups"'
411
        );
412
    }
413
414
    public function testRestrictedEditLoggedInUsersDeletedFromStage()
415
    {
416
        $page = $this->objFromFixture(SiteTree::class, 'restrictedEditLoggedInUsers');
417
        $pageID = $page->ID;
418
419
        $this->logInWithPermission("ADMIN");
420
421
        $page->publishRecursive();
422
        $page->deleteFromStage('Stage');
423
424
        // Get the live version of the page
425
        $page = Versioned::get_one_by_stage(SiteTree::class, Versioned::LIVE, "\"SiteTree\".\"ID\" = $pageID");
426
        $this->assertTrue(is_object($page), 'Versioned::get_one_by_stage() is returning an object');
427
428
        // subadmin users
429
        $subadminuser = $this->objFromFixture(Member::class, 'subadmin');
430
        $this->assertTrue(
431
            $page->canEdit($subadminuser),
432
            'Authenticated members can edit a page that was deleted from stage and marked as "Editable by logged ' .
433
            'in users" if they have cms permissions and belong to any of these groups'
434
        );
435
    }
436
437
    public function testInheritCanViewFromSiteConfig()
438
    {
439
        $page = $this->objFromFixture(SiteTree::class, 'inheritWithNoParent');
440
        $siteconfig = $this->objFromFixture(SiteConfig::class, 'default');
441
        $editor = $this->objFromFixture(Member::class, 'editor');
442
        $editorGroup = $this->objFromFixture(Group::class, 'editorgroup');
443
444
        $siteconfig->CanViewType = 'Anyone';
445
        $siteconfig->write();
446
        $this->assertTrue(
447
            $page->canView(false),
0 ignored issues
show
Bug introduced by
false of type false is incompatible with the type SilverStripe\Security\Member expected by parameter $member of SilverStripe\ORM\DataObject::canView(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

447
            $page->canView(/** @scrutinizer ignore-type */ false),
Loading history...
448
            'Anyone can view a page when set to inherit from the SiteConfig, and SiteConfig has canView set to ' .
449
            'LoggedInUsers'
450
        );
451
452
        $siteconfig->CanViewType = 'LoggedInUsers';
453
        $siteconfig->write();
454
        $this->assertFalse(
455
            $page->canView(false),
456
            'Anonymous can\'t view a page when set to inherit from the SiteConfig, and SiteConfig has canView set to ' .
457
            'LoggedInUsers'
458
        );
459
460
        $siteconfig->CanViewType = 'LoggedInUsers';
461
        $siteconfig->write();
462
        $this->assertTrue(
463
            $page->canView($editor),
464
            'Users can view a page when set to inherit from the SiteConfig, and SiteConfig has canView set to ' .
465
            'LoggedInUsers'
466
        );
467
468
        $siteconfig->CanViewType = 'OnlyTheseUsers';
469
        $siteconfig->ViewerGroups()->add($editorGroup);
470
        $siteconfig->write();
471
        $this->assertTrue(
472
            $page->canView($editor),
473
            'Editors can view a page when set to inherit from the SiteConfig, and SiteConfig has canView set to ' .
474
            'OnlyTheseUsers'
475
        );
476
        $this->assertFalse(
477
            $page->canView(false),
478
            'Anonymous can\'t view a page when set to inherit from the SiteConfig, and SiteConfig has canView set ' .
479
            'to OnlyTheseUsers'
480
        );
481
    }
482
483
    public function testInheritCanEditFromSiteConfig()
484
    {
485
        $page = $this->objFromFixture(SiteTree::class, 'inheritWithNoParent');
486
        $siteconfig = $this->objFromFixture(SiteConfig::class, 'default');
487
        $editor = $this->objFromFixture(Member::class, 'editor');
488
        $user = $this->objFromFixture(Member::class, 'websiteuser');
489
        $editorGroup = $this->objFromFixture(Group::class, 'editorgroup');
490
491
        $siteconfig->CanEditType = 'LoggedInUsers';
492
        $siteconfig->write();
493
494
        $this->assertFalse(
495
            $page->canEdit(false),
0 ignored issues
show
Bug introduced by
false of type false is incompatible with the type SilverStripe\Security\Member expected by parameter $member of SilverStripe\ORM\DataObject::canEdit(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

495
            $page->canEdit(/** @scrutinizer ignore-type */ false),
Loading history...
496
            'Anonymous can\'t edit a page when set to inherit from the SiteConfig, and SiteConfig has canEdit set ' .
497
            'to LoggedInUsers'
498
        );
499
        Security::setCurrentUser($editor);
500
        $this->assertTrue(
501
            $page->canEdit(),
502
            'Users can edit a page when set to inherit from the SiteConfig, and SiteConfig has canEdit set to ' .
503
            'LoggedInUsers'
504
        );
505
506
        $siteconfig->CanEditType = 'OnlyTheseUsers';
507
        $siteconfig->EditorGroups()->add($editorGroup);
508
        $siteconfig->write();
509
        $this->assertTrue(
510
            $page->canEdit($editor),
511
            'Editors can edit a page when set to inherit from the SiteConfig, and SiteConfig has canEdit set to ' .
512
            'OnlyTheseUsers'
513
        );
514
        Security::setCurrentUser(null);
515
        $this->assertFalse(
516
            $page->canEdit(false),
517
            'Anonymous can\'t edit a page when set to inherit from the SiteConfig, and SiteConfig has canEdit set ' .
518
            'to OnlyTheseUsers'
519
        );
520
        Security::setCurrentUser($user);
521
        $this->assertFalse(
522
            $page->canEdit($user),
523
            'Website user can\'t edit a page when set to inherit from the SiteConfig, and SiteConfig has canEdit set ' .
524
            'to OnlyTheseUsers'
525
        );
526
    }
527
}
528