Completed
Push — develop ( 5f7df1...9cb564 )
by Matteo
10s
created

MessageTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 53
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetShortMessage() 0 4 1
A testGetFullMessage() 0 4 1
A setUp() 0 13 1
A testToString() 0 8 1
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