|
1
|
|
|
<?php |
|
2
|
|
|
use Ubiquity\utils\base\UString; |
|
3
|
|
|
class UStringTest extends \Codeception\Test\Unit { |
|
4
|
|
|
/** |
|
5
|
|
|
* |
|
6
|
|
|
* @var \UnitTester |
|
7
|
|
|
*/ |
|
8
|
|
|
protected $tester; |
|
9
|
|
|
|
|
10
|
|
|
protected function _before() { |
|
11
|
|
|
} |
|
12
|
|
|
|
|
13
|
|
|
protected function _after() { |
|
14
|
|
|
} |
|
15
|
|
|
|
|
16
|
|
|
// tests |
|
17
|
|
|
public function testCleanAttribute() { |
|
18
|
|
|
$this->assertEquals ( "attr-ta-", UString::cleanAttribute ( "attr ta%%" ) ); |
|
19
|
|
|
$this->assertEquals ( "attr", UString::cleanAttribute ( "attr" ) ); |
|
20
|
|
|
$this->assertEquals ( "attr01", UString::cleanAttribute ( "attr01" ) ); |
|
21
|
|
|
$this->assertEquals ( "01attr01", UString::cleanAttribute ( "01attr01" ) ); |
|
22
|
|
|
$this->assertEquals ( "01attr", UString::cleanAttribute ( "01attr" ) ); |
|
23
|
|
|
$this->assertEquals ( "attri-bute", UString::cleanAttribute ( "attri-bute" ) ); |
|
24
|
|
|
$this->assertEquals ( "attri-bute", UString::cleanAttribute ( "attri--bute" ) ); |
|
25
|
|
|
// $this->assertEquals ( "attri-bute", UString::cleanAttribute ( "attri---bute" ) ); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function testStartsWith() { |
|
29
|
|
|
$this->assertTrue ( UString::startswith ( '-test', '-' ) ); |
|
30
|
|
|
$this->assertFalse ( UString::startswith ( 'test', '-' ) ); |
|
31
|
|
|
$this->assertFalse ( UString::startswith ( '', '-' ) ); |
|
32
|
|
|
$this->assertFalse ( UString::startswith ( null, '-' ) ); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function testEndsWith() { |
|
36
|
|
|
$this->assertTrue ( UString::endswith ( '-test', 't' ) ); |
|
37
|
|
|
$this->assertFalse ( UString::endswith ( 'test', '-' ) ); |
|
38
|
|
|
$this->assertFalse ( UString::endswith ( '', '-' ) ); |
|
39
|
|
|
$this->assertFalse ( UString::endswith ( null, '-' ) ); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function testGetBooleanStr() { |
|
43
|
|
|
$this->assertEquals ( 'true', UString::getBooleanStr ( true ) ); |
|
44
|
|
|
$this->assertEquals ( 'true', UString::getBooleanStr ( 1 ) ); |
|
45
|
|
|
$this->assertEquals ( 'true', UString::getBooleanStr ( 'a' ) ); |
|
46
|
|
|
$this->assertEquals ( 'false', UString::getBooleanStr ( false ) ); |
|
47
|
|
|
$this->assertEquals ( 'false', UString::getBooleanStr ( null ) ); |
|
48
|
|
|
$this->assertEquals ( 'false', UString::getBooleanStr ( 0 ) ); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function testIsNull() { |
|
52
|
|
|
$this->assertTrue ( UString::isNull ( null ) ); |
|
53
|
|
|
$this->assertTrue ( UString::isNull ( '' ) ); |
|
54
|
|
|
$this->assertTrue ( UString::isNull ( "" ) ); |
|
55
|
|
|
$this->assertFalse ( UString::isNull ( false ) ); |
|
56
|
|
|
$this->assertFalse ( UString::isNull ( 55 ) ); |
|
57
|
|
|
$this->assertFalse ( UString::isNull ( 'texte' ) ); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function testIsNotNull() { |
|
61
|
|
|
$this->assertFalse ( UString::isNotNull ( null ) ); |
|
62
|
|
|
$this->assertFalse ( UString::isNotNull ( '' ) ); |
|
63
|
|
|
$this->assertFalse ( UString::isNotNull ( "" ) ); |
|
64
|
|
|
$this->assertTrue ( UString::isNotNull ( false ) ); |
|
65
|
|
|
$this->assertTrue ( UString::isNotNull ( 55 ) ); |
|
66
|
|
|
$this->assertTrue ( UString::isNotNull ( 'texte' ) ); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function testIsBooleanTrue() { |
|
70
|
|
|
$this->assertTrue ( UString::isBooleanTrue ( 'true' ) ); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
public function testIsBooleanFalse() { |
|
74
|
|
|
$this->assertTrue ( UString::isBooleanFalse ( 'false' ) ); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
public function testIsBoolean() { |
|
78
|
|
|
$this->assertTrue ( UString::isBoolean ( true ) ); |
|
79
|
|
|
$this->assertTrue ( UString::isBoolean ( false ) ); |
|
80
|
|
|
$this->assertFalse ( UString::isBoolean ( 0 ) ); |
|
81
|
|
|
$this->assertFalse ( UString::isBoolean ( 1 ) ); |
|
82
|
|
|
$this->assertFalse ( UString::isBoolean ( 'false' ) ); |
|
83
|
|
|
$this->assertFalse ( UString::isBoolean ( 'true' ) ); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
public function testIsBooleanStr() { |
|
87
|
|
|
$this->assertFalse ( UString::isBooleanStr ( 'blop' ) ); |
|
88
|
|
|
$this->assertFalse ( UString::isBooleanStr ( 'y' ) ); |
|
89
|
|
|
$this->assertTrue ( UString::isBooleanStr ( 'true' ) ); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
public function testPluralize() { |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
public function testFirstReplace() { |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
public function testReplaceFirstOccurrence() { |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
public function testReplaceArray() { |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
public function testDoubleBackSlashes() { |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
public function testMask() { |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
public function testIsValid() { |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
public function testToString() { |
|
114
|
|
|
} |
|
115
|
|
|
} |