|
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
|
|
|
|