Completed
Pull Request — master (#433)
by Albin
10:58
created

LocalTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 29
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 8 1
A tearDown() 0 6 2
A shouldSupportsDirectory() 0 5 1
1
<?php
2
3
namespace Gaufrette\Adapter\Local\Functional\FileStream;
4
5
use Gaufrette\Adapter\Local\Local;
6
use Gaufrette\Filesystem;
7
use Gaufrette\Functional\FileStream\FunctionalTestCase;
8
9
class LocalTest extends FunctionalTestCase
10
{
11
    protected $directory;
12
13
    public function setUp()
14
    {
15
        $this->directory = __DIR__.DIRECTORY_SEPARATOR.'filesystem';
16
        @mkdir($this->directory.DIRECTORY_SEPARATOR.'subdir', 0777, true);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
17
        $this->filesystem = new Filesystem(new Local($this->directory, true));
18
19
        $this->registerLocalFilesystemInStream();
20
    }
21
22
    public function tearDown()
23
    {
24
        if (is_dir($this->directory)) {
25
            (new \Symfony\Component\Filesystem\Filesystem())->remove($this->directory);
26
        }
27
    }
28
29
    /**
30
     * @test
31
     */
32
    public function shouldSupportsDirectory()
33
    {
34
        $this->assertTrue(file_exists('gaufrette://filestream/subdir'));
35
        $this->assertTrue(is_dir('gaufrette://filestream/subdir'));
36
    }
37
}
38