Passed
Push — master ( 1b6475...610123 )
by Petr
10:18
created

VolumeTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 30
dl 0
loc 57
rs 10
c 0
b 0
f 0
wmc 4
1
<?php
2
3
namespace InfoStorageTests;
4
5
6
use kalanis\UploadPerPartes\Exceptions\UploadException;
7
8
9
class VolumeTest extends AStorage
10
{
11
    /**
12
     * @throws UploadException
13
     */
14
    public function testThru(): void
15
    {
16
        $file = $this->mockTestFile();
17
        $storage = $this->mockStorage();
18
        $storage->save($file, 'abcdefghijklmnopqrstuvwxyz');
19
        $this->assertTrue($storage->exists($file));
20
        $storage->load($file);
21
        $storage->remove($file);
22
        $this->assertFalse($storage->exists($file));
23
    }
24
25
    /**
26
     * @throws UploadException
27
     */
28
    public function testUnreadable(): void
29
    {
30
        $file = $this->mockTestFile();
31
        $storage = $this->mockStorage();
32
        $storage->save($file, 'abcdefghijklmnopqrstuvwxyz');
33
        $storage->load($file);
34
        chmod($file, 0333);
35
        $this->expectException(UploadException::class);
36
        $storage->load($file);
37
        $this->expectExceptionMessageMatches('CANNOT READ DRIVEFILE');
38
    }
39
40
    /**
41
     * @throws UploadException
42
     */
43
    public function testUnwriteable(): void
44
    {
45
        $file = $this->mockTestFile();
46
        $storage = $this->mockStorage();
47
        $storage->save($file, 'abcdefghijklmnopqrstuvwxyz');
48
        chmod($file, 0444);
49
        $this->expectException(UploadException::class);
50
        $storage->save($file, 'abcdefghijklmnopqrstuvwxyz');
51
        $this->expectExceptionMessageMatches('CANNOT WRITE DRIVEFILE');
52
    }
53
54
    /**
55
     * @throws UploadException
56
     */
57
    public function testDeleted(): void
58
    {
59
        $file = $this->mockTestFile();
60
        $storage = $this->mockStorage();
61
        $storage->save($file, 'abcdefghijklmnopqrstuvwxyz');
62
        $storage->remove($file);
63
        $this->expectException(UploadException::class);
64
        $storage->remove($file); // dies here
65
        $this->expectExceptionMessageMatches('DRIVEFILE CANNOT BE REMOVED');
66
    }
67
}
68