Passed
Push — master ( 1c50e6...c84c43 )
by Robbie
02:10
created

testConstructorThrowsExceptionWhenGivenChildren()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
class DocumentImportFieldTest extends SapphireTest
0 ignored issues
show
Bug introduced by
The type SapphireTest 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...
4
{
5
    /**
6
     * @expectedException InvalidArgumentException
7
     */
8
    public function testConstructorThrowsExceptionWhenGivenString()
9
    {
10
        new DocumentImportField('exception time!');
11
    }
12
13
    /**
14
     * @expectedException InvalidArgumentException
15
     */
16
    public function testConstructorThrowsExceptionWhenGivenChildren()
17
    {
18
        new DocumentImportField(['i', 'don\'t', 'like', 'kids']);
19
    }
20
21
    public function testFieldAddsJavascriptRequirements()
22
    {
23
        // Start with a clean slate (no global state interference)
24
        Requirements::backend()->clear();
0 ignored issues
show
Bug introduced by
The type Requirements 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...
25
26
        new DocumentImportField();
27
        $javascript = Requirements::backend()->get_javascript();
28
        $this->assertNotEmpty($javascript);
29
    }
30
31
    public function testFieldListGeneration()
32
    {
33
        $importField = new DocumentImportField();
34
35
        $fields = $importField->getChildren();
36
        $this->assertInstanceOf('FieldList', $fields);
37
38
        // We don't need to check that all of the fields are there, but just check a couple
39
        $this->assertInstanceOf('HeaderField', $fields->fieldByName('FileWarningHeader'));
40
        $innerField = $fields->fieldByName('ImportedFromFile');
41
        $this->assertInstanceOf('DocumentImportInnerField', $innerField);
42
43
        // Check the getter works
44
        $this->assertSame($innerField, $importField->getInnerField());
45
46
        // Check the fields have been given has the change tracker disabled
47
        $splitHeader = $fields->fieldByName('DocumentImportField-SplitHeader');
48
        $this->assertInstanceOf('DropdownField', $splitHeader);
49
        $this->assertContains('no-change-track', $splitHeader->extraClass());
50
    }
51
}
52