StringUtilsTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 25
c 3
b 0
f 0
dl 0
loc 43
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testCamelize() 0 6 1
A testStartWith() 0 12 1
A testEndsWith() 0 12 1
A testUnderscore() 0 5 1
1
<?php
2
3
namespace LAG\Component\StringUtils;
4
5
use PHPUnit\Framework\TestCase;
6
7
class StringUtilsTest extends TestCase
8
{
9
    public function testStartWith(): void
10
    {
11
        $this->assertTrue(StringUtils::startsWith('Panda', 'P'));
12
        $this->assertTrue(StringUtils::startsWith('Panda', 'Pa'));
13
        $this->assertTrue(StringUtils::startsWith('Panda', 'Pan'));
14
        $this->assertTrue(StringUtils::startsWith('Panda', 'Pand'));
15
        $this->assertTrue(StringUtils::startsWith('Panda', 'Panda'));
16
17
        $this->assertFalse(StringUtils::startsWith('Panda', 'panda'));
18
        $this->assertFalse(StringUtils::startsWith('Panda', 'pan'));
19
        $this->assertFalse(StringUtils::startsWith('panda', 'P'));
20
        $this->assertFalse(StringUtils::startsWith('panda', 'coriandre'));
21
    }
22
23
    public function testEndsWith(): void
24
    {
25
        $this->assertTrue(StringUtils::endsWith('Panda', 'a'));
26
        $this->assertTrue(StringUtils::endsWith('Panda', 'da'));
27
        $this->assertTrue(StringUtils::endsWith('Panda', 'nda'));
28
        $this->assertTrue(StringUtils::endsWith('Panda', 'anda'));
29
        $this->assertTrue(StringUtils::endsWith('Panda', 'Panda'));
30
31
        $this->assertFalse(StringUtils::endsWith('Panda', 'panda'));
32
        $this->assertFalse(StringUtils::endsWith('Panda', 'pan'));
33
        $this->assertFalse(StringUtils::endsWith('panda', 'A'));
34
        $this->assertFalse(StringUtils::endsWith('panda', 'coriandre'));
35
    }
36
37
    public function testCamelize(): void
38
    {
39
        $this->assertEquals('MyLittlePanda', StringUtils::camelize('my little panda'));
40
        $this->assertEquals('MyLittlePanda', StringUtils::camelize('My Little Panda'));
41
42
        $this->assertEquals('toratoratora', StringUtils::camelize('tora tora tora', true));
43
    }
44
45
    public function testUnderscore(): void
46
    {
47
        $this->assertEquals('salsifi-potatoes', StringUtils::underscore('Salsifi-Potatoes'));
48
        $this->assertEquals('salsifi_potatoes', StringUtils::underscore('SalsifiPotatoes'));
49
        $this->assertEquals('cms.article.publication_status', StringUtils::underscore('cms.article.publicationStatus'));
50
    }
51
}
52