Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
lock
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
4
Issues
4
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Packages
Packages
Container Registry
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
TYPO3
Extensions
lock
Commits
0dee446b
Commit
0dee446b
authored
Nov 10, 2017
by
Daniel Hürtgen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEATURE] LockBuilder::buildFlockLock() implemented
parent
f76c284d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
1 deletion
+58
-1
Classes/Builder/LockBuilder.php
Classes/Builder/LockBuilder.php
+30
-1
Tests/Unit/Builder/LockBuilderTest.php
Tests/Unit/Builder/LockBuilderTest.php
+28
-0
No files found.
Classes/Builder/LockBuilder.php
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
(
$className
,
$path
);
return
$lock
;
}
...
...
Tests/Unit/Builder/LockBuilderTest.php
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
([]);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment