Test Setup Failed
Pull Request — master (#197)
by Gorrie
01:07
created

tests/Reports/ElementTypeReportTest.php (1 issue)

1
<?php
2
3
namespace DNADesign\Elemental\Tests\Reports;
4
5
use DNADesign\Elemental\Reports\ElementTypeReport;
6
use DNADesign\Elemental\Tests\Src\TestElement;
7
use DNADesign\Elemental\Tests\Src\TestPage;
8
use DNADesign\Elemental\Tests\Src\TestUnusedElement;
9
use SilverStripe\Dev\FunctionalTest;
10
use SilverStripe\ORM\ArrayList;
11
use SilverStripe\View\ArrayData;
12
13
class ElementTypeReportTest extends FunctionalTest
14
{
15
    protected $usesDatabase = true;
16
17
    protected static $extra_dataobjects = [
18
        TestElement::class,
19
        TestPage::class,
20
        TestUnusedElement::class,
21
    ];
22
23
    public function testReportShowsBlockTypes()
24
    {
25
        $this->logInWithPermission('ADMIN');
26
27
        $result = (string) $this->get('admin/reports/show/DNADesign-Elemental-Reports-ElementTypeReport')->getBody();
28
29
        $this->assertContains('Content Type', $result, 'Table has headings');
30
31
        $this->assertContains('Unused Element', $result, 'Unused elements are still shown in the report');
32
33
        $this->assertContains(
34
            'data-class="DNADesign-Elemental-Models-ElementContent"',
35
            $result,
36
            'Report contains content element (bundled with elemental)'
37
        );
38
    }
39
40
    public function testSourceRecords()
41
    {
42
        $records = (new ElementTypeReport)->sourceRecords();
43
44
        $this->assertInstanceOf(ArrayList::class, $records);
45
        $this->assertNotContains(BaseElement::class, $records->toArray(), 'BaseElement is excluded');
0 ignored issues
show
The type DNADesign\Elemental\Tests\Reports\BaseElement 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...
46
47
        $this->assertContainsOnlyInstancesOf(ArrayData::class, $records);
48
49
        foreach ($records as $record) {
50
            $this->assertNotNull($record->Icon);
51
            $this->assertNotNull($record->Type);
52
            $this->assertInternalType('int', $record->Total);
53
        }
54
    }
55
}
56