StringUtilsTest::testStartWith()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 12
rs 9.9666
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