Create flock directory
This commit is contained in:
parent
e970027682
commit
be22c37ea1
@ -42,8 +42,12 @@ class FlockStore implements BlockingStoreInterface, SharedLockStoreInterface
|
|||||||
if (null === $lockPath) {
|
if (null === $lockPath) {
|
||||||
$lockPath = sys_get_temp_dir();
|
$lockPath = sys_get_temp_dir();
|
||||||
}
|
}
|
||||||
if (!is_dir($lockPath) || !is_writable($lockPath)) {
|
if (!is_dir($lockPath)) {
|
||||||
throw new InvalidArgumentException(sprintf('The directory "%s" is not writable.', $lockPath));
|
if (false === @mkdir($lockPath, 0777, true) && !is_dir($lockPath)) {
|
||||||
|
throw new InvalidArgumentException(sprintf('The FlockStore directory "%s" does not exists and cannot be created.', $lockPath));
|
||||||
|
}
|
||||||
|
} elseif (!is_writable($lockPath)) {
|
||||||
|
throw new InvalidArgumentException(sprintf('The FlockStore directory "%s" is not writable.', $lockPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->lockPath = $lockPath;
|
$this->lockPath = $lockPath;
|
||||||
|
@ -32,10 +32,10 @@ class FlockStoreTest extends AbstractStoreTest
|
|||||||
return new FlockStore();
|
return new FlockStore();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testConstructWhenRepositoryDoesNotExist()
|
public function testConstructWhenRepositoryCannotBeCreated()
|
||||||
{
|
{
|
||||||
$this->expectException('Symfony\Component\Lock\Exception\InvalidArgumentException');
|
$this->expectException('Symfony\Component\Lock\Exception\InvalidArgumentException');
|
||||||
$this->expectExceptionMessage('The directory "/a/b/c/d/e" is not writable.');
|
$this->expectExceptionMessage('The FlockStore directory "/a/b/c/d/e" does not exists and cannot be created.');
|
||||||
if (!getenv('USER') || 'root' === getenv('USER')) {
|
if (!getenv('USER') || 'root' === getenv('USER')) {
|
||||||
$this->markTestSkipped('This test will fail if run under superuser');
|
$this->markTestSkipped('This test will fail if run under superuser');
|
||||||
}
|
}
|
||||||
@ -46,7 +46,7 @@ class FlockStoreTest extends AbstractStoreTest
|
|||||||
public function testConstructWhenRepositoryIsNotWriteable()
|
public function testConstructWhenRepositoryIsNotWriteable()
|
||||||
{
|
{
|
||||||
$this->expectException('Symfony\Component\Lock\Exception\InvalidArgumentException');
|
$this->expectException('Symfony\Component\Lock\Exception\InvalidArgumentException');
|
||||||
$this->expectExceptionMessage('The directory "/" is not writable.');
|
$this->expectExceptionMessage('The FlockStore directory "/" is not writable.');
|
||||||
if (!getenv('USER') || 'root' === getenv('USER')) {
|
if (!getenv('USER') || 'root' === getenv('USER')) {
|
||||||
$this->markTestSkipped('This test will fail if run under superuser');
|
$this->markTestSkipped('This test will fail if run under superuser');
|
||||||
}
|
}
|
||||||
@ -54,6 +54,15 @@ class FlockStoreTest extends AbstractStoreTest
|
|||||||
new FlockStore('/');
|
new FlockStore('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testConstructWithSubdir()
|
||||||
|
{
|
||||||
|
if (!getenv('USER') || 'root' === getenv('USER')) {
|
||||||
|
$this->markTestSkipped('This test will fail if run under superuser');
|
||||||
|
}
|
||||||
|
|
||||||
|
new FlockStore(sys_get_temp_dir().'/sf-flock');
|
||||||
|
}
|
||||||
|
|
||||||
public function testSaveSanitizeName()
|
public function testSaveSanitizeName()
|
||||||
{
|
{
|
||||||
$store = $this->getStore();
|
$store = $this->getStore();
|
||||||
|
Reference in New Issue
Block a user