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

ConfigStoreTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 8
Bugs 1 Features 0
Metric Value
wmc 5
eloc 16
c 8
b 1
f 0
dl 0
loc 47
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testPostConstructGood() 0 7 1
A testPostConstruct() 0 3 1
A testPostConstructNoPath() 0 5 1
A testFileConstruct() 0 3 1
A testFileConstructGood() 0 6 1
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