|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of Bldr.io |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Aaron Scherer <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to the MIT license that is bundled |
|
9
|
|
|
* with this source code in the file LICENSE |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Bldr\Tests\Block\Miscellaneous\Task; |
|
13
|
|
|
|
|
14
|
|
|
use Bldr\Block\Miscellaneous\Task\ExportTask; |
|
15
|
|
|
use Bldr\Block\Miscellaneous\Service\EnvironmentVariableRepository; |
|
16
|
|
|
use Symfony\Component\Console\Output\NullOutput; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @author Luis Cordova <[email protected]> |
|
20
|
|
|
* @author Raul Rodriguez <[email protected]> |
|
21
|
|
|
*/ |
|
22
|
|
|
class ExportTaskTest extends \PHPUnit_Framework_TestCase |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* @type ExportTask |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $exportTask; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @type EnvironmentVariableRepository |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $environmentVariableRepository; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* |
|
36
|
|
|
*/ |
|
37
|
|
|
public function setUp() |
|
38
|
|
|
{ |
|
39
|
|
|
$this->environmentVariableRepository = new EnvironmentVariableRepository(); |
|
40
|
|
|
$this->exportTask = new ExportTask($this->environmentVariableRepository); |
|
41
|
|
|
$this->exportTask->configure(); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* |
|
46
|
|
|
*/ |
|
47
|
|
|
public function testSetEnvVarsWithValidValues() |
|
48
|
|
|
{ |
|
49
|
|
|
$this->exportTask->setParameter('arguments', ['SYMFONY_ENV=prod', 'TRAVIS_DEBUG=true', 'TRAVIS_BOOLEAN=']); |
|
50
|
|
|
|
|
51
|
|
|
$this->assertCount(0, $this->environmentVariableRepository->getEnvironmentVariables()); |
|
52
|
|
|
|
|
53
|
|
|
$this->exportTask->run(new NullOutput()); |
|
54
|
|
|
|
|
55
|
|
|
$this->assertCount(3, $this->environmentVariableRepository->getEnvironmentVariables()); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* |
|
60
|
|
|
*/ |
|
61
|
|
|
public function testSetEnvVarsWithInvalidValue() |
|
62
|
|
|
{ |
|
63
|
|
|
$this->setExpectedException( |
|
64
|
|
|
'\Bldr\Exception\TaskRuntimeException', |
|
65
|
|
|
'Each argument needs to follow the pattern e.g. SYMFONY_ENV=prod' |
|
66
|
|
|
); |
|
67
|
|
|
|
|
68
|
|
|
$this->exportTask->setParameter('arguments', ['TRAVIS_WRONG_VALUE']); |
|
69
|
|
|
|
|
70
|
|
|
$this->exportTask->run(new NullOutput()); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|