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

BasicTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 37
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testFiles() 0 10 1
A testFilesOpenCrash() 0 6 1
A testFilesCloseCrash() 0 6 1
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