Passed
Pull Request — master (#27)
by Robbie
02:54
created

DatedUpdateHolderControllerTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 9.4285
1
<?php
2
3
namespace CWP\CWP\Tests\PageTypes;
4
5
use CWP\CWP\PageTypes\EventHolder;
6
use SilverStripe\Core\Config\Config;
7
use SilverStripe\Dev\FunctionalTest;
8
use SilverStripe\View\SSViewer;
9
10
class DatedUpdateHolderControllerTest extends FunctionalTest
11
{
12
    protected static $fixture_file = 'EventHolderTest.yml';
13
14
    protected static $use_draft_site = true;
15
16
    protected function setUp()
17
    {
18
        parent::setUp();
19
20
        // Note: this test requires the starter theme to be installed
21
        Config::inst()->update(SSViewer::class, 'theme', 'starter');
0 ignored issues
show
Bug introduced by
The method update() does not exist on SilverStripe\Config\Coll...nfigCollectionInterface. It seems like you code against a sub-type of SilverStripe\Config\Coll...nfigCollectionInterface such as SilverStripe\Config\Coll...\MemoryConfigCollection. ( Ignorable by Annotation )

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

21
        Config::inst()->/** @scrutinizer ignore-call */ update(SSViewer::class, 'theme', 'starter');
Loading history...
22
    }
23
24
    public function testSettingDateFiltersInReverseOrderShowsMessage()
25
    {
26
        /** @var EventHolder $holder */
27
        $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1');
28
29
        $result = $this->get($holder->Link() . '?from=2018-01-10&to=2018-01-01');
30
31
        $this->assertContains('Filter has been applied with the dates reversed', $result->getBody());
32
    }
33
34
    public function testSettingFromButNotToDateShowsMessage()
35
    {
36
        /** @var EventHolder $holder */
37
        $holder = $this->objFromFixture(EventHolder::class, 'EventHolder1');
38
39
        $result = $this->get($holder->Link() . '?from=2018-01-10');
40
41
        $this->assertContains('Filtered by a single date', $result->getBody());
42
    }
43
}
44