FactoryTest::executeCommand()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Siad007\VersionControl\HG\Tests;
4
5
use Siad007\VersionControl\HG\Factory;
6
7
class FactoryTest extends Helpers\TestCase
8
{
9
    protected function setUp()
10
    {
11
        assumePhpVersion('5.4');
12
        parent::setUp();
13
    }
14
15
    /**
16
     * @test
17
     */
18
    public function instantiateHgCommands()
19
    {
20
        $commands = [
21
            'clone',
22
            'init',
23
            'paths',
24
            'pull',
25
            'push',
26
            'root',
27
            'summary',
28
            'tags',
29
            'update',
30
            'verify',
31
            'version'
32
        ];
33
34
        foreach ($commands as $command) {
35
            $this->assertInstanceOf(
36
                sprintf('Siad007\VersionControl\HG\Command\%sCommand', $command),
37
                Factory::getInstance($command)
38
            );
39
        }
40
    }
41
42
    /**
43
     * @test
44
     */
45
    public function privateConstructor()
46
    {
47
        $refClass  = new \ReflectionClass('\\Siad007\\VersionControl\\HG\\Factory');
48
        $refMethod = $refClass->getConstructor();
49
50
        $this->assertTrue($refMethod->isPrivate());
51
    }
52
53
    /**
54
     * @test
55
     * @expectedException \InvalidArgumentException
56
     */
57
    public function notExistingCommand()
58
    {
59
        Factory::getInstance('test');
60
    }
61
62
    /**
63
     * @test
64
     * @expectedException \InvalidArgumentException
65
     */
66
    public function invokeByNonCreate()
67
    {
68
        Factory::nonExisting('test');
69
    }
70
71
    /**
72
     * @test
73
     */
74
    public function executeCommand()
75
    {
76
        $expected = "Mercurial Distributed SCM";
77
78
        $this->assertStringStartsWith($expected, Factory::createVersion()->execute());
79
    }
80
81
    /**
82
     * @test
83
     *
84
     * @expectedException \RuntimeException
85
     */
86
    public function executeCommandWithoutRepositoryInitilized()
87
    {
88
        Factory::createStatus()->execute();
89
    }
90
}
91