Completed
Push — master ( c24d4c...96117c )
by Sven
02:34
created

StringUtilsTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 51
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testSplitOnUpperCase() 0 9 1
A testSplitOnLowerCase() 0 9 1
A testStartsWith() 0 7 1
A testEndsWith() 0 7 1
1
<?php
2
namespace Bedd\Common;
3
4
/**
5
 * StringUtilsTest
6
 */
7
class StringUtilsTest extends \PHPUnit_Framework_TestCase
8
{
9
10
    /**
11
     * Test for Bedd\Common\StringUtils::splitOnUpperCase
12
     */
13
    public function testSplitOnUpperCase()
14
    {
15
        $this->assertEquals(['hallo welt'], StringUtils::splitOnUpperCase('hallo welt'));
16
        $this->assertEquals(['hallo ', 'Welt'], StringUtils::splitOnUpperCase('hallo Welt'));
17
        $this->assertEquals([], StringUtils::splitOnUpperCase(''));
18
        $this->setExpectedException('InvalidArgumentException');
19
        StringUtils::splitOnUpperCase(28);
20
        StringUtils::splitOnUpperCase(['test1', 'test2']);
21
    }
22
23
    /**
24
     * Test for Bedd\Common\StringUtils::splitOnLowerCase
25
     */
26
    public function testSplitOnLowerCase()
27
    {
28
        $this->assertEquals(['h', 'a', 'l', 'l', 'o ', 'w', 'e', 'l', 't'], StringUtils::splitOnLowerCase('hallo welt'));
29
        $this->assertEquals(['HALLO W', 'eLT'], StringUtils::splitOnLowerCase('HALLO WeLT'));
30
        $this->assertEquals([], StringUtils::splitOnLowerCase(''));
31
        $this->setExpectedException('InvalidArgumentException');
32
        StringUtils::splitOnLowerCase(28);
33
        StringUtils::splitOnLowerCase(['test1', 'test2']);
34
    }
35
36
    /**
37
     * Test for Bedd\Common\StringUtils::startsWith
38
     */
39
    public function testStartsWith()
40
    {
41
        $this->assertEquals(false, StringUtils::startsWith('Hallo Welt', 'hallo'));
42
        $this->assertEquals(true, StringUtils::startsWith('Hallo Welt', 'Hallo'));
43
        $this->assertEquals(false, StringUtils::startsWith('Hallo Welt', 'Test'));
44
        $this->assertEquals(true, StringUtils::startsWith('Hallo Welt', ''));
45
    }
46
47
    /**
48
     * Test for Bedd\Common\StringUtils::endsWith
49
     */
50
    public function testEndsWith()
51
    {
52
      $this->assertEquals(false, StringUtils::endsWith('Hallo Welt', 'welt'));
53
      $this->assertEquals(true, StringUtils::endsWith('Hallo Welt', 'Welt'));
54
      $this->assertEquals(false, StringUtils::endsWith('Hallo Welt', 'Test'));
55
      $this->assertEquals(true, StringUtils::endsWith('Hallo Welt', ''));
56
    }
57
}
58