Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
6bdc34dc
Commit
6bdc34dc
authored
Jan 17, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finished testing the string class.
parent
3e8fbce0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
115 additions
and
0 deletions
+115
-0
str.test.php
tests/cases/laravel/str.test.php
+115
-0
No files found.
tests/cases/laravel/str.test.php
View file @
6bdc34dc
...
...
@@ -15,4 +15,119 @@ class StrTest extends PHPUnit_Framework_TestCase {
Config
::
set
(
'application.encoding'
,
'UTF-8'
);
}
/**
* Test the Str::length method.
*
* @group laravel
*/
public
function
testStringLengthIsCorrect
()
{
$this
->
assertEquals
(
6
,
Str
::
length
(
'Taylor'
));
$this
->
assertEquals
(
5
,
Str
::
length
(
'ラドクリフ'
));
}
/**
* Test the Str::lower method.
*
* @group laravel
*/
public
function
testStringCanBeConvertedToLowercase
()
{
$this
->
assertEquals
(
'taylor'
,
Str
::
lower
(
'TAYLOR'
));
$this
->
assertEquals
(
'άχιστη'
,
Str
::
lower
(
'ΆΧΙΣΤΗ'
));
}
/**
* Test the Str::upper method.
*
* @group laravel
*/
public
function
testStringCanBeConvertedToUppercase
()
{
$this
->
assertEquals
(
'TAYLOR'
,
Str
::
upper
(
'taylor'
));
$this
->
assertEquals
(
'ΆΧΙΣΤΗ'
,
Str
::
upper
(
'άχιστη'
));
}
/**
* Test the Str::title method.
*
* @group laravel
*/
public
function
testStringCanBeConvertedToTitleCase
()
{
$this
->
assertEquals
(
'Taylor'
,
Str
::
title
(
'taylor'
));
$this
->
assertEquals
(
'Άχιστη'
,
Str
::
title
(
'άχιστη'
));
}
/**
* Test the Str::limit method.
*
* @group laravel
*/
public
function
testStringCanBeLimitedByCharacters
()
{
$this
->
assertEquals
(
'Tay...'
,
Str
::
limit
(
'Taylor'
,
3
));
$this
->
assertEquals
(
'Taylor'
,
Str
::
limit
(
'Taylor'
,
6
));
$this
->
assertEquals
(
'Tay___'
,
Str
::
limit
(
'Taylor'
,
3
,
'___'
));
}
/**
* 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
));
}
/**
* Test the Str::plural and Str::singular methods.
*
* @group laravel
*/
public
function
testStringsCanBeSingularOrPlural
()
{
$this
->
assertEquals
(
'user'
,
Str
::
singular
(
'users'
));
$this
->
assertEquals
(
'user'
,
Str
::
singular
(
'USERS'
));
$this
->
assertEquals
(
'users'
,
Str
::
plural
(
'user'
));
$this
->
assertEquals
(
'users'
,
Str
::
plural
(
'USER'
));
$this
->
assertEquals
(
'user'
,
Str
::
plural
(
'user'
,
1
));
$this
->
assertEquals
(
'users'
,
Str
::
plural
(
'user'
,
2
));
}
/**
* Test the Str::slug method.
*
* @group laravel
*/
public
function
testStringsCanBeSlugged
()
{
$this
->
assertEquals
(
'my-new-post'
,
Str
::
slug
(
'My nEw post!!!'
));
$this
->
assertEquals
(
'my_new_post'
,
Str
::
slug
(
'My nEw post!!!'
,
'_'
));
}
/**
* Test the Str::classify method.
*
* @group laravel
*/
public
function
testStringsCanBeClassified
()
{
$this
->
assertEquals
(
'Something_Else'
,
Str
::
classify
(
'something.else'
));
$this
->
assertEquals
(
'Something_Else'
,
Str
::
classify
(
'something_else'
));
}
/**
* Test the Str::random method.
*
* @group laravel
*/
public
function
testRandomStringsCanBeGenerated
()
{
$this
->
assertEquals
(
40
,
strlen
(
Str
::
random
(
40
)));
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment