Passed
Push — sheepy/elevation-configuration ( bdeab0...bcf7bc )
by Marco
18:34
created

ConfigStoreTest::testPostConstruct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
4
namespace Firesphere\SolrSearch\Tests;
5
6
use Firesphere\SolrSearch\Stores\FileConfigStore;
7
use Firesphere\SolrSearch\Stores\PostConfigStore;
8
use SilverStripe\Control\Director;
9
use SilverStripe\Dev\SapphireTest;
10
11
class ConfigStoreTest extends SapphireTest
12
{
13
    protected static $fixture_file = '../fixtures/DataResolver.yml';
14
    protected static $extra_dataobjects = [
15
        TestObject::class,
16
        TestPage::class,
17
        TestRelationObject::class,
18
    ];
19
20
    /**
21
     * @expectedException \Solarium\Exception\RuntimeException
22
     */
23
    public function testFileConstruct()
24
    {
25
        new FileConfigStore([]);
26
    }
27
28
    public function testFileConstructGood()
29
    {
30
        $store = new FileConfigStore(['path' => 'test']);
31
        $this->assertEquals(Director::baseFolder() . '/test/lol', $store->instanceDir('lol'));
32
33
        $this->assertEquals(['path' => Director::baseFolder() . '/test'], $store->getConfig());
34
    }
35
36
    /**
37
     * @expectedException \Solarium\Exception\RuntimeException
38
     */
39
    public function testPostConstruct()
40
    {
41
        new PostConfigStore([]);
42
    }
43
44
    public function testPostConstructGood()
45
    {
46
        $store = new PostConfigStore(['path' => 'test']);
47
48
        $this->assertEquals('test/', $store->getPath());
49
50
        $this->assertEquals('lol', $store->instanceDir('lol'));
51
    }
52
53
    public function testPostConstructNoPath()
54
    {
55
        $store = new PostConfigStore(['test' => 'this']);
56
57
        $this->assertEquals('/', $store->getPath());
58
    }
59
}
60