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

Controllers/ElementSiteTreeFilterSearchTest.php (1 issue)

Checks if used types are declared or listed as dependencies.

Bug Major
1
<?php
2
3
namespace DNADesign\Elemental\Tests\Controllers;
4
5
use DNADesign\Elemental\Extensions\ElementalPageExtension;
6
use DNADesign\Elemental\Tests\Src\TestPage;
7
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...
8
use SilverStripe\CMS\Controllers\CMSSiteTreeFilter_Search;
9
use SilverStripe\Dev\SapphireTest;
10
11
class ElementSiteTreeFilterSearchTest extends SapphireTest
12
{
13
    protected static $fixture_file = 'ElementSiteTreeFilterSearchTest.yml';
14
15
    protected static $extra_dataobjects = [
16
        TestPage::class,
17
    ];
18
19
    /**
20
     * @param string $searchTerm
21
     * @param array $expected
22
     * @dataProvider searchProvider
23
     */
24
    public function testElementalPageDataMatchesInCmsSearch($searchTerm, $expected)
25
    {
26
        $filter = CMSSiteTreeFilter_Search::create(['Term' => $searchTerm]);
27
        $result = $filter->getFilteredPages();
28
29
        $this->assertListContains($expected, $result);
30
    }
31
32
    /**
33
     * @return array[]
34
     */
35
    public function searchProvider()
36
    {
37
        return [
38
            'Nested block data' => ['specifically', [
39
                ['Title' => 'Content blocks page'],
40
            ]],
41
            'Regular page data' => ['regular', [
42
                ['Title' => 'Regular page'],
43
            ]],
44
            'Combined results' => ['content', [
45
                ['Title' => 'Content blocks page'],
46
                ['Title' => 'Regular page'],
47
            ]],
48
        ];
49
    }
50
}
51