1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of phpDocumentor. |
4
|
|
|
* |
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
6
|
|
|
* file that was distributed with this source code. |
7
|
|
|
* |
8
|
|
|
* @copyright 2010-2016 Mike van Riel<[email protected]> |
9
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT |
10
|
|
|
* @link http://phpdoc.org |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace phpDocumentor\Application\Configuration\Factory; |
14
|
|
|
|
15
|
|
|
use phpDocumentor\DomainModel\Dsn; |
16
|
|
|
use phpDocumentor\DomainModel\Path; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @coversDefaultClass phpDocumentor\Application\Configuration\Factory\CommandlineOptionsMiddleware |
20
|
|
|
* @covers ::__construct |
21
|
|
|
* @covers ::<private> |
22
|
|
|
*/ |
23
|
|
|
final class CommandlineOptionsMiddlewareTest extends \PHPUnit_Framework_TestCase |
24
|
|
|
{ |
25
|
|
|
/** @var CommandlineOptionsMiddleware */ |
26
|
|
|
private $middleware; |
27
|
|
|
|
28
|
|
|
public function setUp() |
29
|
|
|
{ |
30
|
|
|
$this->middleware = new CommandlineOptionsMiddleware(); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @test |
35
|
|
|
* @covers ::provideOptions |
36
|
|
|
* @covers ::__invoke |
37
|
|
|
*/ |
38
|
|
|
public function itShouldOverwriteTheDestinationFolderBasedOnTheTargetOption() |
39
|
|
|
{ |
40
|
|
|
$expected = '/abc'; |
41
|
|
|
$configuration = ['phpdocumentor' => ['paths' => ['output' => '/tmp']]]; |
42
|
|
|
$this->middleware->provideOptions(['target' => $expected]); |
43
|
|
|
$newConfiguration = $this->middleware->__invoke($configuration); |
44
|
|
|
|
45
|
|
|
$this->assertEquals(new Dsn($expected), $newConfiguration['phpdocumentor']['paths']['output']); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @test |
50
|
|
|
* @covers ::provideOptions |
51
|
|
|
* @covers ::__invoke |
52
|
|
|
*/ |
53
|
|
|
public function itShouldOverwriteTheCacheFolderBasedOnTheCacheFolderOption() |
54
|
|
|
{ |
55
|
|
|
$expected = '/abc'; |
56
|
|
|
$configuration = ['phpdocumentor' => ['paths' => ['cache' => '/tmp']]]; |
57
|
|
|
$this->middleware->provideOptions(['cache-folder' => $expected]); |
58
|
|
|
$newConfiguration = $this->middleware->__invoke($configuration); |
59
|
|
|
|
60
|
|
|
$this->assertEquals(new Path($expected), $newConfiguration['phpdocumentor']['paths']['cache']); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @test |
65
|
|
|
* @covers ::provideOptions |
66
|
|
|
* @covers ::__invoke |
67
|
|
|
*/ |
68
|
|
|
public function itShouldDisableTheCacheBasedOnTheForceOption() |
69
|
|
|
{ |
70
|
|
|
$configuration = ['phpdocumentor' => ['use-cache' => true]]; |
71
|
|
|
$this->middleware->provideOptions(['force' => true]); |
72
|
|
|
$newConfiguration = $this->middleware->__invoke($configuration); |
73
|
|
|
|
74
|
|
|
$this->assertFalse($newConfiguration['phpdocumentor']['use-cache']); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @test |
79
|
|
|
* @covers ::provideOptions |
80
|
|
|
* @covers ::__invoke |
81
|
|
|
*/ |
82
|
|
|
public function itShouldOverrideTheTitleBasedOnTheTitleOption() |
83
|
|
|
{ |
84
|
|
|
$expected = 'phpDocumentor3'; |
85
|
|
|
$configuration = ['phpdocumentor' => ['title' => 'phpDocumentor2']]; |
86
|
|
|
$this->middleware->provideOptions(['title' => $expected]); |
87
|
|
|
$newConfiguration = $this->middleware->__invoke($configuration); |
88
|
|
|
|
89
|
|
|
$this->assertSame($expected, $newConfiguration['phpdocumentor']['title']); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @test |
94
|
|
|
* @covers ::provideOptions |
95
|
|
|
* @covers ::__invoke |
96
|
|
|
*/ |
97
|
|
|
public function itShouldOverrideTheListOfTemplatesBasedOnTheTemplateOption() |
98
|
|
|
{ |
99
|
|
|
$expected = 'clean'; |
100
|
|
|
$configuration = ['phpdocumentor' => ['templates' => ['responsive']]]; |
101
|
|
|
$this->middleware->provideOptions(['template' => $expected]); |
102
|
|
|
$newConfiguration = $this->middleware->__invoke($configuration); |
103
|
|
|
|
104
|
|
|
$this->assertSame([$expected], $newConfiguration['phpdocumentor']['templates']); |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
|