|
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; |
|
21
|
|
|
|
|
22
|
|
|
use Baleen\Cli\Application; |
|
23
|
|
|
use Mockery as m; |
|
24
|
|
|
use Symfony\Component\Console\Command\Command; |
|
25
|
|
|
use Symfony\Component\Console\Helper\HelperSet; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Class ApplicationTest |
|
29
|
|
|
* @author Gabriel Somoza <[email protected]> |
|
30
|
|
|
*/ |
|
31
|
|
|
class ApplicationTest extends BaseTestCase |
|
32
|
|
|
{ |
|
33
|
|
|
|
|
34
|
|
|
public function testConstructor() |
|
35
|
|
|
{ |
|
36
|
|
|
$commands = [new Command('test')]; |
|
37
|
|
|
$helperSet = m::mock(HelperSet::class); |
|
38
|
|
|
$instance = new Application($commands, $helperSet); |
|
39
|
|
|
$this->assertEquals('Baleen', $instance->getName()); |
|
40
|
|
|
|
|
41
|
|
|
// here's how we can test that the init() function got called in the constructor |
|
42
|
|
|
$this->assertSame($helperSet, $instance->getHelperSet()); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function testInit() |
|
46
|
|
|
{ |
|
47
|
|
|
$commands = [new Command('test')]; |
|
48
|
|
|
$helperSet = m::mock(HelperSet::class); |
|
49
|
|
|
$instance = m::mock(Application::class) |
|
50
|
|
|
->makePartial(); |
|
51
|
|
|
$instance->shouldReceive('setCatchExceptions')->with(true)->once(); |
|
52
|
|
|
$instance->shouldReceive('setHelperSet')->with($helperSet)->once(); |
|
53
|
|
|
$instance->shouldReceive('addCommands')->with($commands)->once(); |
|
54
|
|
|
$this->invokeMethod('init', $instance, [$commands, $helperSet]); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|