StoreHandlerTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 4
dl 0
loc 42
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testStoringKeyWithHandler() 0 9 1
A testRemoveKey() 0 14 1
A createKeyValue() 0 8 1
1
<?php
2
3
/*
4
 * This file is part of the distributed-configuration-bundle package
5
 *
6
 * Copyright (c) 2016 Guillaume Cavana
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * Feel free to edit as you please, and have fun.
12
 *
13
 * @author Guillaume Cavana <[email protected]>
14
 */
15
16
namespace Maikuro\DistributedConfigurationBundle\Tests;
17
18
use Maikuro\DistributedConfigurationBundle\Handler\StoreHandler;
19
use Maikuro\DistributedConfigurationBundle\Model\KeyValue;
20
use Webmozart\KeyValueStore\ArrayStore;
21
22
class StoreHandlerTest extends \PHPUnit_Framework_TestCase
23
{
24
    /**
25
     * testStoringKeyWithHandler.
26
     */
27
    public function testStoringKeyWithHandler()
28
    {
29
        $keyValue = $this->createKeyValue();
30
        $store = new ArrayStore();
31
        $storeHandler = new StoreHandler($store);
32
        $storeHandler->flush($keyValue);
33
34
        $this->assertEquals($keyValue, $storeHandler->get('test_key'));
35
    }
36
37
    /**
38
     * testStoringKeyWithHandler.
39
     */
40
    public function testRemoveKey()
41
    {
42
        $keyValue = $this->createKeyValue();
43
        $store = new ArrayStore();
44
        $storeHandler = new StoreHandler($store);
45
        $storeHandler->flush($keyValue);
46
        $storeHandler->remove('test_key');
47
48
        $this->setExpectedException('Webmozart\KeyValueStore\Api\NoSuchKeyException');
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
49
50
        $storeHandler->get('test_key');
51
52
        $this->assertEquals($keyValue, $storeHandler->get('test_key'));
53
    }
54
55
    private function createKeyValue()
56
    {
57
        $keyValue = new KeyValue();
58
        $keyValue->setKey('test_key');
59
        $keyValue->setValue('test_value');
60
61
        return $keyValue;
62
    }
63
}
64