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

tests/ElementalAreaTest.php (1 issue)

Checks if used types are declared or listed as dependencies.

Bug Major
1
<?php
2
3
namespace DNADesign\Elemental\Tests;
4
5
use DNADesign\Elemental\Extensions\ElementalPageExtension;
6
use DNADesign\Elemental\Models\ElementalArea;
7
use DNADesign\Elemental\Tests\Src\TestElement;
8
use DNADesign\Elemental\Tests\Src\TestPage;
9
use Page;
0 ignored issues
show
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...
10
use SilverStripe\Dev\SapphireTest;
11
12
class ElementalAreaTest extends SapphireTest
13
{
14
    protected static $fixture_file = 'ElementalAreaTest.yml';
15
16
    protected static $required_extensions = [
17
        Page::class => [
18
            ElementalPageExtension::class,
19
        ],
20
    ];
21
22
    protected static $extra_dataobjects = [
23
        TestElement::class,
24
        TestPage::class,
25
    ];
26
27
    public function testElementControllers()
28
    {
29
        $area = $this->objFromFixture(ElementalArea::class, 'area1');
30
        $controllers = $area->ElementControllers();
31
32
        $this->assertEquals(2, $controllers->count(), 'Should be a controller per element');
33
    }
34
35
    public function testGetOwnerPage()
36
    {
37
        $this->markTestIncomplete();
38
    }
39
40
    public function testForTemplate()
41
    {
42
        $area = $this->objFromFixture(ElementalArea::class, 'area1');
43
44
        $this->assertContains('Hello Test', $area->forTemplate());
45
        $this->assertContains('Hello Test 2', $area->forTemplate());
46
    }
47
48
    public function testCanBePublished()
49
    {
50
        $member = $this->logInWithPermission('SITETREE_EDIT_ALL');
51
52
        $page = $this->objFromFixture(TestPage::class, 'page1');
53
        $this->assertTrue($page->canPublish($member));
54
55
        $area = $this->objFromFixture(ElementalArea::class, 'area1');
56
        $this->assertTrue($area->canPublish($member));
57
58
        $element = $this->objFromFixture(TestElement::class, 'element1');
59
        $this->assertTrue($element->canPublish($member));
60
    }
61
}
62