FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
framework/tests/Support/SupportStrTest.php at master · JavaDevl/framework · GitHub
JavaDevl
/
framework
Public
forked from
laravel/framework
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
framework
/
tests
/
Support
/
SupportStrTest.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
184 lines (161 loc) · 7.19 KB
Breadcrumbs
framework
/
tests
/
Support
/
SupportStrTest.php
Copy path
File metadata and controls
executable file
·
184 lines (161 loc) · 7.19 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?php
use
Illuminate
\
Support
\
Str
;
class
SupportStrTest
extends
PHPUnit_Framework_TestCase
{
/**
* Test the Str::words method.
*
* @group laravel
*/
public
function
testStringCanBeLimitedByWords
()
{
$
this
->
assertEquals
(
'
Taylor...
'
, Str::
words
(
'
Taylor Otwell
'
,
1
));
$
this
->
assertEquals
(
'
Taylor___
'
, Str::
words
(
'
Taylor Otwell
'
,
1
,
'
___
'
));
$
this
->
assertEquals
(
'
Taylor Otwell
'
, Str::
words
(
'
Taylor Otwell
'
,
3
));
}
public
function
testStringTrimmedOnlyWhereNecessary
()
{
$
this
->
assertEquals
(
'
Taylor Otwell
'
, Str::
words
(
'
Taylor Otwell
'
,
3
));
$
this
->
assertEquals
(
'
Taylor...
'
, Str::
words
(
'
Taylor Otwell
'
,
1
));
}
public
function
testStringTitle
()
{
$
this
->
assertEquals
(
'
Jefferson Costella
'
, Str::
title
(
'
jefferson costella
'
));
$
this
->
assertEquals
(
'
Jefferson Costella
'
, Str::
title
(
'
jefFErson coSTella
'
));
}
public
function
testStringWithoutWordsDoesntProduceError
()
{
$
nbsp
=
chr
(
0xC2
).
chr
(
0xA0
);
$
this
->
assertEquals
(
'
'
, Str::
words
(
'
'
));
$
this
->
assertEquals
(
$
nbsp
, Str::
words
(
$
nbsp
));
}
public
function
testStartsWith
()
{
$
this
->
assertTrue
(Str::
startsWith
(
'
jason
'
,
'
jas
'
));
$
this
->
assertTrue
(Str::
startsWith
(
'
jason
'
,
'
jason
'
));
$
this
->
assertTrue
(Str::
startsWith
(
'
jason
'
, [
'
jas
'
]));
$
this
->
assertFalse
(Str::
startsWith
(
'
jason
'
,
'
day
'
));
$
this
->
assertFalse
(Str::
startsWith
(
'
jason
'
, [
'
day
'
]));
$
this
->
assertFalse
(Str::
startsWith
(
'
jason
'
,
''
));
}
public
function
testEndsWith
()
{
$
this
->
assertTrue
(Str::
endsWith
(
'
jason
'
,
'
on
'
));
$
this
->
assertTrue
(Str::
endsWith
(
'
jason
'
,
'
jason
'
));
$
this
->
assertTrue
(Str::
endsWith
(
'
jason
'
, [
'
on
'
]));
$
this
->
assertFalse
(Str::
endsWith
(
'
jason
'
,
'
no
'
));
$
this
->
assertFalse
(Str::
endsWith
(
'
jason
'
, [
'
no
'
]));
$
this
->
assertFalse
(Str::
endsWith
(
'
jason
'
,
''
));
$
this
->
assertFalse
(Str::
endsWith
(
'
7
'
,
'
7
'
));
}
public
function
testStrContains
()
{
$
this
->
assertTrue
(Str::
contains
(
'
taylor
'
,
'
ylo
'
));
$
this
->
assertTrue
(Str::
contains
(
'
taylor
'
, [
'
ylo
'
]));
$
this
->
assertFalse
(Str::
contains
(
'
taylor
'
,
'
xxx
'
));
$
this
->
assertFalse
(Str::
contains
(
'
taylor
'
, [
'
xxx
'
]));
$
this
->
assertFalse
(Str::
contains
(
'
taylor
'
,
''
));
}
public
function
testParseCallback
()
{
$
this
->
assertEquals
([
'
Class
'
,
'
method
'
], Str::
parseCallback
(
'
Class@method
'
,
'
foo
'
));
$
this
->
assertEquals
([
'
Class
'
,
'
foo
'
], Str::
parseCallback
(
'
Class
'
,
'
foo
'
));
}
public
function
testSlug
()
{
$
this
->
assertEquals
(
'
hello-world
'
, Str::
slug
(
'
hello world
'
));
$
this
->
assertEquals
(
'
hello-world
'
, Str::
slug
(
'
hello-world
'
));
$
this
->
assertEquals
(
'
hello-world
'
, Str::
slug
(
'
hello_world
'
));
$
this
->
assertEquals
(
'
hello_world
'
, Str::
slug
(
'
hello_world
'
,
'
_
'
));
}
public
function
testFinish
()
{
$
this
->
assertEquals
(
'
abbc
'
, Str::
finish
(
'
ab
'
,
'
bc
'
));
$
this
->
assertEquals
(
'
abbc
'
, Str::
finish
(
'
abbcbc
'
,
'
bc
'
));
$
this
->
assertEquals
(
'
abcbbc
'
, Str::
finish
(
'
abcbbcbc
'
,
'
bc
'
));
}
public
function
testIs
()
{
$
this
->
assertTrue
(Str::
is
(
'
/
'
,
'
/
'
));
$
this
->
assertFalse
(Str::
is
(
'
/
'
,
'
/
'
));
$
this
->
assertFalse
(Str::
is
(
'
/
'
,
'
/a
'
));
$
this
->
assertTrue
(Str::
is
(
'
foo/*
'
,
'
foo/bar/baz
'
));
$
this
->
assertTrue
(Str::
is
(
'
*/foo
'
,
'
blah/baz/foo
'
));
}
public
function
testLower
()
{
$
this
->
assertEquals
(
'
foo bar baz
'
, Str::
lower
(
'
FOO BAR BAZ
'
));
$
this
->
assertEquals
(
'
foo bar baz
'
, Str::
lower
(
'
fOo Bar bAz
'
));
}
public
function
testUpper
()
{
$
this
->
assertEquals
(
'
FOO BAR BAZ
'
, Str::
upper
(
'
foo bar baz
'
));
$
this
->
assertEquals
(
'
FOO BAR BAZ
'
, Str::
upper
(
'
foO bAr BaZ
'
));
}
public
function
testLimit
()
{
$
this
->
assertEquals
(
'
Laravel is...
'
, Str::
limit
(
'
Laravel is a free, open source PHP web application framework.
'
,
10
));
$
this
->
assertEquals
(
'
这是一...
'
, Str::
limit
(
'
这是一段中文
'
,
6
));
}
public
function
testLength
()
{
$
this
->
assertEquals
(
11
, Str::
length
(
'
foo bar baz
'
));
}
public
function
testQuickRandom
()
{
$
randomInteger
=
random_int
(
1
,
100
);
$
this
->
assertEquals
(
$
randomInteger
,
strlen
(Str::
quickRandom
(
$
randomInteger
)));
$
this
->
assertInternalType
(
'
string
'
, Str::
quickRandom
());
$
this
->
assertEquals
(
16
,
strlen
(Str::
quickRandom
()));
}
public
function
testRandom
()
{
$
this
->
assertEquals
(
16
,
strlen
(Str::
random
()));
$
randomInteger
=
random_int
(
1
,
100
);
$
this
->
assertEquals
(
$
randomInteger
,
strlen
(Str::
random
(
$
randomInteger
)));
$
this
->
assertInternalType
(
'
string
'
, Str::
random
());
}
public
function
testSnake
()
{
$
this
->
assertEquals
(
'
laravel_p_h_p_framework
'
, Str::
snake
(
'
LaravelPHPFramework
'
));
$
this
->
assertEquals
(
'
laravel_php_framework
'
, Str::
snake
(
'
LaravelPhpFramework
'
));
$
this
->
assertEquals
(
'
laravel php framework
'
, Str::
snake
(
'
LaravelPhpFramework
'
,
'
'
));
$
this
->
assertEquals
(
'
laravel_php_framework
'
, Str::
snake
(
'
Laravel Php Framework
'
));
$
this
->
assertEquals
(
'
laravel_php_framework
'
, Str::
snake
(
'
Laravel Php Framework
'
));
}
public
function
testStudly
()
{
$
this
->
assertEquals
(
'
LaravelPHPFramework
'
, Str::
studly
(
'
laravel_p_h_p_framework
'
));
$
this
->
assertEquals
(
'
LaravelPhpFramework
'
, Str::
studly
(
'
laravel_php_framework
'
));
$
this
->
assertEquals
(
'
LaravelPhPFramework
'
, Str::
studly
(
'
laravel-phP-framework
'
));
$
this
->
assertEquals
(
'
LaravelPhpFramework
'
, Str::
studly
(
'
laravel -_- php -_- framework
'
));
}
public
function
testCamel
()
{
$
this
->
assertEquals
(
'
laravelPHPFramework
'
, Str::
camel
(
'
Laravel_p_h_p_framework
'
));
$
this
->
assertEquals
(
'
laravelPhpFramework
'
, Str::
camel
(
'
Laravel_php_framework
'
));
$
this
->
assertEquals
(
'
laravelPhPFramework
'
, Str::
camel
(
'
Laravel-phP-framework
'
));
$
this
->
assertEquals
(
'
laravelPhpFramework
'
, Str::
camel
(
'
Laravel -_- php -_- framework
'
));
}
public
function
testSubstr
()
{
$
this
->
assertEquals
(
'
Ё
'
, Str::
substr
(
'
БГДЖИЛЁ
'
, -
1
));
$
this
->
assertEquals
(
'
ЛЁ
'
, Str::
substr
(
'
БГДЖИЛЁ
'
, -
2
));
$
this
->
assertEquals
(
'
И
'
, Str::
substr
(
'
БГДЖИЛЁ
'
, -
3
,
1
));
$
this
->
assertEquals
(
'
ДЖИЛ
'
, Str::
substr
(
'
БГДЖИЛЁ
'
,
2
, -
1
));
$
this
->
assertEmpty
(Str::
substr
(
'
БГДЖИЛЁ
'
,
4
, -
4
));
$
this
->
assertEquals
(
'
ИЛ
'
, Str::
substr
(
'
БГДЖИЛЁ
'
, -
3
, -
1
));
$
this
->
assertEquals
(
'
ГДЖИЛЁ
'
, Str::
substr
(
'
БГДЖИЛЁ
'
,
1
));
$
this
->
assertEquals
(
'
ГДЖ
'
, Str::
substr
(
'
БГДЖИЛЁ
'
,
1
,
3
));
$
this
->
assertEquals
(
'
БГДЖ
'
, Str::
substr
(
'
БГДЖИЛЁ
'
,
0
,
4
));
$
this
->
assertEquals
(
'
Ё
'
, Str::
substr
(
'
БГДЖИЛЁ
'
, -
1
,
1
));
$
this
->
assertEmpty
(Str::
substr
(
'
Б
'
,
2
));
}
public
function
testUcfirst
()
{
$
this
->
assertEquals
(
'
Laravel
'
, Str::
ucfirst
(
'
laravel
'
));
$
this
->
assertEquals
(
'
Laravel framework
'
, Str::
ucfirst
(
'
laravel framework
'
));
$
this
->
assertEquals
(
'
Мама
'
, Str::
ucfirst
(
'
мама
'
));
$
this
->
assertEquals
(
'
Мама мыла раму
'
, Str::
ucfirst
(
'
мама мыла раму
'
));
}
}
Back
|
FazBrowse Home
|
New Git URL