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
4a93a6e0
Commit
4a93a6e0
authored
10 years ago
by
Vincent Petry
Browse files
Options
Downloads
Patches
Plain Diff
Added unit tests for cache of enabled apps
parent
9d5f18c0
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/lib/app.php
+74
-10
74 additions, 10 deletions
tests/lib/app.php
with
74 additions
and
10 deletions
tests/lib/app.php
+
74
−
10
View file @
4a93a6e0
...
...
@@ -337,15 +337,7 @@ class Test_App extends PHPUnit_Framework_TestCase {
\OC_User
::
setUserId
(
$user
);
$appConfig
=
$this
->
getMock
(
'\OC\AppConfig'
,
array
(
'getValues'
),
array
(
\OC_DB
::
getConnection
()),
''
,
false
);
$appConfig
->
expects
(
$this
->
once
())
$this
->
setupAppConfigMock
()
->
expects
(
$this
->
once
())
->
method
(
'getValues'
)
->
will
(
$this
->
returnValue
(
array
(
...
...
@@ -358,7 +350,6 @@ class Test_App extends PHPUnit_Framework_TestCase {
)
)
);
$this
->
registerAppConfig
(
$appConfig
);
$apps
=
\OC_App
::
getEnabledApps
(
true
,
$forceAll
);
$this
->
assertEquals
(
$expectedApps
,
$apps
);
...
...
@@ -377,6 +368,79 @@ class Test_App extends PHPUnit_Framework_TestCase {
$group2
->
delete
();
}
/**
* Test isEnabledApps() with cache, not re-reading the list of
* enabled apps more than once when a user is set.
*/
public
function
testEnabledAppsCache
()
{
$userManager
=
\OC
::
$server
->
getUserManager
();
$user1
=
$userManager
->
createUser
(
self
::
TEST_USER1
,
self
::
TEST_USER1
);
\OC_User
::
setUserId
(
self
::
TEST_USER1
);
$this
->
setupAppConfigMock
()
->
expects
(
$this
->
once
())
->
method
(
'getValues'
)
->
will
(
$this
->
returnValue
(
array
(
'app3'
=>
'yes'
,
'app2'
=>
'no'
,
)
)
);
$apps
=
\OC_App
::
getEnabledApps
(
true
);
$this
->
assertEquals
(
array
(
'files'
,
'app3'
),
$apps
);
// mock should not be called again here
$apps
=
\OC_App
::
getEnabledApps
(
false
);
$this
->
assertEquals
(
array
(
'files'
,
'app3'
),
$apps
);
$this
->
restoreAppConfig
();
\OC_User
::
setUserId
(
null
);
$user1
->
delete
();
// clear user cache...
$userManager
->
delete
(
self
::
TEST_USER1
);
}
/**
* Tests that the apps list is re-requested (not cached) when
* no user is set.
*/
public
function
testEnabledAppsNoCache
()
{
$this
->
setupAppConfigMock
()
->
expects
(
$this
->
exactly
(
2
))
->
method
(
'getValues'
)
->
will
(
$this
->
returnValue
(
array
(
'app3'
=>
'yes'
,
'app2'
=>
'no'
,
)
)
);
$apps
=
\OC_App
::
getEnabledApps
(
true
);
$this
->
assertEquals
(
array
(
'files'
,
'app3'
),
$apps
);
// mock should be called again here
$apps
=
\OC_App
::
getEnabledApps
(
false
);
$this
->
assertEquals
(
array
(
'files'
,
'app3'
),
$apps
);
$this
->
restoreAppConfig
();
}
private
function
setupAppConfigMock
()
{
$appConfig
=
$this
->
getMock
(
'\OC\AppConfig'
,
array
(
'getValues'
),
array
(
\OC_DB
::
getConnection
()),
''
,
false
);
$this
->
registerAppConfig
(
$appConfig
);
return
$appConfig
;
}
/**
* Register an app config mock for testing purposes.
* @param $appConfig app config mock
...
...
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