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

WorkingDirectorySpec::let()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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