Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
085fdfec
Commit
085fdfec
authored
11 years ago
by
Thomas Müller
Browse files
Options
Downloads
Patches
Plain Diff
adding unit tests for OC_Util::basename
parent
e2d3225e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/util.php
+1
-0
1 addition, 0 deletions
lib/util.php
tests/lib/util.php
+24
-8
24 additions, 8 deletions
tests/lib/util.php
with
25 additions
and
8 deletions
lib/util.php
+
1
−
0
View file @
085fdfec
...
...
@@ -895,6 +895,7 @@ class OC_Util {
public
static
function
basename
(
$file
)
{
$file
=
rtrim
(
$file
,
'/'
);
$t
=
explode
(
'/'
,
$file
);
return
array_pop
(
$t
);
}
...
...
This diff is collapsed.
Click to expand it.
tests/lib/util.php
+
24
−
8
View file @
085fdfec
...
...
@@ -8,12 +8,9 @@
class
Test_Util
extends
PHPUnit_Framework_TestCase
{
// Constructor
function
Test_Util
()
{
function
testFormatDate
()
{
date_default_timezone_set
(
"UTC"
);
}
function
testFormatDate
()
{
$result
=
OC_Util
::
formatDate
(
1350129205
);
$expected
=
'October 13, 2012 11:53'
;
$this
->
assertEquals
(
$expected
,
$result
);
...
...
@@ -61,8 +58,27 @@ class Test_Util extends PHPUnit_Framework_TestCase {
OC_Config
::
deleteKey
(
'mail_domain'
);
}
function
testGetInstanceIdGeneratesValidId
()
{
OC_Config
::
deleteKey
(
'instanceid'
);
$this
->
assertStringStartsWith
(
'oc'
,
OC_Util
::
getInstanceId
());
}
function
testGetInstanceIdGeneratesValidId
()
{
OC_Config
::
deleteKey
(
'instanceid'
);
$this
->
assertStringStartsWith
(
'oc'
,
OC_Util
::
getInstanceId
());
}
/**
* @dataProvider baseNameProvider
*/
public
function
testBaseName
(
$expected
,
$file
)
{
$base
=
\OC_Util
::
basename
(
$file
);
$this
->
assertEquals
(
$expected
,
$base
);
}
public
function
baseNameProvider
()
{
return
array
(
array
(
'public_html'
,
'/home/user/public_html/'
),
array
(
'public_html'
,
'/home/user/public_html'
),
array
(
''
,
'/'
),
array
(
'442aa682de2a64db1e010f50e60fd9c9'
,
'local::C:\Users\ADMINI~1\AppData\Local\Temp\2/442aa682de2a64db1e010f50e60fd9c9/'
)
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment