StringUtilsTest   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 13
c 2
b 0
f 0
dl 0
loc 56
rs 10
wmc 11

11 Methods

Rating   Name   Duplication   Size   Complexity  
A testDoesStartWith() 0 3 1
A testIsNotEmpty() 0 3 1
A testIsEmptyWithWhiteSpaces() 0 3 1
A testDoesEndWith1() 0 3 1
A testDoesStartWith2() 0 3 1
A testDoesNotStartWith() 0 3 1
A testDoesNotEndWith1() 0 3 1
A testRemoveFromStartExceptionWhenInvalidStart() 0 4 1
A testDoesEndWith2() 0 3 1
A testRemoveFromStart() 0 3 1
A testIsEmpty() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DaveLiddament\StaticAnalysisResultsBaseliner\Tests\Unit\Core\Utils;
6
7
use DaveLiddament\StaticAnalysisResultsBaseliner\Domain\Utils\StringUtils;
8
use PHPUnit\Framework\TestCase;
9
10
final class StringUtilsTest extends TestCase
11
{
12
    public function testDoesStartWith(): void
13
    {
14
        $this->assertTrue(StringUtils::startsWith('Foo', 'FooBar'));
15
    }
16
17
    public function testDoesStartWith2(): void
18
    {
19
        $this->assertTrue(StringUtils::startsWith('Foo', 'FooBarFoo'));
20
    }
21
22
    public function testDoesNotStartWith(): void
23
    {
24
        $this->assertFalse(StringUtils::startsWith('oo', 'FooBar'));
25
    }
26
27
    public function testRemoveFromStart(): void
28
    {
29
        $this->assertEquals('Bar', StringUtils::removeFromStart('Foo', 'FooBar'));
30
    }
31
32
    public function testRemoveFromStartExceptionWhenInvalidStart(): void
33
    {
34
        $this->expectException(\InvalidArgumentException::class);
35
        StringUtils::removeFromStart('Bar', 'FooBar');
36
    }
37
38
    public function testDoesEndWith1(): void
39
    {
40
        $this->assertTrue(StringUtils::endsWith('e', 'abcde'));
41
    }
42
43
    public function testDoesEndWith2(): void
44
    {
45
        $this->assertTrue(StringUtils::endsWith('de', 'abcde'));
46
    }
47
48
    public function testDoesNotEndWith1(): void
49
    {
50
        $this->assertFalse(StringUtils::endsWith('d', 'abcde'));
51
    }
52
53
    public function testIsEmpty(): void
54
    {
55
        $this->assertTrue(StringUtils::isEmptyLine(''));
56
    }
57
58
    public function testIsEmptyWithWhiteSpaces(): void
59
    {
60
        $this->assertTrue(StringUtils::isEmptyLine('     '));
61
    }
62
63
    public function testIsNotEmpty(): void
64
    {
65
        $this->assertFalse(StringUtils::isEmptyLine('  a   '));
66
    }
67
}
68