Skip to content

[fs] Filesystem transport must create a storage dir if it does not exists. #78

New issue

Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “No Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? No Sign in to your account

Merged
merged 1 commit into from
May 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/fs/FsContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Enqueue\Psr\PsrDestination;
use Enqueue\Psr\PsrQueue;
use Makasim\File\TempFile;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Filesystem\LockHandler;

class FsContext implements PsrContext
Expand Down Expand Up @@ -38,6 +39,9 @@ class FsContext implements PsrContext
*/
public function __construct($storeDir, $preFetchCount, $chmod)
{
$fs = new Filesystem();
$fs->mkdir($storeDir);

$this->storeDir = $storeDir;
$this->preFetchCount = $preFetchCount;
$this->chmod = $chmod;
Expand Down
26 changes: 26 additions & 0 deletions pkg/fs/Tests/Functional/FsContextTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Enqueue\Fs\Tests\Functional;

use Enqueue\Fs\FsConnectionFactory;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Filesystem\Filesystem;

class FsContextTest extends TestCase
{
public function tearDown()
{
$fs = new Filesystem();
$fs->remove(sys_get_temp_dir().'/enqueue');
}

public function testShouldCreateFoldersIfNotExistOnConstruct()
{
$fs = new Filesystem();
$fs->remove(sys_get_temp_dir().'/enqueue');

$this->fsContext = (new FsConnectionFactory(['store_dir' => sys_get_temp_dir().'/enqueue/dir/notexiststest']))->createContext();

$this->assertDirectoryExists(sys_get_temp_dir().'/enqueue/dir/notexiststest');
}
}