Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
SemaphoreFactory example
$keys
=
[
]
;
$store
->
expects
(
$this
->
exactly
(
2
)
)
->
method
(
'save'
)
->
with
(
$this
->
callback
(
function
D
$key
)
use
(
&
$keys
)
{
$keys
[
]
=
$key
;
return
true;
}
)
)
;
$logger
=
$this
->
createMock
(
LoggerInterface::
class
)
;
$factory
=
new
SemaphoreFactory
(
$store
)
;
$factory
->
setLogger
(
$logger
)
;
$semaphore1
=
$factory
->
createSemaphore
(
'foo', 4
)
;
$semaphore2
=
$factory
->
createSemaphore
(
'foo', 4
)
;
// assert lock1 and lock2 don't share the same state
$semaphore1
->
acquire
(
)
;
$semaphore2
->
acquire
(
)
;
$this
->
assertNotSame
(
$keys
[
0
]
,
$keys
[
1
]
)
;
}