1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* README plugin for HiDev |
5
|
|
|
* |
6
|
|
|
* @link https://github.com/hiqdev/hidev-readme |
7
|
|
|
* @package hidev-readme |
8
|
|
|
* @license BSD-3-Clause |
9
|
|
|
* @copyright Copyright (c) 2015, HiQDev (http://hiqdev.com/) |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace base; |
13
|
|
|
|
14
|
|
|
use hidev\tests\functional\Tester; |
15
|
|
|
|
16
|
|
|
class ReadmeTest extends \PHPUnit_Framework_TestCase |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var \FunctionalTester |
20
|
|
|
*/ |
21
|
|
|
protected $tester; |
22
|
|
|
|
23
|
|
|
protected function setUp() |
24
|
|
|
{ |
25
|
|
|
$this->tester = new Tester($this); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
protected function tearDown() |
29
|
|
|
{ |
30
|
|
|
$this->tester = null; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Test minimal. |
35
|
|
|
*/ |
36
|
|
View Code Duplication |
public function testMinimal() |
|
|
|
|
37
|
|
|
{ |
38
|
|
|
$this->tester->hidev('init the-vendor/new-test-package --norequire --year=2014'); |
39
|
|
|
$this->tester->hidev('README.md'); |
40
|
|
|
$this->tester->assertFileHas('README.md', [ |
41
|
|
|
"New Test Package\n================", |
42
|
|
|
"\n\n## License\n\n", |
43
|
|
|
'This project is released under the terms of the No license', |
44
|
|
|
'Read more [here](http://choosealicense.com/licenses/no-license).', |
45
|
|
|
'Copyright © 2014-' . date('Y') . ', The Vendor', |
46
|
|
|
]); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Test options. |
51
|
|
|
*/ |
52
|
|
View Code Duplication |
public function testMore() |
|
|
|
|
53
|
|
|
{ |
54
|
|
|
$this->tester->hidev('init the-vendor/new-test-package --norequire --headline=Package --license=MIT --year=2014 "--description=The project longer decription"'); |
55
|
|
|
$this->tester->hidev('README.md'); |
56
|
|
|
$this->tester->assertFileHas('README.md', [ |
57
|
|
|
"Package\n=======", |
58
|
|
|
'**New Test Package**', |
59
|
|
|
'The project longer decription', |
60
|
|
|
'## License', |
61
|
|
|
'This project is released under the terms of the MIT [license](LICENSE)', |
62
|
|
|
'Read more [here](http://choosealicense.com/licenses/mit).', |
63
|
|
|
]); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Test docs/readme. |
68
|
|
|
*/ |
69
|
|
|
public function testDocs() |
70
|
|
|
{ |
71
|
|
|
$this->tester->hidev('init the-vendor/new-test-package --norequire --year=2015'); |
72
|
|
|
$this->tester->writeFile('docs/readme/Usage.md', "Usage instructions.\nIn multiple lines."); |
73
|
|
|
$this->tester->hidev('README.md'); |
74
|
|
|
$this->tester->assertFileHas('README.md', [ |
75
|
|
|
"\n\n## Usage\n\nUsage instructions.\nIn multiple lines.\n\n", |
76
|
|
|
]); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.