Completed
Push — master ( 456549...47da6e )
by Łukasz
02:25
created

WorkingDirectorySpec   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 5
dl 0
loc 46
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 7 1
A it_should_provide_absolute_path() 0 4 1
A it_should_return_path_for_to_string_method() 0 4 1
A it_should_touch_dot_file() 0 6 1
A it_should_load_dot_env() 0 5 1
A it_should_get_candidates() 0 5 1
1
<?php
2
3
namespace spec\Tworzenieweb\SqlProvisioner\Filesystem;
4
5
use Prophecy\Argument;
6
use Symfony\Component\Filesystem\Filesystem;
7
use Tworzenieweb\SqlProvisioner\Filesystem\CandidatesFinder;
8
use Tworzenieweb\SqlProvisioner\Filesystem\EnvironmentLoaderInterface;
9
use Tworzenieweb\SqlProvisioner\Filesystem\WorkingDirectory;
10
use PhpSpec\ObjectBehavior;
11
12
/**
13
 * @author Luke Adamczewski
14
 * @package spec\Tworzenieweb\SqlProvisioner\Filesystem
15
 * @mixin WorkingDirectory
16
 */
17
class WorkingDirectorySpec extends ObjectBehavior
18
{
19
    private $dotEnvPath;
20
21
    private $currentDirectory;
22
23
    function let(CandidatesFinder $candidatesFinder, Filesystem $filesystem, EnvironmentLoaderInterface $environmentLoader)
24
    {
25
        $this->currentDirectory = __DIR__;
26
        $this->dotEnvPath = $this->currentDirectory . DIRECTORY_SEPARATOR . '.env';
27
        $filesystem->isAbsolutePath($this->currentDirectory)->willReturn(true);
28
        $this->beConstructedWith($this->currentDirectory, $candidatesFinder, $filesystem, $environmentLoader);
29
    }
30
31
    function it_should_provide_absolute_path()
32
    {
33
        $this->getCurrentDirectoryAbsolute()->shouldReturn($this->currentDirectory);
34
    }
35
36
    function it_should_return_path_for_to_string_method()
37
    {
38
        $this->__toString()->shouldReturn($this->currentDirectory);
39
    }
40
41
    function it_should_touch_dot_file(Filesystem $filesystem)
42
    {
43
        $filesystem->isAbsolutePath($this->getCurrentDirectoryAbsolute())->shouldBeCalled();
44
        $filesystem->dumpFile(Argument::type('string'), WorkingDirectory::DRAFT_CONTENT)->shouldBeCalled();
45
        $this->createEnvironmentFile();
46
    }
47
48
    /**
49
     * @param EnvironmentLoaderInterface $environmentLoader
50
     */
51
    function it_should_load_dot_env(EnvironmentLoaderInterface $environmentLoader)
52
    {
53
        $environmentLoader->load($this)->shouldBeCalled();
54
        $this->loadEnvironment();
55
    }
56
57
    function it_should_get_candidates(CandidatesFinder $candidatesFinder)
58
    {
59
        $candidatesFinder->find($this->currentDirectory)->shouldBeCalled();
60
        $this->getCandidates();
61
    }
62
}
63