Passed
Push — master ( 1a6375...8f4058 )
by Petr
08:21 queued 05:12
created

TempFilesTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 16
c 0
b 0
f 0
dl 0
loc 49
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A fullProvider() 0 5 1
A testCannotUseSource() 0 4 1
A testCannotUseMime() 0 4 1
A testFull() 0 5 1
A getProcessor() 0 4 1
A testCannotMime() 0 5 1
1
<?php
2
3
namespace tests\ChecksTests;
4
5
6
use tests\CommonTestClass;
7
use kalanis\kw_files\Interfaces\IProcessFiles;
8
use kalanis\kw_files\Processing\Storage\Files\Basic;
9
use kalanis\kw_mime\Check\TempFiles;
10
use kalanis\kw_mime\MimeException;
11
use kalanis\kw_storage\Storage\Key;
12
use kalanis\kw_storage\Storage\Storage;
13
use kalanis\kw_storage\Storage\Target\Volume;
14
15
16
class TempFilesTest extends CommonTestClass
17
{
18
    public function testCannotUseMime(): void
19
    {
20
        $lib = new XFTempFiles1();
21
        $this->assertFalse($lib->canUse('whatever'));
22
    }
23
24
    public function testCannotUseSource(): void
25
    {
26
        $lib = new TempFiles();
27
        $this->assertFalse($lib->canUse('whatever'));
28
    }
29
30
    /**
31
     * @throws MimeException
32
     */
33
    public function testCannotMime(): void
34
    {
35
        $lib = new XFTempFiles2();
36
        $this->expectException(MimeException::class);
37
        $lib->getMime(['whatever']);
38
    }
39
40
    /**
41
     * @param string $file
42
     * @param string $mime
43
     * @throws MimeException
44
     * @dataProvider fullProvider
45
     */
46
    public function testFull(string $file, string $mime): void
47
    {
48
        $lib = new TempFiles();
49
        $lib->canUse($this->getProcessor());
50
        $this->assertEquals($mime, $lib->getMime([$file]));
51
    }
52
53
    public function fullProvider(): array
54
    {
55
        return [
56
            ['test.class', $this->defaultJavaFileMime()],
57
            ['test.pas', 'text/plain'],
58
        ];
59
    }
60
61
    protected function getProcessor(): IProcessFiles
62
    {
63
        Key\StaticPrefixKey::setPrefix(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR);
64
        return new Basic(new Storage(new Key\StaticPrefixKey(), new Volume()));
65
    }
66
}
67