ConfigProviderTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 1
cbo 5
dl 0
loc 35
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B testRegister() 0 29 1
1
<?php
2
/*
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the MIT license. For more information, see
17
 * <http://www.doctrine-project.org>.
18
 */
19
20
namespace BaleenTest\Cli\Provider;
21
22
use Baleen\Cli\Config\Config;
23
use Baleen\Cli\Config\ConfigStorage;
24
use Baleen\Cli\Provider\ConfigProvider;
25
use Baleen\Cli\Provider\Services;
26
use Mockery as m;
27
28
/**
29
 * Class ConfigProviderTest
30
 * @author Gabriel Somoza <[email protected]>
31
 */
32
class ConfigProviderTest extends ServiceProviderTestCase
33
{
34
    /**
35
     * testRegister
36
     */
37
    public function testRegister()
38
    {
39
        $configStorage = m::mock(ConfigStorage::class);
40
        $appConfigMock = m::mock(Config::class);
41
        $configStorage->shouldReceive('load')->with(m::type('string'))->once()->andReturn($appConfigMock);
42
43
        $this->setInstance(m::mock(ConfigProvider::class)->makePartial());
44
45
        $localConfigFolder = realpath(implode(DIRECTORY_SEPARATOR, [__DIR__, '..', '..', '..']));
46
        $this->assertFileExists($localConfigFolder);
47
48
        $this->getInstance()->getContainer()
49
            ->shouldReceive('get')
50
            ->with(Services::BALEEN_BASE_DIR)
51
            ->once()
52
            ->andReturn($localConfigFolder);
53
54
        $this->assertSingletonProvided(
55
            Services::CONFIG,
56
            $this->assertCallbackInstanceOf(Config::class, $configStorage)
57
        )->shouldReceive('withArgument')->with(Services::CONFIG_STORAGE);
58
59
        $this->assertSingletonProvided(
60
            Services::CONFIG_STORAGE,
61
            $this->assertCallbackInstanceOf(ConfigStorage::class)
62
        );
63
64
        $this->instance->register();
65
    }
66
}
67