MessageTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
cc 1
nc 1
nop 0
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(): void
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(): void
50
    {
51
        $this->assertEquals($this->shortMsg, $this->msg->getShortMessage());
52
    }
53
54
    /**
55
     * @covers GitElephant\Objects\Commit\Message::getFullMessage
56
     */
57
    public function testGetFullMessage(): void
58
    {
59
        $this->assertEquals($this->fullMsg, $this->msg->getFullMessage());
60
    }
61
62
    /**
63
     * @covers GitElephant\Objects\Commit\Message::toString
64
     */
65
    public function testToString(): void
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