Passed
Push — master ( d309df...7ec489 )
by Petr
02:37
created

BasicTest::testFilesCloseCrash()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
namespace SourcesTests\Files\Storage;
4
5
6
use kalanis\kw_auth\AuthException;
7
use kalanis\kw_auth\Translations;
8
9
10
class BasicTest extends AStorageTests
11
{
12
    /**
13
     * @throws AuthException
14
     */
15
    public function testFiles(): void
16
    {
17
        $lib = new MockFiles();
18
        $lib->setLang(new Translations());
19
        $content = $lib->open($this->sourcePath);
20
        $this->assertNotEmpty($content);
21
        $lib->save($this->testingPath, $content);
22
        chmod($this->testingPath, 0444);
23
        $this->expectException(AuthException::class);
24
        $lib->save($this->testingPath, $content);
25
    }
26
27
    /**
28
     * @throws AuthException
29
     */
30
    public function testFilesOpenCrash(): void
31
    {
32
        $lib = new MockFiles(new XCrashStorage());
33
        $lib->setLang(new Translations());
34
        $this->expectException(AuthException::class);
35
        $lib->open($this->testingPath);
36
    }
37
38
    /**
39
     * @throws AuthException
40
     */
41
    public function testFilesCloseCrash(): void
42
    {
43
        $lib = new MockFiles(new XCrashStorage());
44
        $lib->setLang(new Translations());
45
        $this->expectException(AuthException::class);
46
        $lib->save($this->testingPath, [['anything']]);
47
    }
48
}
49