TextFileTestCase::tearDown()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace TextFile\Tests;
4
5
use Symfony\Component\Filesystem\Filesystem;
6
7
/**
8
 * Class TextFileTestCase
9
 *
10
 * @package TextFile\Tests
11
 */
12
class TextFileTestCase extends \PHPUnit_Framework_TestCase
13
{
14
    /**
15
     * @var string
16
     */
17
    protected $workspace;
18
19
    /**
20
     * @var Filesystem
21
     */
22
    protected $filesystem;
23
24
    protected function setUp()
25
    {
26
        $this->filesystem = new Filesystem();
27
        $this->workspace  = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.time().mt_rand(0, 1000);
28
29
        mkdir($this->workspace, 0777, true);
30
31
        $this->workspace = realpath($this->workspace);
32
    }
33
34
    protected function tearDown()
35
    {
36
        $this->filesystem->remove($this->workspace);
37
    }
38
39
    /**
40
     * @param string $fileName
41
     *
42
     * @return string
43
     */
44
    protected function createTestFileFromFixtures($fileName)
45
    {
46
        $this->filesystem->copy($this->getPathFixtureFile($fileName), $this->workspace.DIRECTORY_SEPARATOR.$fileName);
47
48
        return $this->workspace.DIRECTORY_SEPARATOR.$fileName;
49
    }
50
51
    /**
52
     * @param string $fileName
53
     *
54
     * @return string
55
     */
56
    protected function getPathFixtureFile($fileName)
57
    {
58
        return __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.$fileName;
59
    }
60
}
61