aboutsummaryrefslogtreecommitdiff
path: root/tests/FilesTest.php
blob: 83a32d628762bd3ed48278c309b0087ae707c3b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php

namespace Wcms\Tests;

use PHPUnit\Framework\TestCase;

/**
 * This abstract test class adds 3 usefull variables for files tests:
 * - $this->testdir
 * - $this->notwritabledir
 * - $this->notwritablefile
 */
abstract class FilesTest extends TestCase
{
    protected $ds = DIRECTORY_SEPARATOR;
    protected $testdir = 'build/test';
    protected $notwritabledir = 'build/test/notwritabledir';
    protected $notwritablefile = 'build/test/notwritablefile';

    protected function setUp(): void
    {
        parent::setUp();
        if (!is_dir($this->testdir)) {
            mkdir($this->testdir, 0755, true);
        }
        if (!file_exists($this->notwritabledir)) {
            mkdir($this->notwritabledir, 0000);
        }
        if (!file_exists($this->notwritablefile)) {
            touch($this->notwritablefile);
            chmod($this->notwritablefile, 0000);
        }
    }
}