Completed
Push — master ( 0f3db4...6e7c4d )
by Guillaume
16:16
created

StoreHandlerTest::testRemoveKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
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