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
|
|
|
|