CreateSettingsContext::theValueForKeyShouldBe()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace Galileo\SettingBundle\Features\Context;
4
5
use Behat\Behat\Context\Context;
6
use Galileo\SettingBundle\Lib\Application\SettingApplication;
7
use Galileo\SettingBundle\Lib\Infrastructure\Internal\InMemorySettingRepository;
8
use Galileo\SettingBundle\Lib\Model\ValueObject\Section;
9
10
class CreateSettingsContext implements Context
11
{
12
    /**
13
     * @var SettingApplication
14
     */
15
    private $settings;
16
17
    /**
18
     * @Given there is nothing registered in storage system
19
     */
20
    public function thereIsNothingRegisteredInStorageSystem()
21
    {
22
        $settingRepository = new InMemorySettingRepository([]);
23
        $this->settings = new SettingApplication($settingRepository);
24
    }
25
26
    /**
27
     * @Given there is already registered :key setting with :value value
28
     */
29
    public function alreadyRegisteredKeyWithValue($key, $value)
30
    {
31
        $this->settings = new SettingApplication(
32
            new InMemorySettingRepository([[$key, $value, Section::EMPTY_SECTION]])
33
        );
34
    }
35
36
    /**
37
     * @When you try to create new setting named :settingName with value :settingValue
38
     */
39
    public function youTryToCreateNewSettingNamedWithValue($settingName, $settingValue)
40
    {
41
        $this->settings->set($settingName, $settingValue);
42
    }
43
44
    /**
45
     * @Then the value for :key should be :value
46
     */
47
    public function theValueForKeyShouldBe($key, $value)
48
    {
49
        assert($value === $this->settings->get($key), 'Key value not the same as stored one');
50
    }
51
}
52