FluentReadVersionsExtensionTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 14
c 2
b 0
f 1
dl 0
loc 23
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testUpdateListSetsCurrentLocaleIntoHavingInQuery() 0 13 1
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