Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
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
drupal
Commits
51bc69ca
Commit
51bc69ca
authored
11 years ago
by
catch
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2088147
by damiankloip: Unit test the LockBackendAbstract class.
parent
701d4e60
Branches
Branches containing commit
Tags
Tags containing commit
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/tests/Drupal/Tests/Core/Lock/LockBackendAbstractTest.php
+77
-0
77 additions, 0 deletions
.../tests/Drupal/Tests/Core/Lock/LockBackendAbstractTest.php
with
77 additions
and
0 deletions
core/tests/Drupal/Tests/Core/Lock/LockBackendAbstractTest.php
0 → 100644
+
77
−
0
View file @
51bc69ca
<?php
/**
* @file
* Contains \Drupal\Tests\Core\Lock\LockBackendAbstractTest.
*/
namespace
Drupal\Tests\Core\Lock
;
use
Drupal\Tests\UnitTestCase
;
/**
* Tests the LockBackendAbstract class.
*
* @group Drupal
* @group Lock
*
* @see \Drupal\Tests\Core\Lock\LockBackendAbstractTest
*/
class
LockBackendAbstractTest
extends
UnitTestCase
{
/**
* The Mocked LockBackendAbstract object.
*
* @var \Drupal\Core\Lock\LockBackendAbstract|\PHPUnit_Framework_MockObject_MockObject
*/
protected
$lock
;
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'LockBackendAbstract test'
,
'description'
=>
'Test the LockBackendAbstract class.'
,
'group'
=>
'Lock'
,
);
}
public
function
setUp
()
{
$this
->
lock
=
$this
->
getMockForAbstractClass
(
'Drupal\Core\Lock\LockBackendAbstract'
);
}
/**
* Tests the wait() method when lockMayBeAvailable() returns TRUE.
*/
public
function
testWaitFalse
()
{
$this
->
lock
->
expects
(
$this
->
any
())
->
method
(
'lockMayBeAvailable'
)
->
with
(
$this
->
equalTo
(
'test_name'
))
->
will
(
$this
->
returnValue
(
TRUE
));
$this
->
assertFalse
(
$this
->
lock
->
wait
(
'test_name'
));
}
/**
* Tests the wait() method when lockMayBeAvailable() returns FALSE.
*/
public
function
testWaitTrue
()
{
$this
->
lock
->
expects
(
$this
->
any
())
->
method
(
'lockMayBeAvailable'
)
->
with
(
$this
->
equalTo
(
'test_name'
))
->
will
(
$this
->
returnValue
(
FALSE
));
$this
->
assertTrue
(
$this
->
lock
->
wait
(
'test_name'
,
1
));
}
/**
* Test the getLockId() method.
*/
public
function
testGetLockId
()
{
$lock_id
=
$this
->
lock
->
getLockId
();
$this
->
assertInternalType
(
'string'
,
$lock_id
);
// Example lock ID would be '7213141505232b6ee2cb967.27683891'.
$this
->
assertRegExp
(
'/[\da-f]+\.\d+/'
,
$lock_id
);
// Test the same lock ID is returned a second time.
$this
->
assertSame
(
$lock_id
,
$this
->
lock
->
getLockId
());
}
}
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