Completed
Pull Request — master (#8)
by VEBER
02:15
created

CommandTest::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of the CLIFramework package.
5
 *
6
 * (c) Arnaud VEBER <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CLIFramework;
13
14
use CLIFramework\Command;
15
16
class CommandTest extends \PHPUnit_Framework_TestCase
17
{
18
    /**
19
     * command mock
20
     *
21
     * @var \CLIFramework\Command
22
     */
23
    private $command = null;
24
25
    /**
26
     * set up
27
     */
28
    public function setUp()
29
    {
30
        // mock command
31
        $this->command = $this->getMockBuilder('\CLIFramework\Command')
32
            ->disableOriginalConstructor()
33
            ->setMethods(array('getCommandName', 'getCommandDescription'))
34
            ->getMock();
35
    }
36
37
    /**
38
     * tear down
39
     */
40
    public function tearDown()
41
    {
42
        $this->command = null;
43
    }
44
45
    /**
46
     * test configure
47
     */
48
    public function testConfigure()
49
    {
50
        // name & description
51
        $name = 'test:command';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 8 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
52
        $description = 'The test command';
53
54
        // stub getCommandName
55
        $this->command->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<CLIFramework\Command>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
56
            ->method('getCommandName')
57
            ->will($this->returnValue($name));
58
59
        // stub getCommandDescription
60
        $this->command->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<CLIFramework\Command>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
61
            ->method('getCommandDescription')
62
            ->will($this->returnValue($description));
63
64
        // configure
65
        $this->command->configure();
66
67
        // asert
68
        $this->assertEquals($name, $this->command->getName());
69
        $this->assertEquals($description, $this->command->getDescription());
70
    }
71
}
72