Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
TYPO3
Extensions
lock
Commits
0dee446b
Commit
0dee446b
authored
Nov 10, 2017
by
Daniel Hürtgen
Browse files
[FEATURE] LockBuilder::buildFlockLock() implemented
parent
f76c284d
Changes
2
Hide whitespace changes
Inline
Side-by-side
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
(
$
class
Name
,
$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