Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
apc
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
apc
Commits
56a6ca87
Commit
56a6ca87
authored
6 months ago
by
Alberto Paderno
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3465135
: Add a getCacheBins() method
parent
9399cd9e
No related branches found
No related tags found
1 merge request
!50
Issue #3465135: Add a getCacheBins() method
Pipeline
#240305
passed
6 months ago
Stage: build
Stage: validate
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apc.test
+39
-10
39 additions, 10 deletions
apc.test
with
39 additions
and
10 deletions
apc.test
+
39
−
10
View file @
56a6ca87
...
...
@@ -24,6 +24,26 @@ class ApcCacheTestCase extends DrupalWebTestCase {
*/
protected
$modules
=
array
(
'apc'
);
/**
* Retrieves the cache bins to enable.
*
* @param bool $ignore_first
* (optional) Whether to ignore the first cache bin, which is always
* 'apc_cache'. Defaults to FALSE.
*
* @return array
* The cache bins to enable.
*/
protected
function
getCacheBins
(
$ignore_first
=
FALSE
)
{
$cache_bins
=
$this
->
cacheBins
;
if
(
$ignore_first
)
{
array_shift
(
$cache_bins
);
}
return
$cache_bins
;
}
/**
* Adds cache bins to the list of cache bins that are stored on APCu.
*
...
...
@@ -205,7 +225,8 @@ class ApcCacheSaveAndRetrieveCase extends ApcCacheTestCase {
* The cache IDs of the stored data.
*/
private
function
storeTestData
(
&
$values
,
&
$cids
)
{
$bin
=
'cache_apc'
;
$cache_bins
=
$this
->
getCacheBins
();
$bin
=
$cache_bins
[
0
];
$cids
=
array
();
$values
=
array
(
$this
->
randomName
()
=>
TRUE
,
...
...
@@ -243,7 +264,8 @@ class ApcCacheSaveAndRetrieveCase extends ApcCacheTestCase {
* Tests retrieving data.
*/
protected
function
testRetrieveData
()
{
$bin
=
'cache_apc'
;
$cache_bins
=
$this
->
getCacheBins
();
$bin
=
$cache_bins
[
0
];
$this
->
storeTestData
(
$values
,
$cids
);
...
...
@@ -256,7 +278,8 @@ class ApcCacheSaveAndRetrieveCase extends ApcCacheTestCase {
* Tests cache_get_multiple().
*/
public
function
testRetrieveMultipleValues
()
{
$bin
=
'cache_apc'
;
$cache_bins
=
$this
->
getCacheBins
();
$bin
=
$cache_bins
[
0
];
$this
->
storeTestData
(
$values
,
$cids
);
$this
->
assertCacheItems
(
$bin
,
$cids
,
$values
);
...
...
@@ -287,7 +310,9 @@ class ApcCacheClearCase extends ApcCacheTestCase {
* Tests clearing the cache using a single cache ID without using wildcards.
*/
public
function
testClearWithCid
()
{
$bin
=
'cache_apc'
;
$cache_bins
=
$this
->
getCacheBins
();
$bin
=
$cache_bins
[
0
];
$value
=
$this
->
randomString
();
cache_set
(
'test_cid_clear'
,
$value
,
$bin
);
$this
->
assertCacheItem
(
$bin
,
'test_cid_clear'
,
$value
);
...
...
@@ -316,7 +341,8 @@ class ApcCacheClearCase extends ApcCacheTestCase {
* Tests clearing the cache using wildcards.
*/
public
function
testClearWithWildcard
()
{
$bin
=
'cache_apc'
;
$cache_bins
=
$this
->
getCacheBins
();
$bin
=
$cache_bins
[
0
];
$item3
=
$this
->
randomName
(
16
);
$value1
=
$this
->
randomString
();
...
...
@@ -355,7 +381,8 @@ class ApcCacheClearCase extends ApcCacheTestCase {
* Tests clearing the cache passing more cache IDs.
*/
public
function
testClearWithCids
()
{
$bin
=
'cache_apc'
;
$cache_bins
=
$this
->
getCacheBins
();
$bin
=
$cache_bins
[
0
];
$item3
=
$this
->
randomName
(
16
);
$value1
=
$this
->
randomString
();
...
...
@@ -408,7 +435,8 @@ class ApcCacheIsEmptyCase extends ApcCacheTestCase {
* Tests clearing the cache using a cache ID.
*/
public
function
testIsEmpty
()
{
$bin
=
'cache_apc'
;
$cache_bins
=
$this
->
getCacheBins
();
$bin
=
$cache_bins
[
0
];
cache_set
(
'test_temporary'
,
$this
->
randomString
(),
$bin
);
cache_clear_all
(
'*'
,
$bin
,
TRUE
);
...
...
@@ -512,6 +540,7 @@ class ApcCacheExternalValuesCase extends ApcCacheTestCase {
* Writes some cache items and verifies other values are not overridden.
*/
public
function
testWriteCache
()
{
$cache_bins
=
$this
->
getCacheBins
();
$cids
=
array
(
'test_temporary'
,
'test_'
.
$this
->
randomName
(),
...
...
@@ -520,13 +549,13 @@ class ApcCacheExternalValuesCase extends ApcCacheTestCase {
'apc_cache::'
,
);
foreach
(
$
this
->
cache
B
ins
as
$bin
)
{
foreach
(
$cache
_b
ins
as
$bin
)
{
foreach
(
$cids
as
$cid
)
{
cache_set
(
$cid
,
$this
->
randomString
(),
$bin
);
}
}
foreach
(
$
this
->
cache
B
ins
as
$bin
)
{
foreach
(
$cache
_b
ins
as
$bin
)
{
foreach
(
$cids
as
$cid
)
{
$this
->
assertCacheItem
(
$bin
,
$cid
);
}
...
...
@@ -539,7 +568,7 @@ class ApcCacheExternalValuesCase extends ApcCacheTestCase {
* Tests clearing the cache for all cache bins.
*/
public
function
testClearingCache
()
{
foreach
(
$this
->
c
acheBins
as
$bin
)
{
foreach
(
$this
->
getC
acheBins
()
as
$bin
)
{
cache_clear_all
(
'*'
,
$bin
,
TRUE
);
}
...
...
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