Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
9da81894
Commit
9da81894
authored
Mar 29, 2013
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved helper test from util namespace to helpers namespace, added tests for StringHelper
parent
00319fb8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
2 deletions
+76
-2
ArrayHelperTest.php
tests/unit/framework/helpers/ArrayHelperTest.php
+1
-1
HtmlTest.php
tests/unit/framework/helpers/HtmlTest.php
+1
-1
StringHelperTest.php
tests/unit/framework/helpers/StringHelperTest.php
+74
-0
No files found.
tests/unit/framework/
util
/ArrayHelperTest.php
→
tests/unit/framework/
helpers
/ArrayHelperTest.php
View file @
9da81894
<?php
namespace
yiiunit\framework\
util
;
namespace
yiiunit\framework\
helpers
;
use
yii\helpers\ArrayHelper
;
...
...
tests/unit/framework/
util
/HtmlTest.php
→
tests/unit/framework/
helpers
/HtmlTest.php
View file @
9da81894
<?php
namespace
yiiunit\framework\
util
;
namespace
yiiunit\framework\
helpers
;
use
Yii
;
use
yii\helpers\Html
;
...
...
tests/unit/framework/helpers/StringHelperTest.php
0 → 100644
View file @
9da81894
<?php
namespace
yiiunit\framework\helpers
;
use
\yii\helpers\StringHelper
as
StringHelper
;
/**
* StringHelperTest
*/
class
StringHelperTest
extends
\yii\test\TestCase
{
public
function
testStrlen
()
{
$this
->
assertEquals
(
4
,
StringHelper
::
strlen
(
'this'
));
$this
->
assertEquals
(
6
,
StringHelper
::
strlen
(
'это'
));
}
public
function
testSubstr
()
{
$this
->
assertEquals
(
'th'
,
StringHelper
::
substr
(
'this'
,
0
,
2
));
$this
->
assertEquals
(
'э'
,
StringHelper
::
substr
(
'это'
,
0
,
2
));
}
public
function
testPluralize
()
{
$testData
=
array
(
'move'
=>
'moves'
,
'foot'
=>
'feet'
,
'child'
=>
'children'
,
'human'
=>
'humans'
,
'man'
=>
'men'
,
'staff'
=>
'staff'
,
'tooth'
=>
'teeth'
,
'person'
=>
'people'
,
'mouse'
=>
'mice'
,
'touch'
=>
'touches'
,
'hash'
=>
'hashes'
,
'shelf'
=>
'shelves'
,
'potato'
=>
'potatoes'
,
'bus'
=>
'buses'
,
'test'
=>
'tests'
,
'car'
=>
'cars'
,
);
foreach
(
$testData
as
$testIn
=>
$testOut
)
{
$this
->
assertEquals
(
$testOut
,
StringHelper
::
pluralize
(
$testIn
));
$this
->
assertEquals
(
ucfirst
(
$testOut
),
ucfirst
(
StringHelper
::
pluralize
(
$testIn
)));
}
}
public
function
testCamel2words
()
{
$this
->
assertEquals
(
'Camel Case'
,
StringHelper
::
camel2words
(
'camelCase'
));
$this
->
assertEquals
(
'Lower Case'
,
StringHelper
::
camel2words
(
'lower_case'
));
$this
->
assertEquals
(
'Tricky Stuff It Is Testing'
,
StringHelper
::
camel2words
(
' tricky_stuff.it-is testing... '
));
}
public
function
testCamel2id
()
{
$this
->
assertEquals
(
'post-tag'
,
StringHelper
::
camel2id
(
'PostTag'
));
$this
->
assertEquals
(
'post_tag'
,
StringHelper
::
camel2id
(
'PostTag'
,
'_'
));
$this
->
assertEquals
(
'post-tag'
,
StringHelper
::
camel2id
(
'postTag'
));
$this
->
assertEquals
(
'post_tag'
,
StringHelper
::
camel2id
(
'postTag'
,
'_'
));
}
public
function
testId2camel
()
{
$this
->
assertEquals
(
'PostTag'
,
StringHelper
::
id2camel
(
'post-tag'
));
$this
->
assertEquals
(
'PostTag'
,
StringHelper
::
id2camel
(
'post_tag'
,
'_'
));
$this
->
assertEquals
(
'PostTag'
,
StringHelper
::
id2camel
(
'post-tag'
));
$this
->
assertEquals
(
'PostTag'
,
StringHelper
::
id2camel
(
'post_tag'
,
'_'
));
}
}
\ 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