Completed
Push — master ( 41ae82...437c90 )
by Dave
13s queued 11s
created

StringUtilsTest::testDoesStartWith()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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 InvalidArgumentException;
9
use PHPUnit\Framework\TestCase;
10
11
class StringUtilsTest extends TestCase
12
{
13
    public function testDoesStartWith(): void
14
    {
15
        $this->assertTrue(StringUtils::startsWith('Foo', 'FooBar'));
16
    }
17
18
    public function testDoesStartWith2(): void
19
    {
20
        $this->assertTrue(StringUtils::startsWith('Foo', 'FooBarFoo'));
21
    }
22
23
    public function testDoesNotStartWith(): void
24
    {
25
        $this->assertFalse(StringUtils::startsWith('oo', 'FooBar'));
26
    }
27
28
    public function testRemoveFromStart(): void
29
    {
30
        $this->assertEquals('Bar', StringUtils::removeFromStart('Foo', 'FooBar'));
31
    }
32
33
    public function testRemoveFromStartExceptionWhenInvalidStart(): void
34
    {
35
        $this->expectException(InvalidArgumentException::class);
36
        StringUtils::removeFromStart('Bar', 'FooBar');
37
    }
38
39
    public function testDoesEndWith1(): void
40
    {
41
        $this->assertTrue(StringUtils::endsWith('e', 'abcde'));
42
    }
43
44
    public function testDoesEndWith2(): void
45
    {
46
        $this->assertTrue(StringUtils::endsWith('de', 'abcde'));
47
    }
48
49
    public function testDoesNotEndWith1(): void
50
    {
51
        $this->assertFalse(StringUtils::endsWith('d', 'abcde'));
52
    }
53
54
    public function testIsEmpty(): void
55
    {
56
        $this->assertTrue(StringUtils::isEmptyLine(''));
57
    }
58
59
    public function testIsEmptyWithWhiteSpaces(): void
60
    {
61
        $this->assertTrue(StringUtils::isEmptyLine('     '));
62
    }
63
64
    public function testIsNotEmpty(): void
65
    {
66
        $this->assertFalse(StringUtils::isEmptyLine('  a   '));
67
    }
68
}
69