Completed
Push — master ( 84107b...f0cb22 )
by Robbie
11s
created

FluentExtensionTest::testGetLocalisedTable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace TractorCow\Fluent\Tests\Extension;
4
5
use SilverStripe\CMS\Model\SiteTree;
6
use SilverStripe\Dev\SapphireTest;
7
use TractorCow\Fluent\Extension\FluentExtension;
8
use TractorCow\Fluent\State\FluentState;
9
use TractorCow\Fluent\Tests\Extension\Stub\FluentStubObject;
10
11
class FluentExtensionTest extends SapphireTest
12
{
13
    protected static $required_extensions = [
14
        SiteTree::class => [FluentExtension::class],
15
        FluentStubObject::class => [FluentExtension::class],
16
    ];
17
18
    public function testFluentLocaleAndFrontendAreAddedToDataQuery()
19
    {
20
        FluentState::singleton()
21
            ->setLocale('test')
22
            ->setIsFrontend(true);
23
24
        /** @var \SilverStripe\ORM\DataQuery $query */
25
        $query = SiteTree::get()->dataQuery();
26
        $this->assertSame('test', $query->getQueryParam('Fluent.Locale'));
27
        $this->assertTrue($query->getQueryParam('Fluent.IsFrontend'));
0 ignored issues
show
Bug introduced by
$query->getQueryParam('Fluent.IsFrontend') of type string is incompatible with the type boolean expected by parameter $condition of PHPUnit_Framework_Assert::assertTrue(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

27
        $this->assertTrue(/** @scrutinizer ignore-type */ $query->getQueryParam('Fluent.IsFrontend'));
Loading history...
28
    }
29
30
    public function testGetLocalisedTable()
31
    {
32
        $this->assertSame('SiteTree_Localised', (new SiteTree)->getLocalisedTable('SiteTree'));
33
        $this->assertSame('SiteTree_Localised_FR', (new SiteTree)->getLocalisedTable('SiteTree', 'FR'));
34
    }
35
}
36