testUpdateListSetsCurrentLocaleIntoHavingInQuery()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 9
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 13
rs 9.9666
1
<?php
2
3
namespace TractorCow\Fluent\Tests\Extension;
4
5
use SilverStripe\CMS\Model\SiteTree;
0 ignored issues
show
Bug introduced by
The type SilverStripe\CMS\Model\SiteTree 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 SilverStripe\Dev\SapphireTest;
7
use TractorCow\Fluent\Extension\FluentReadVersionsExtension;
8
use TractorCow\Fluent\Extension\FluentSiteTreeExtension;
9
use TractorCow\Fluent\State\FluentState;
10
11
class FluentReadVersionsExtensionTest extends SapphireTest
12
{
13
    protected $usesDatabase = true;
14
15
    protected static $required_extensions = [
16
        SiteTree::class => [
17
            FluentSiteTreeExtension::class,
18
        ],
19
    ];
20
21
    public function testUpdateListSetsCurrentLocaleIntoHavingInQuery()
22
    {
23
        FluentState::singleton()->withState(function (FluentState $newState) {
24
            $newState->setLocale('en_NZ');
25
            $list = SiteTree::get();
26
27
            $extension = new FluentReadVersionsExtension();
28
            $extension->updateList($list);
29
30
            $this->assertContains(
31
                ['"SourceLocale" = ?' => ['en_NZ']],
32
                $list->dataQuery()->getFinalisedQuery()->getHaving(),
33
                'Fluent adds the current locale to the underlying list\'s data query'
34
            );
35
        });
36
    }
37
}
38