NewlineTest   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
eloc 19
c 2
b 0
f 0
dl 0
loc 60
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A testCanCreateMultipleLineBoth() 0 5 1
A testCanCreateMultipleLineReturn() 0 5 1
A testCanCreateLineBoth() 0 5 1
A testCanCreateLineReturn() 0 5 1
A testCanCreateLineBreak() 0 5 1
A testCanCreateMultipleLineBreak() 0 5 1
1
<?php
2
declare(strict_types=1);
3
4
require '../vendor/autoload.php';
5
6
use PHPUnit\Framework\TestCase;
7
use Newball\SpaceTools\Newline;
8
9
final class NewlineTest extends TestCase
10
{
11
    /**
12
     * Test that a single newline can be created
13
     */
14
    public function testCanCreateLineBreak()
15
    {
16
        $newlineTest = new Newline();
17
        $nl = $newlineTest->nl;
18
        $this->assertEquals("\n", $nl);
19
    }
20
21
    /**
22
     * Test that a multiple newline can be created
23
     */
24
    public function testCanCreateMultipleLineBreak()
25
    {
26
        $newlineTest = new Newline(3);
27
        $nl = $newlineTest->nl;
28
        $this->assertEquals("\n\n\n", $nl);
29
    }
30
31
    /**
32
     * Test that a single return line can be created
33
     */
34
    public function testCanCreateLineReturn()
35
    {
36
        $newlineTest = new Newline(1, 'return');
37
        $nl = $newlineTest->nl;
38
        $this->assertEquals("\r", $nl);
39
    }
40
41
    /**
42
     * Test that multiple return line can be created
43
     */
44
    public function testCanCreateMultipleLineReturn()
45
    {
46
        $newlineTest = new Newline(5, 'return');
47
        $nl = $newlineTest->nl;
48
        $this->assertEquals("\r\r\r\r\r", $nl);
49
    }
50
51
    /**
52
     * Test that a return line with new line can be created
53
     */
54
    public function testCanCreateLineBoth()
55
    {
56
        $newlineTest = new Newline(1, 'both');
57
        $nl = $newlineTest->nl;
58
        $this->assertEquals("\r\n", $nl);
59
    }
60
61
    /**
62
     * Test that multiple return lines with new lines can be created
63
     */
64
    public function testCanCreateMultipleLineBoth()
65
    {
66
        $newlineTest = new Newline(9, 'both');
67
        $nl = $newlineTest->nl;
68
        $this->assertEquals("\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", $nl);
69
    }
70
71
72
73
}