These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace SilverStripe\Subsites\Tests; |
||
4 | |||
5 | use SilverStripe\Dev\SapphireTest; |
||
6 | use SilverStripe\Subsites\Model\Subsite; |
||
7 | |||
8 | class BaseSubsiteTest extends SapphireTest |
||
9 | { |
||
10 | protected function setUp() |
||
11 | { |
||
12 | parent::setUp(); |
||
13 | |||
14 | Subsite::$use_session_subsiteid = true; |
||
15 | Subsite::$force_subsite = null; |
||
16 | } |
||
17 | |||
18 | /** |
||
19 | * Avoid subsites filtering on fixture fetching. |
||
20 | * @param string $className |
||
21 | * @param string $identifier |
||
22 | * @return \SilverStripe\ORM\DataObject |
||
23 | */ |
||
24 | View Code Duplication | protected function objFromFixture($className, $identifier) |
|
0 ignored issues
–
show
|
|||
25 | { |
||
26 | Subsite::disable_subsite_filter(true); |
||
27 | $obj = parent::objFromFixture($className, $identifier); |
||
28 | Subsite::disable_subsite_filter(false); |
||
29 | |||
30 | return $obj; |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * Tests the initial state of disable_subsite_filter |
||
35 | */ |
||
36 | public function testDisableSubsiteFilter() |
||
37 | { |
||
38 | $this->assertFalse(Subsite::$disable_subsite_filter); |
||
39 | } |
||
40 | } |
||
41 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.