PublicDirectoryTest::tearDown()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the SF Forward Bundle.
5
 *
6
 * (c) DAOUDI Soufian <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace SfForward\Tests\Util;
13
14
use PHPUnit\Framework\TestCase;
15
use SfForward\Util\PublicDirectory;
16
17
class PublicDirectoryTest extends TestCase
18
{
19
    protected $projectDir;
20
    protected $webDir;
21
    protected $publicDir;
22
23
    protected function setUp()
24
    {
25
        $this->projectDir = sprintf('%s/../..', __DIR__);
26
    }
27
28
    protected function tearDown()
29
    {
30
        $this->projectDir = null;
31
        $this->webDir = null;
32
        $this->publicDir = null;
33
    }
34
35
    public function testGetPublicDir()
36
    {
37
        $this->assertEquals($this->projectDir.'/', PublicDirectory::getPublicDir($this->projectDir));
38
    }
39
40
    public function testGetWebDirectoryForSf2And3()
41
    {
42
        $webDir = sprintf('%s/%s/', $this->projectDir, PublicDirectory::WEB_FOLDER_NAME);
43
44
        if (!is_dir($webDir)) {
45
            mkdir($webDir);
46
        }
47
48
        $this->assertEquals($webDir, PublicDirectory::getPublicDir($this->projectDir));
49
50
        if (is_dir($webDir)) {
51
            rmdir($webDir);
52
        }
53
    }
54
55
    public function testGetPublicDirectoryForSf4()
56
    {
57
        $publicDir = sprintf('%s/%s/', $this->projectDir, PublicDirectory::PUBLIC_FOLDER_NAME);
58
59
        if (!is_dir($publicDir)) {
60
            mkdir($publicDir);
61
        }
62
63
        $this->assertEquals($publicDir, PublicDirectory::getPublicDir($this->projectDir));
64
65
        if (is_dir($publicDir)) {
66
            rmdir($publicDir);
67
        }
68
    }
69
}
70