Completed
Push — develop ( 9ac21c...a157fb )
by Tom
04:58
created

OptionParserTest::parseLongOptionArgument()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
rs 9.4285
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
/*
3
 * this file is part of magerun
4
 *
5
 * @author Tom Klingenberg <https://github.com/ktomk>
6
 */
7
8
namespace N98\Magento\Application;
9
10
use N98\Magento\Command\PHPUnit\TestCase;
11
12
/**
13
 * Class OptionParserTest
14
 *
15
 * @covers  N98\Magento\Application\OptionParser
16
 * @package N98\Magento\Application
17
 */
18
class OptionParserTest extends TestCase
19
{
20
    /**
21
     * @test
22
     */
23
    public function creation()
24
    {
25
        $parser = OptionParser::init(array());
26
        $this->assertInstanceOf('\N98\Magento\Application\OptionParser', $parser);
27
    }
28
29
    /**
30
     * @test
31
     */
32
    public function parseLongOptionArgument()
33
    {
34
        $parser = new OptionParser(array('--root-dir'));
35
        $this->assertNull($parser->getLongOptionArgument('root-dir'));
36
37
        $parser = new OptionParser(array('', '--root-dir'));
38
        $this->assertNull($parser->getLongOptionArgument('root-dir'));
39
40
        $parser = new OptionParser(array('', '--root-dir='));
41
        $this->assertNull($parser->getLongOptionArgument('root-dir'));
42
43
        $parser = new OptionParser(array('', '--root-dir=value'));
44
        $this->assertNotNull($parser->getLongOptionArgument('root-dir'));
45
        $this->assertSame('value', $parser->getLongOptionArgument('root-dir'));
46
    }
47
48
    /**
49
     * @test
50
     */
51
    public function hasLongOption()
52
    {
53
        $parser = new OptionParser(array('--root-dir'));
54
        $this->assertNull($parser->hasLongOption('root-dir'));
55
56
        $parser = new OptionParser(array('', '--root-dir'));
57
        $this->assertTrue($parser->hasLongOption('root-dir'));
58
59
        $parser = new OptionParser(array('', '--root-dir='));
60
        $this->assertNull($parser->hasLongOption('root-dir'));
61
    }
62
}
63