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
0dee446b
Commit
0dee446b
authored
7 years ago
by
Daniel Hürtgen
Browse files
Options
Downloads
Patches
Plain Diff
[FEATURE] LockBuilder::buildFlockLock() implemented
parent
f76c284d
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/Builder/LockBuilder.php
+30
-1
30 additions, 1 deletion
Classes/Builder/LockBuilder.php
Tests/Unit/Builder/LockBuilderTest.php
+28
-0
28 additions, 0 deletions
Tests/Unit/Builder/LockBuilderTest.php
with
58 additions
and
1 deletion
Classes/Builder/LockBuilder.php
+
30
−
1
View file @
0dee446b
...
...
@@ -21,6 +21,35 @@ class LockBuilder implements SingletonInterface
* @throws LockCreateException
*/
public
function
buildDirectoryLock
(
array
$configuration
)
{
$lock
=
$this
->
buildPathLock
(
Lock\DirectoryLock
::
class
,
$configuration
);
return
$lock
;
}
/**
* @param array $configuration
*
* @return Lock\FlockLock
* @throws InvalidConfigurationException
* @throws LockCreateException
*/
public
function
buildFlockLock
(
array
$configuration
)
{
$lock
=
$this
->
buildPathLock
(
Lock\FlockLock
::
class
,
$configuration
);
return
$lock
;
}
/**
* @param string $className
* @param array $configuration
*
* @return Lock\LockInterface
* @throws InvalidConfigurationException
* @throws LockCreateException
*/
protected
function
buildPathLock
(
$className
,
array
$configuration
)
{
$path
=
isset
(
$configuration
[
'path'
])
?
(
string
)
$configuration
[
'path'
]
:
null
;
if
(
empty
(
$path
))
{
...
...
@@ -33,7 +62,7 @@ class LockBuilder implements SingletonInterface
if
(
!
$this
->
preparePath
(
$path
))
{
throw
new
LockCreateException
(
sprintf
(
'Path %s is not usable (not readable/writeable)'
,
$path
),
1510318759
);
}
$lock
=
GeneralUtility
::
makeInstance
(
Lock\DirectoryLock
::
class
,
$path
);
$lock
=
GeneralUtility
::
makeInstance
(
$
class
Name
,
$path
);
return
$lock
;
}
...
...
This diff is collapsed.
Click to expand it.
Tests/Unit/Builder/LockBuilderTest.php
+
28
−
0
View file @
0dee446b
...
...
@@ -99,4 +99,32 @@ class LockBuilderTest extends UnitTestCase
$builder
->
buildDirectoryLock
([]);
}
/**
* @test
*/
public
function
itBuildsAFlockLock
()
{
$configurtion
=
[
'path'
=>
$this
->
getLockPath
(),
];
$builder
=
new
LockBuilder
();
$lock
=
$builder
->
buildFlockLock
(
$configurtion
);
$this
->
assertInstanceOf
(
Lock\FlockLock
::
class
,
$lock
);
}
/**
* @test
* @expectedException \Higidi\Lock\Builder\Exception\InvalidConfigurationException
* @expectedExceptionCode 1510318044
*/
public
function
itThrowsAnInvalidConfigurationExceptionOnBuildAFlockLockWithMissingPathConfiguration
()
{
$builder
=
new
LockBuilder
();
$builder
->
buildFlockLock
([]);
}
}
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