Passed
Push — master ( a1de92...1a465b )
by Robbie
03:52
created

ElementalEditorTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testGetField() 0 12 1
1
<?php
2
3
namespace DNADesign\Elemental\Tests;
4
5
use DNADesign\Elemental\ElementalEditor;
0 ignored issues
show
Bug introduced by Robbie Averill
The type DNADesign\Elemental\ElementalEditor 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...
6
use DNADesign\Elemental\Extensions\ElementalPageExtension;
7
use DNADesign\Elemental\Forms\ElementalAreaField;
8
use DNADesign\Elemental\Models\ElementalArea;
9
use DNADesign\Elemental\Models\ElementContent;
10
use Page;
0 ignored issues
show
Bug introduced by Will Rossiter
The type Page 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...
11
use SilverStripe\Dev\SapphireTest;
12
use SilverStripe\Forms\FormField;
13
use SilverStripe\Forms\GridField\GridField;
14
use Symbiote\GridFieldExtensions\GridFieldAddNewMultiClass;
15
16
class ElementalEditorTest extends SapphireTest
17
{
18
    protected static $fixture_file = 'ElementalEditorTest.yml';
19
20
    protected static $required_extensions = [
21
        Page::class => [
22
            ElementalPageExtension::class,
23
        ],
24
    ];
25
26
    public function testGetField()
27
    {
28
        $area = $this->objFromFixture(ElementalArea::class, 'area1');
29
30
        $field = ElementalAreaField::create('ElementalArea', $area, [ElementContent::class]);
31
        $this->assertInstanceOf(FormField::class, $field);
32
        $this->assertEquals('ElementalArea', $field->getName());
33
34
        $classes = $field->getConfig()->getComponentByType(GridFieldAddNewMultiClass::class)->getClasses($field);
35
36
        $this->assertCount(1, $classes, 'Only one type available');
37
        $this->assertArrayHasKey('DNADesign-Elemental-Models-ElementContent', $classes);
0 ignored issues
show
Bug introduced by Guy Marriott
It seems like $classes can also be of type Countable and Traversable; however, parameter $array of PHPUnit_Framework_Assert::assertArrayHasKey() does only seem to accept ArrayAccess|array, maybe add an additional type check? ( Ignorable by Annotation )

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

37
        $this->assertArrayHasKey('DNADesign-Elemental-Models-ElementContent', /** @scrutinizer ignore-type */ $classes);
Loading history...
38
    }
39
}
40