BaseElementExtensionTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 16
c 2
b 0
f 0
dl 0
loc 37
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testUpdateCmsFields() 0 8 1
A setUp() 0 8 1
A testVirtualElementAnchor() 0 8 1
1
<?php
2
3
namespace DNADesign\ElementalVirtual\Tests;
4
5
use DNADesign\Elemental\Models\BaseElement;
6
use DNADesign\Elemental\Models\ElementalArea;
7
use DNADesign\Elemental\Tests\Src\TestElement;
0 ignored issues
show
Bug introduced by
The type DNADesign\Elemental\Tests\Src\TestElement was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use DNADesign\Elemental\Tests\Src\TestPage;
0 ignored issues
show
Bug introduced by
The type DNADesign\Elemental\Tests\Src\TestPage was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use DNADesign\ElementalVirtual\Model\ElementVirtual;
10
use SilverStripe\Core\Config\Config;
11
use SilverStripe\Dev\SapphireTest;
12
13
class BaseElementExtensionTest extends SapphireTest
14
{
15
    protected static $fixture_file = 'BaseElementExtensionTest.yml';
16
17
    protected static $extra_dataobjects = [
18
        TestElement::class,
19
        TestPage::class
20
    ];
21
22
    public function setUp()
23
    {
24
        parent::setUp();
25
26
        Config::modify()->set('Page', 'can_be_root', true);
27
28
        $this->page = $this->objFromFixture(TestPage::class, 'page1');
0 ignored issues
show
Bug Best Practice introduced by
The property page does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
29
        $this->page->publishRecursive();
30
    }
31
32
    public function testVirtualElementAnchor()
33
    {
34
        Config::modify()->set(BaseElement::class, 'disable_pretty_anchor_name', true);
35
36
        $element = $this->objFromFixture(ElementVirtual::class, 'virtual1');
37
        $linked = $this->objFromFixture(TestElement::class, 'element1');
38
39
        $this->assertEquals('e' . $linked->ID, $element->getAnchor());
40
    }
41
42
    public function testUpdateCmsFields()
43
    {
44
        $linked = $this->objFromFixture(TestElement::class, 'element1');
45
46
        // should show that this element has virtual clones
47
        $list = $linked->getCMSFields()->dataFieldByName('VirtualClones')->getList();
48
49
        $this->assertEquals(1, $list->count());
50
    }
51
}
52