Passed
Push — sheepy/introspection ( 9a33c8...7d1300 )
by Marco
05:54
created

ConfigStoreTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 5
eloc 11
dl 0
loc 41
rs 10
c 3
b 1
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testFileConstruct() 0 3 1
A testPostConstructGood() 0 7 1
A testPostConstruct() 0 3 1
A testFileConstructGood() 0 6 1
A testPostConstructNoPath() 0 5 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
14
    /**
15
     * @expectedException \Solarium\Exception\RuntimeException
16
     */
17
    public function testFileConstruct()
18
    {
19
        new FileConfigStore([]);
20
    }
21
22
    public function testFileConstructGood()
23
    {
24
        $store = new FileConfigStore(['path' => 'test']);
25
        $this->assertEquals(Director::baseFolder() . '/test/lol', $store->instanceDir('lol'));
26
27
        $this->assertEquals(['path' => Director::baseFolder() . '/test'], $store->getConfig());
28
    }
29
30
    /**
31
     * @expectedException \Solarium\Exception\RuntimeException
32
     */
33
    public function testPostConstruct()
34
    {
35
        new PostConfigStore([]);
36
    }
37
38
    public function testPostConstructGood()
39
    {
40
        $store = new PostConfigStore(['path' => 'test']);
41
42
        $this->assertEquals('test/', $store->getPath());
43
44
        $this->assertEquals('lol', $store->instanceDir('lol'));
45
    }
46
47
    public function testPostConstructNoPath()
48
    {
49
        $store = new PostConfigStore(['test' => 'this']);
50
51
        $this->assertEquals('/', $store->getPath());
52
    }
53
}
54