|
1
|
|
|
<?php |
|
|
|
|
|
|
2
|
|
|
/** |
|
3
|
|
|
* Changelog keeper |
|
4
|
|
|
* |
|
5
|
|
|
* @link https://github.com/hiqdev/chkipper |
|
6
|
|
|
* @package chkipper |
|
7
|
|
|
* @license BSD-3-Clause |
|
8
|
|
|
* @copyright Copyright (c) 2016-2017, HiQDev (http://hiqdev.com/) |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace hiqdev\chkipper\tests\unit\lib; |
|
12
|
|
|
|
|
13
|
|
|
use hiqdev\chkipper\lib\Commit; |
|
14
|
|
|
use hiqdev\chkipper\lib\History; |
|
15
|
|
|
use hiqdev\chkipper\lib\Note; |
|
16
|
|
|
use hiqdev\chkipper\lib\parsers\MarkdownParser; |
|
17
|
|
|
use hiqdev\chkipper\lib\Tag; |
|
18
|
|
|
|
|
19
|
|
|
ini_set('xdebug.var_display_max_depth', 15); |
|
20
|
|
|
ini_set('xdebug.var_display_max_children', 256); |
|
21
|
|
|
ini_set('xdebug.var_display_max_data', 1024); |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Markdown history parser test case. |
|
25
|
|
|
* |
|
26
|
|
|
* @author Andrii Vasyliev <[email protected]> |
|
27
|
|
|
*/ |
|
28
|
|
|
class MarkdownParserTest extends \PHPUnit_Framework_TestCase |
|
29
|
|
|
{ |
|
30
|
|
|
/** |
|
31
|
|
|
* @var MarkdownParser |
|
32
|
|
|
*/ |
|
33
|
|
|
protected $object; |
|
34
|
|
|
|
|
35
|
|
|
protected $note = 'Added basics'; |
|
36
|
|
|
protected $hash = 'b22f8ac'; |
|
37
|
|
|
protected $date = '2016-06-11'; |
|
38
|
|
|
protected $subject = 'inited'; |
|
39
|
|
|
protected $author = '@hiqsol'; |
|
40
|
|
|
protected $email = '[email protected]'; |
|
41
|
|
|
protected $label; |
|
42
|
|
|
protected $comment = ' - longer description for initial commit'; |
|
43
|
|
|
|
|
44
|
|
|
protected function setUp() |
|
45
|
|
|
{ |
|
46
|
|
|
$this->label = $this->date . ' ' . $this->subject . ' [' . $this->author . ']'; |
|
47
|
|
|
$this->object = new MarkdownParser(new Config()); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
protected function tearDown() |
|
51
|
|
|
{ |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function testParsePath() |
|
55
|
|
|
{ |
|
56
|
|
|
$this->object->parsePath(__DIR__ . '/minimal.md'); |
|
57
|
|
|
$history = new History($this->object->getConfig()); |
|
58
|
|
|
$history->setHeaders([ |
|
59
|
|
|
'hiqdev/chkipper commits history', |
|
60
|
|
|
'-------------------------------', |
|
61
|
|
|
]); |
|
62
|
|
|
$history->setTags([ |
|
63
|
|
|
$this->object->getLastTag() => new Tag( |
|
64
|
|
|
$this->object->getLastTag(), |
|
65
|
|
|
null, |
|
66
|
|
|
[ |
|
67
|
|
|
$this->note => new Note($this->note, [ |
|
68
|
|
|
$this->hash => new Commit($this->hash, $this->label, [$this->comment]), |
|
69
|
|
|
]), |
|
70
|
|
|
] |
|
71
|
|
|
), |
|
72
|
|
|
$this->object->getInitTag() => new Tag($this->object->getInitTag(), $this->date), |
|
73
|
|
|
]); |
|
74
|
|
|
$history->addHash($this->hash); |
|
75
|
|
|
$history->setLinks([ |
|
76
|
|
|
'Under development' => 'https://github.com/hiqdev/chkipper/releases', |
|
77
|
|
|
'Development started' => 'https://github.com/hiqdev/chkipper/releases', |
|
78
|
|
|
'[email protected]' => 'https://github.com/hiqsol', |
|
79
|
|
|
'@hiqsol' => 'https://github.com/hiqsol', |
|
80
|
|
|
'b22f8ac' => 'https://github.com/hiqdev/chkipper/commit/b22f8ac', |
|
81
|
|
|
]); |
|
82
|
|
|
$this->assertEquals($history, $this->object->getHistory()); |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.