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
8939307f
Commit
8939307f
authored
6 months ago
by
Alberto Paderno
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3464133
: Use only a test method for ApcCacheSaveCase
parent
c7404ba2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!41
Issue #3464133: Use only a test method for ApcCacheSaveCase
Pipeline
#235971
passed
6 months ago
Stage: build
Stage: validate
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/apc.test
+32
-58
32 additions, 58 deletions
tests/apc.test
with
32 additions
and
58 deletions
tests/apc.test
+
32
−
58
View file @
8939307f
...
...
@@ -37,7 +37,7 @@ class ApcCacheTestCase extends DrupalWebTestCase {
/**
* Adds modules to the list of modules to enable.
*
* @param
array
$modules
* @param
string ...
$modules
* The modules to enable.
*/
protected
function
setModules
(...
$modules
)
{
...
...
@@ -117,7 +117,7 @@ class ApcCacheTestCase extends DrupalWebTestCase {
}
/**
* Tests
cache
saving.
* Tests saving
and retrieving data
.
*/
class
ApcCacheSaveCase
extends
ApcCacheTestCase
{
...
...
@@ -127,76 +127,50 @@ class ApcCacheSaveCase extends ApcCacheTestCase {
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Save cache test'
,
'description'
=>
'Verifies the cached
value
s are correctly stored.'
,
'description'
=>
'Verifies the cached
item
s are correctly stored.'
,
'group'
=>
'Alternative PHP Cache'
,
);
}
/**
* Tests
saving and restoring a string
.
* Tests
retrieving data
.
*/
public
function
testString
()
{
$this
->
checkVariable
(
$this
->
randomName
(
100
));
}
/**
* Tests saving and restoring an integer.
*/
public
function
testInteger
()
{
$this
->
checkVariable
(
100
);
}
/**
* Tests saving and restoring a double.
*/
public
function
testDouble
()
{
$this
->
checkVariable
(
1.29
);
}
/**
* Tests saving and restoring an array.
*/
public
function
testArray
()
{
$this
->
checkVariable
(
array
(
'drupal1'
,
'drupal2'
=>
'drupal3'
,
'drupal4'
=>
array
(
'drupal5'
,
'drupal6'
)));
}
/**
* Tests saving and restoring an object.
*/
public
function
testObject
()
{
protected
function
testRetrievingData
()
{
$bin
=
'cache_apc'
;
$test_object
=
new
stdClass
();
$test_object
->
test1
=
$this
->
randomName
(
100
);
$test_object
->
test2
=
100
;
$test_object
->
test3
=
array
(
'drupal1'
,
'drupal2'
=>
'drupal3'
,
'drupal4'
=>
array
(
'drupal5'
,
'drupal6'
));
cache_set
(
'test_object'
,
$test_object
,
$bin
);
$cache
=
cache_get
(
'test_object'
,
$bin
);
$this
->
assertTrue
(
isset
(
$cache
->
data
)
&&
$cache
->
data
==
$test_object
,
t
(
'Object is saved and restored properly.'
));
}
$values
=
array
(
'boolean'
=>
TRUE
,
'integer'
=>
mt_rand
(
256
,
1024
),
'string'
=>
$this
->
randomString
(),
'array'
=>
array
(
mt_rand
(
8
,
32
)
=>
$this
->
randomString
(),
$this
->
randomName
()
=>
$this
->
randomString
(),
$this
->
randomName
(
10
)
=>
array
(
mt_rand
(
8
,
32
)
=>
$this
->
randomString
(),
$this
->
randomName
()
=>
$this
->
randomstring
(),
),
),
'object'
=>
(
object
)
array
(
$this
->
randomName
()
=>
$this
->
randomString
(),
$this
->
randomName
(
10
)
=>
array
(
mt_rand
(
8
,
32
)
=>
$this
->
randomString
(),
$this
->
randomName
()
=>
$this
->
randomstring
(),
),
),
);
/**
* Verifies a value is stored and restored properly in the cache.
*/
protected
function
checkVariable
(
$var
)
{
$bin
=
'cache_apc'
;
cache_set
(
'test_var'
,
$var
,
$bin
);
$cache
=
cache_get
(
'test_var'
,
$bin
);
$this
->
assertTrue
(
isset
(
$cache
->
data
)
&&
$cache
->
data
===
$var
,
t
(
'@type is saved and restored properly.'
,
array
(
'@type'
=>
ucfirst
(
gettype
(
$var
)))));
}
foreach
(
$values
as
$type
=>
$data
)
{
cache_set
(
"test_var_
$type
"
,
$data
,
$bin
);
}
/**
* Test no empty cache IDs are written in the cache table.
*/
public
function
testNoEmptyCids
()
{
$this
->
drupalGet
(
'user/register'
);
$this
->
assertFalse
(
cache_get
(
''
),
t
(
'No cache entry is written with an empty cache ID.'
));
foreach
(
$values
as
$type
=>
$data
)
{
$this
->
assertCacheItem
(
$bin
,
"test_var_
$type
"
,
$data
);
}
}
}
/**
* Test cache_get_multiple().
* Test
s
cache_get_multiple().
*/
class
ApcCacheGetMultipleUnitTest
extends
ApcCacheTestCase
{
...
...
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