1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SilverStripe\Subsites\Tests; |
4
|
|
|
|
5
|
|
|
use Page; |
6
|
|
|
use SilverStripe\Assets\FileNameFilter; |
7
|
|
|
use SilverStripe\CMS\Controllers\CMSMain; |
8
|
|
|
use SilverStripe\CMS\Controllers\ModelAsController; |
9
|
|
|
use SilverStripe\CMS\Model\SiteTree; |
10
|
|
|
use SilverStripe\Control\Director; |
11
|
|
|
use SilverStripe\Core\Config\Config; |
12
|
|
|
use SilverStripe\Core\Convert; |
13
|
|
|
use SilverStripe\ErrorPage\ErrorPage; |
14
|
|
|
use SilverStripe\Forms\FieldList; |
15
|
|
|
use SilverStripe\Security\Member; |
16
|
|
|
use SilverStripe\SiteConfig\SiteConfig; |
17
|
|
|
use SilverStripe\Subsites\Extensions\SiteTreeSubsites; |
18
|
|
|
use SilverStripe\Subsites\Model\Subsite; |
19
|
|
|
use SilverStripe\Subsites\Pages\SubsitesVirtualPage; |
20
|
|
|
use SilverStripe\Subsites\Tests\SiteTreeSubsitesTest\TestClassA; |
21
|
|
|
use SilverStripe\Subsites\Tests\SiteTreeSubsitesTest\TestClassB; |
22
|
|
|
use SilverStripe\Subsites\Tests\SiteTreeSubsitesTest\TestErrorPage; |
23
|
|
|
use SilverStripe\Versioned\Versioned; |
24
|
|
|
use SilverStripe\View\SSViewer; |
25
|
|
|
|
26
|
|
|
class SiteTreeSubsitesTest extends BaseSubsiteTest |
27
|
|
|
{ |
28
|
|
|
protected static $fixture_file = 'SubsiteTest.yml'; |
29
|
|
|
|
30
|
|
|
protected static $extra_dataobjects = [ |
31
|
|
|
TestClassA::class, |
32
|
|
|
TestClassB::class, |
33
|
|
|
TestErrorPage::class |
34
|
|
|
]; |
35
|
|
|
|
36
|
|
|
protected static $illegal_extensions = [ |
37
|
|
|
SiteTree::class => ['Translatable'] // @todo implement Translatable namespace |
38
|
|
|
]; |
39
|
|
|
|
40
|
|
|
public function testPagesInDifferentSubsitesCanShareURLSegment() |
41
|
|
|
{ |
42
|
|
|
$subsiteMain = $this->objFromFixture(Subsite::class, 'main'); |
|
|
|
|
43
|
|
|
$subsite1 = $this->objFromFixture(Subsite::class, 'subsite1'); |
44
|
|
|
|
45
|
|
|
$pageMain = new SiteTree(); |
46
|
|
|
$pageMain->URLSegment = 'testpage'; |
47
|
|
|
$pageMain->write(); |
48
|
|
|
$pageMain->copyVersionToStage('Stage', 'Live'); |
49
|
|
|
|
50
|
|
|
$pageMainOther = new SiteTree(); |
51
|
|
|
$pageMainOther->URLSegment = 'testpage'; |
52
|
|
|
$pageMainOther->write(); |
53
|
|
|
$pageMainOther->copyVersionToStage('Stage', 'Live'); |
54
|
|
|
|
55
|
|
|
$this->assertNotEquals( |
56
|
|
|
$pageMain->URLSegment, |
57
|
|
|
$pageMainOther->URLSegment, |
58
|
|
|
'Pages in same subsite cant share the same URL' |
59
|
|
|
); |
60
|
|
|
|
61
|
|
|
Subsite::changeSubsite($subsite1->ID); |
62
|
|
|
|
63
|
|
|
$pageSubsite1 = new SiteTree(); |
64
|
|
|
$pageSubsite1->URLSegment = 'testpage'; |
65
|
|
|
$pageSubsite1->write(); |
66
|
|
|
$pageSubsite1->copyVersionToStage('Stage', 'Live'); |
67
|
|
|
|
68
|
|
|
$this->assertEquals( |
69
|
|
|
$pageMain->URLSegment, |
70
|
|
|
$pageSubsite1->URLSegment, |
71
|
|
|
'Pages in different subsites can share the same URL' |
72
|
|
|
); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function testBasicSanity() |
76
|
|
|
{ |
77
|
|
|
$this->assertInstanceOf(SiteConfig::class, singleton(SiteTree::class)->getSiteConfig()); |
78
|
|
|
// The following assert is breaking in Translatable. |
79
|
|
|
$this->assertInstanceOf(FieldList::class, singleton(SiteTree::class)->getCMSFields()); |
80
|
|
|
$this->assertInstanceOf(FieldList::class, singleton(SubsitesVirtualPage::class)->getCMSFields()); |
81
|
|
|
$this->assertTrue(is_array(singleton(SiteTreeSubsites::class)->extraStatics())); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public function errorPageLocationsProvider() |
85
|
|
|
{ |
86
|
|
|
return [ |
87
|
|
|
['domaintest1', '/error-500-one.example.org.html'], |
88
|
|
|
['domaintestVagrant', '/error-500-localhost8080.html'] |
89
|
|
|
]; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @dataProvider errorPageLocationsProvider |
94
|
|
|
*/ |
95
|
|
|
public function testErrorPageLocations($subsiteFixtureName, $expectedFilename) |
96
|
|
|
{ |
97
|
|
|
$static_path = Config::inst()->get(ErrorPage::class, 'static_filepath'); |
98
|
|
|
|
99
|
|
|
$subsite = $this->objFromFixture(Subsite::class, $subsiteFixtureName); |
100
|
|
|
$expected_path = $static_path . $expectedFilename; |
101
|
|
|
|
102
|
|
|
Subsite::changeSubsite($subsite->ID); |
103
|
|
|
$path = TestErrorPage::get_error_filename_spy(500); |
104
|
|
|
|
105
|
|
|
$this->assertEquals($expected_path, $path); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
public function testCanEditSiteTree() |
109
|
|
|
{ |
110
|
|
|
$admin = $this->objFromFixture(Member::class, 'admin'); |
111
|
|
|
$subsite1member = $this->objFromFixture(Member::class, 'subsite1member'); |
112
|
|
|
$subsite2member = $this->objFromFixture(Member::class, 'subsite2member'); |
113
|
|
|
$mainpage = $this->objFromFixture('Page', 'home'); |
114
|
|
|
$subsite1page = $this->objFromFixture('Page', 'subsite1_home'); |
115
|
|
|
$subsite2page = $this->objFromFixture('Page', 'subsite2_home'); |
|
|
|
|
116
|
|
|
$subsite1 = $this->objFromFixture(Subsite::class, 'subsite1'); |
117
|
|
|
$subsite2 = $this->objFromFixture(Subsite::class, 'subsite2'); |
|
|
|
|
118
|
|
|
|
119
|
|
|
// Cant pass member as arguments to canEdit() because of GroupSubsites |
120
|
|
|
$this->logInAs($admin); |
|
|
|
|
121
|
|
|
|
122
|
|
|
$this->assertTrue( |
123
|
|
|
(bool)$subsite1page->canEdit(), |
124
|
|
|
'Administrators can edit all subsites' |
125
|
|
|
); |
126
|
|
|
|
127
|
|
|
// @todo: Workaround because GroupSubsites->augmentSQL() is relying on session state |
128
|
|
|
Subsite::changeSubsite($subsite1); |
|
|
|
|
129
|
|
|
|
130
|
|
|
$this->logInAs($subsite1member->ID); |
131
|
|
|
$this->assertTrue( |
132
|
|
|
(bool)$subsite1page->canEdit(), |
133
|
|
|
'Members can edit pages on a subsite if they are in a group belonging to this subsite' |
134
|
|
|
); |
135
|
|
|
|
136
|
|
|
$this->logInAs($subsite2member->ID); |
137
|
|
|
$this->assertFalse( |
138
|
|
|
(bool)$subsite1page->canEdit(), |
139
|
|
|
'Members cant edit pages on a subsite if they are not in a group belonging to this subsite' |
140
|
|
|
); |
141
|
|
|
|
142
|
|
|
// @todo: Workaround because GroupSubsites->augmentSQL() is relying on session state |
143
|
|
|
Subsite::changeSubsite(0); |
144
|
|
|
$this->assertFalse( |
145
|
|
|
$mainpage->canEdit(), |
146
|
|
|
'Members cant edit pages on the main site if they are not in a group allowing this' |
147
|
|
|
); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* Similar to {@link SubsitesVirtualPageTest->testSubsiteVirtualPageCanHaveSameUrlsegmentAsOtherSubsite()}. |
152
|
|
|
*/ |
153
|
|
|
public function testTwoPagesWithSameURLOnDifferentSubsites() |
154
|
|
|
{ |
155
|
|
|
// Set up a couple of pages with the same URL on different subsites |
156
|
|
|
$s1 = $this->objFromFixture(Subsite::class, 'domaintest1'); |
157
|
|
|
$s2 = $this->objFromFixture(Subsite::class, 'domaintest2'); |
158
|
|
|
|
159
|
|
|
$p1 = new SiteTree(); |
160
|
|
|
$p1->Title = $p1->URLSegment = 'test-page'; |
161
|
|
|
$p1->SubsiteID = $s1->ID; |
162
|
|
|
$p1->write(); |
163
|
|
|
|
164
|
|
|
$p2 = new SiteTree(); |
165
|
|
|
$p2->Title = $p1->URLSegment = 'test-page'; |
166
|
|
|
$p2->SubsiteID = $s2->ID; |
167
|
|
|
$p2->write(); |
168
|
|
|
|
169
|
|
|
// Check that the URLs weren't modified in our set-up |
170
|
|
|
$this->assertEquals('test-page', $p1->URLSegment); |
171
|
|
|
$this->assertEquals('test-page', $p2->URLSegment); |
172
|
|
|
|
173
|
|
|
// Check that if we switch between the different subsites, we receive the correct pages |
174
|
|
|
Subsite::changeSubsite($s1); |
|
|
|
|
175
|
|
|
$this->assertEquals($p1->ID, SiteTree::get_by_link('test-page')->ID); |
176
|
|
|
|
177
|
|
|
Subsite::changeSubsite($s2); |
|
|
|
|
178
|
|
|
$this->assertEquals($p2->ID, SiteTree::get_by_link('test-page')->ID); |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
public function testPageTypesBlacklistInClassDropdown() |
182
|
|
|
{ |
183
|
|
|
$this->logInAs('editor'); |
184
|
|
|
|
185
|
|
|
$s1 = $this->objFromFixture(Subsite::class, 'domaintest1'); |
186
|
|
|
$s2 = $this->objFromFixture(Subsite::class, 'domaintest2'); |
187
|
|
|
$page = singleton(SiteTree::class); |
188
|
|
|
|
189
|
|
|
$s1->PageTypeBlacklist = implode(',', [TestClassA::class, ErrorPage::class]); |
190
|
|
|
$s1->write(); |
191
|
|
|
|
192
|
|
|
Subsite::changeSubsite($s1); |
|
|
|
|
193
|
|
|
$settingsFields = $page->getSettingsFields()->dataFieldByName('ClassName')->getSource(); |
194
|
|
|
|
195
|
|
|
$this->assertArrayNotHasKey( |
196
|
|
|
ErrorPage::class, |
197
|
|
|
$settingsFields |
198
|
|
|
); |
199
|
|
|
$this->assertArrayNotHasKey( |
200
|
|
|
TestClassA::class, |
201
|
|
|
$settingsFields |
202
|
|
|
); |
203
|
|
|
$this->assertArrayHasKey( |
204
|
|
|
TestClassB::class, |
205
|
|
|
$settingsFields |
206
|
|
|
); |
207
|
|
|
|
208
|
|
|
Subsite::changeSubsite($s2); |
|
|
|
|
209
|
|
|
$settingsFields = $page->getSettingsFields()->dataFieldByName('ClassName')->getSource(); |
210
|
|
|
$this->assertArrayHasKey( |
211
|
|
|
ErrorPage::class, |
212
|
|
|
$settingsFields |
213
|
|
|
); |
214
|
|
|
$this->assertArrayHasKey( |
215
|
|
|
TestClassA::class, |
216
|
|
|
$settingsFields |
217
|
|
|
); |
218
|
|
|
$this->assertArrayHasKey( |
219
|
|
|
TestClassB::class, |
220
|
|
|
$settingsFields |
221
|
|
|
); |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
public function testCopyToSubsite() |
225
|
|
|
{ |
226
|
|
|
// Remove baseurl if testing in subdir |
227
|
|
|
Config::modify()->set(Director::class, 'alternate_base_url', '/'); |
228
|
|
|
|
229
|
|
|
/** @var Subsite $otherSubsite */ |
230
|
|
|
$otherSubsite = $this->objFromFixture(Subsite::class, 'subsite1'); |
231
|
|
|
$staffPage = $this->objFromFixture(Page::class, 'staff'); // nested page |
232
|
|
|
$contactPage = $this->objFromFixture(Page::class, 'contact'); // top level page |
233
|
|
|
|
234
|
|
|
$staffPage2 = $staffPage->duplicateToSubsite($otherSubsite->ID); |
235
|
|
|
$contactPage2 = $contactPage->duplicateToSubsite($otherSubsite->ID); |
236
|
|
|
|
237
|
|
|
$this->assertNotEquals($staffPage->ID, $staffPage2->ID); |
238
|
|
|
$this->assertNotEquals($staffPage->SubsiteID, $staffPage2->SubsiteID); |
239
|
|
|
$this->assertNotEquals($contactPage->ID, $contactPage2->ID); |
240
|
|
|
$this->assertNotEquals($contactPage->SubsiteID, $contactPage2->SubsiteID); |
241
|
|
|
$this->assertEmpty($staffPage2->ParentID); |
242
|
|
|
$this->assertEmpty($contactPage2->ParentID); |
243
|
|
|
$this->assertNotEmpty($staffPage->ParentID); |
244
|
|
|
$this->assertEmpty($contactPage->ParentID); |
245
|
|
|
|
246
|
|
|
// Staff is shifted to top level and given a unique url segment |
247
|
|
|
$domain = $otherSubsite->domain(); |
248
|
|
|
$this->assertEquals('http://' . $domain . '/staff-2/', $staffPage2->AbsoluteLink()); |
249
|
|
|
$this->assertEquals('http://' . $domain . '/contact-us-2/', $contactPage2->AbsoluteLink()); |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
public function testPageTypesBlacklistInCMSMain() |
253
|
|
|
{ |
254
|
|
|
$this->logInAs('editor'); |
255
|
|
|
|
256
|
|
|
$cmsmain = new CMSMain(); |
257
|
|
|
|
258
|
|
|
$s1 = $this->objFromFixture(Subsite::class, 'domaintest1'); |
259
|
|
|
$s2 = $this->objFromFixture(Subsite::class, 'domaintest2'); |
260
|
|
|
|
261
|
|
|
$s1->PageTypeBlacklist = implode(',', [TestClassA::class, ErrorPage::class]); |
262
|
|
|
$s1->write(); |
263
|
|
|
|
264
|
|
|
Subsite::changeSubsite($s1); |
|
|
|
|
265
|
|
|
$hints = Convert::json2array($cmsmain->SiteTreeHints()); |
266
|
|
|
$classes = $hints['Root']['disallowedChildren']; |
267
|
|
|
$this->assertContains(ErrorPage::class, $classes); |
268
|
|
|
$this->assertContains(TestClassA::class, $classes); |
269
|
|
|
$this->assertNotContains(TestClassB::class, $classes); |
270
|
|
|
|
271
|
|
|
Subsite::changeSubsite($s2); |
|
|
|
|
272
|
|
|
$hints = Convert::json2array($cmsmain->SiteTreeHints()); |
273
|
|
|
$classes = $hints['Root']['disallowedChildren']; |
274
|
|
|
$this->assertNotContains(ErrorPage::class, $classes); |
275
|
|
|
$this->assertNotContains(TestClassA::class, $classes); |
276
|
|
|
$this->assertNotContains(TestClassB::class, $classes); |
277
|
|
|
} |
278
|
|
|
|
279
|
|
|
/** |
280
|
|
|
* Tests that url segments between subsites don't conflict, but do conflict within them |
281
|
|
|
*/ |
282
|
|
|
public function testValidateURLSegment() |
283
|
|
|
{ |
284
|
|
|
$this->logInWithPermission('ADMIN'); |
285
|
|
|
// Saving existing page in the same subsite doesn't change urls |
286
|
|
|
$mainHome = $this->objFromFixture(Page::class, 'home'); |
287
|
|
|
$mainSubsiteID = $this->idFromFixture(Subsite::class, 'main'); |
288
|
|
|
Subsite::changeSubsite($mainSubsiteID); |
289
|
|
|
$mainHome->Content = '<p>Some new content</p>'; |
290
|
|
|
$mainHome->write(); |
291
|
|
|
$this->assertEquals('home', $mainHome->URLSegment); |
292
|
|
|
$mainHome->doPublish(); |
293
|
|
|
$mainHomeLive = Versioned::get_one_by_stage('Page', 'Live', sprintf('"SiteTree"."ID" = \'%d\'', $mainHome->ID)); |
294
|
|
|
$this->assertEquals('home', $mainHomeLive->URLSegment); |
295
|
|
|
|
296
|
|
|
// Saving existing page in another subsite doesn't change urls |
297
|
|
|
Subsite::changeSubsite($mainSubsiteID); |
298
|
|
|
$subsite1Home = $this->objFromFixture('Page', 'subsite1_home'); |
299
|
|
|
$subsite1Home->Content = '<p>In subsite 1</p>'; |
300
|
|
|
$subsite1Home->write(); |
301
|
|
|
$this->assertEquals('home', $subsite1Home->URLSegment); |
302
|
|
|
$subsite1Home->doPublish(); |
303
|
|
|
$subsite1HomeLive = Versioned::get_one_by_stage( |
304
|
|
|
'Page', |
305
|
|
|
'Live', |
306
|
|
|
sprintf('"SiteTree"."ID" = \'%d\'', $subsite1Home->ID) |
307
|
|
|
); |
308
|
|
|
$this->assertEquals('home', $subsite1HomeLive->URLSegment); |
309
|
|
|
|
310
|
|
|
// Creating a new page in a subsite doesn't conflict with urls in other subsites |
311
|
|
|
$subsite1ID = $this->idFromFixture(Subsite::class, 'subsite1'); |
312
|
|
|
Subsite::changeSubsite($subsite1ID); |
313
|
|
|
$subsite1NewPage = new Page(); |
314
|
|
|
$subsite1NewPage->SubsiteID = $subsite1ID; |
315
|
|
|
$subsite1NewPage->Title = 'Important Page (Subsite 1)'; |
316
|
|
|
$subsite1NewPage->URLSegment = 'important-page'; // Also exists in main subsite |
317
|
|
|
$subsite1NewPage->write(); |
318
|
|
|
$this->assertEquals('important-page', $subsite1NewPage->URLSegment); |
319
|
|
|
$subsite1NewPage->doPublish(); |
320
|
|
|
$subsite1NewPageLive = Versioned::get_one_by_stage( |
321
|
|
|
'Page', |
322
|
|
|
'Live', |
323
|
|
|
sprintf('"SiteTree"."ID" = \'%d\'', $subsite1NewPage->ID) |
324
|
|
|
); |
325
|
|
|
$this->assertEquals('important-page', $subsite1NewPageLive->URLSegment); |
326
|
|
|
|
327
|
|
|
// Creating a new page in a subsite DOES conflict with urls in the same subsite |
328
|
|
|
$subsite1NewPage2 = new Page(); |
329
|
|
|
$subsite1NewPage2->SubsiteID = $subsite1ID; |
330
|
|
|
$subsite1NewPage2->Title = 'Important Page (Subsite 1)'; |
331
|
|
|
$subsite1NewPage2->URLSegment = 'important-page'; // Also exists in main subsite |
332
|
|
|
$subsite1NewPage2->write(); |
333
|
|
|
$this->assertEquals('important-page-2', $subsite1NewPage2->URLSegment); |
334
|
|
|
$subsite1NewPage2->doPublish(); |
335
|
|
|
$subsite1NewPage2Live = Versioned::get_one_by_stage( |
336
|
|
|
'Page', |
337
|
|
|
'Live', |
338
|
|
|
sprintf('"SiteTree"."ID" = \'%d\'', $subsite1NewPage2->ID) |
339
|
|
|
); |
340
|
|
|
$this->assertEquals('important-page-2', $subsite1NewPage2Live->URLSegment); |
341
|
|
|
|
342
|
|
|
// Original page is left un-modified |
343
|
|
|
$mainSubsiteImportantPageID = $this->idFromFixture('Page', 'importantpage'); |
344
|
|
|
$mainSubsiteImportantPage = Page::get()->byID($mainSubsiteImportantPageID); |
345
|
|
|
$this->assertEquals('important-page', $mainSubsiteImportantPage->URLSegment); |
346
|
|
|
$mainSubsiteImportantPage->Content = '<p>New Important Page Content</p>'; |
347
|
|
|
$mainSubsiteImportantPage->write(); |
348
|
|
|
$this->assertEquals('important-page', $mainSubsiteImportantPage->URLSegment); |
349
|
|
|
} |
350
|
|
|
|
351
|
|
View Code Duplication |
public function testCopySubsiteWithChildren() |
|
|
|
|
352
|
|
|
{ |
353
|
|
|
$page = $this->objFromFixture('Page', 'about'); |
354
|
|
|
$newSubsite = $this->objFromFixture(Subsite::class, 'subsite1'); |
355
|
|
|
|
356
|
|
|
$moved = $page->duplicateToSubsite($newSubsite->ID, true); |
357
|
|
|
$this->assertEquals($moved->SubsiteID, $newSubsite->ID, 'Ensure returned records are on new subsite'); |
358
|
|
|
$this->assertEquals( |
359
|
|
|
$moved->AllChildren()->count(), |
360
|
|
|
$page->AllChildren()->count(), |
361
|
|
|
'All pages are copied across' |
362
|
|
|
); |
363
|
|
|
} |
364
|
|
|
|
365
|
|
View Code Duplication |
public function testCopySubsiteWithoutChildren() |
|
|
|
|
366
|
|
|
{ |
367
|
|
|
$page = $this->objFromFixture('Page', 'about'); |
368
|
|
|
$newSubsite = $this->objFromFixture(Subsite::class, 'subsite2'); |
369
|
|
|
|
370
|
|
|
$moved = $page->duplicateToSubsite($newSubsite->ID, false); |
371
|
|
|
$this->assertEquals($moved->SubsiteID, $newSubsite->ID, 'Ensure returned records are on new subsite'); |
372
|
|
|
$this->assertEquals($moved->AllChildren()->count(), 0, 'All pages are copied across'); |
373
|
|
|
} |
374
|
|
|
|
375
|
|
|
public function testIfSubsiteThemeIsSetToThemeList() |
376
|
|
|
{ |
377
|
|
|
$defaultThemes = ['default']; |
378
|
|
|
SSViewer::set_themes($defaultThemes); |
379
|
|
|
|
380
|
|
|
$subsitePage = $this->objFromFixture(Page::class, 'home'); |
381
|
|
|
Subsite::changeSubsite($subsitePage->SubsiteID); |
382
|
|
|
$controller = ModelAsController::controller_for($subsitePage); |
|
|
|
|
383
|
|
|
SiteTree::singleton()->extend('contentcontrollerInit', $controller); |
384
|
|
|
|
385
|
|
|
$this->assertEquals( |
386
|
|
|
SSViewer::get_themes(), |
387
|
|
|
$defaultThemes, |
388
|
|
|
'Themes should not be modified when Subsite has no theme defined' |
389
|
|
|
); |
390
|
|
|
|
391
|
|
|
$pageWithTheme = $this->objFromFixture(Page::class, 'subsite1_home'); |
392
|
|
|
Subsite::changeSubsite($pageWithTheme->SubsiteID); |
393
|
|
|
$controller = ModelAsController::controller_for($pageWithTheme); |
|
|
|
|
394
|
|
|
SiteTree::singleton()->extend('contentcontrollerInit', $controller); |
395
|
|
|
$subsiteTheme = $pageWithTheme->Subsite()->Theme; |
396
|
|
|
$this->assertContains( |
397
|
|
|
$subsiteTheme, |
398
|
|
|
SSViewer::get_themes(), |
399
|
|
|
'Themes should be modified when Subsite has theme defined' |
400
|
|
|
); |
401
|
|
|
} |
402
|
|
|
} |
403
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.