|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the GitElephant package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Matteo Giachino <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
* |
|
11
|
|
|
* Just for fun... |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace GitElephant\Objects\Commit; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Commit message tests |
|
18
|
|
|
* |
|
19
|
|
|
* @author Mathias Geat <[email protected]> |
|
20
|
|
|
*/ |
|
21
|
|
|
class MessageTest extends \PHPUnit_Framework_TestCase |
|
22
|
|
|
{ |
|
23
|
|
|
protected $shortMsg; |
|
24
|
|
|
protected $longMsg; |
|
25
|
|
|
protected $fullMsg; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var Message |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $msg; |
|
31
|
|
|
|
|
32
|
|
|
protected function setUp() |
|
33
|
|
|
{ |
|
34
|
|
|
$this->shortMsg = 'This is the short message'; |
|
35
|
|
|
$this->longMsg = <<<HDOC |
|
36
|
|
|
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, |
|
37
|
|
|
sed diam nonumy eirmod tempor invidunt ut labore et dolore |
|
38
|
|
|
magna aliquyam erat, sed diam voluptua. At vero eos et accusam |
|
39
|
|
|
et justo duo dolores et ea rebum. |
|
40
|
|
|
HDOC; |
|
41
|
|
|
|
|
42
|
|
|
$this->fullMsg = $this->shortMsg . PHP_EOL . PHP_EOL . $this->longMsg; |
|
43
|
|
|
$this->msg = new Message(explode(PHP_EOL, $this->fullMsg)); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @covers GitElephant\Objects\Commit\Message::getShortMessage |
|
48
|
|
|
*/ |
|
49
|
|
|
public function testGetShortMessage() |
|
50
|
|
|
{ |
|
51
|
|
|
$this->assertEquals($this->shortMsg, $this->msg->getShortMessage()); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @covers GitElephant\Objects\Commit\Message::getFullMessage |
|
56
|
|
|
*/ |
|
57
|
|
|
public function testGetFullMessage() |
|
58
|
|
|
{ |
|
59
|
|
|
$this->assertEquals($this->fullMsg, $this->msg->getFullMessage()); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @covers GitElephant\Objects\Commit\Message::toString |
|
64
|
|
|
*/ |
|
65
|
|
|
public function testToString() |
|
66
|
|
|
{ |
|
67
|
|
|
$this->assertEquals($this->shortMsg, $this->msg->toString()); |
|
68
|
|
|
$this->assertEquals($this->shortMsg, $this->msg->__toString()); |
|
69
|
|
|
$this->assertEquals($this->shortMsg, (string) $this->msg); |
|
70
|
|
|
|
|
71
|
|
|
$this->assertEquals($this->fullMsg, $this->msg->toString(true)); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|