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

TempFilesTest::testCannotUseSource()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 0
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