Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lock
Manage
Activity
Members
Labels
Plan
Issues
9
Issue boards
Milestones
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Service Desk
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
TYPO3
Extensions
lock
Commits
00362ef5
Commit
00362ef5
authored
7 years ago
by
Daniel Hürtgen
Browse files
Options
Downloads
Patches
Plain Diff
[FEATURE] Inject lock implementation builder
parent
fb408934
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Classes/LockFactory.php
+21
-1
21 additions, 1 deletion
Classes/LockFactory.php
Tests/Unit/LockFactoryTest.php
+23
-0
23 additions, 0 deletions
Tests/Unit/LockFactoryTest.php
with
44 additions
and
1 deletion
Classes/LockFactory.php
+
21
−
1
View file @
00362ef5
...
...
@@ -18,15 +18,25 @@ class LockFactory extends CoreLockFactory
*/
protected
$configuration
;
/**
* @var LockBuilder
*/
protected
$lockBuilder
;
/**
* @param Configuration|null $configuration The configuration to use
* @param LockBuilder|null $lockBuilder The lock implementation builder to use
*/
public
function
__construct
(
Configuration
$configuration
=
null
)
public
function
__construct
(
Configuration
$configuration
=
null
,
LockBuilder
$lockBuilder
=
null
)
{
if
(
null
===
$configuration
)
{
$configuration
=
GeneralUtility
::
makeInstance
(
Configuration
::
class
);
}
if
(
null
===
$lockBuilder
)
{
$lockBuilder
=
GeneralUtility
::
makeInstance
(
LockBuilder
::
class
);
}
$this
->
configuration
=
$configuration
;
$this
->
lockBuilder
=
$lockBuilder
;
}
/**
...
...
@@ -39,6 +49,16 @@ class LockFactory extends CoreLockFactory
return
$this
->
configuration
;
}
/**
* Get lock builder.
*
* @return LockBuilder
*/
public
function
getLockBuilder
()
{
return
$this
->
lockBuilder
;
}
/**
* Get best matching locking method
*
...
...
This diff is collapsed.
Click to expand it.
Tests/Unit/LockFactoryTest.php
+
23
−
0
View file @
00362ef5
...
...
@@ -3,6 +3,7 @@
namespace
Higidi\Lock\Tests\Unit
;
use
Higidi\Lock\Configuration\Configuration
;
use
Higidi\Lock\LockBuilder
;
use
Higidi\Lock\LockFactory
;
use
Higidi\Lock\Strategy\MutexAdapterStrategy
;
use
Nimut\TestingFramework\TestCase\UnitTestCase
;
...
...
@@ -60,6 +61,28 @@ class LockFactoryTest extends UnitTestCase
$this
->
assertSame
(
$configuration
->
reveal
(),
$sut
->
getConfiguration
());
}
/**
* @test
*/
public
function
itCreatesADefaultLockBuilderIfNotPassed
()
{
$sut
=
new
LockFactory
();
$this
->
assertInstanceOf
(
LockBuilder
::
class
,
$sut
->
getLockBuilder
());
}
/**
* @test
*/
public
function
itHoldsALockBuilder
()
{
$lockBuilder
=
$this
->
prophesize
(
LockBuilder
::
class
);
$sut
=
new
LockFactory
(
null
,
$lockBuilder
->
reveal
());
$this
->
assertSame
(
$lockBuilder
->
reveal
(),
$sut
->
getLockBuilder
());
}
/**
* @test
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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