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
|
|
|
|