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'); |
|
|
|
|
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
|
|
|
|
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.