Test Failed
Push — master ( f9dc8e...64f7bc )
by Petr
08:10
created

ThumbTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 17
dl 0
loc 37
rs 10
c 2
b 0
f 1
wmc 2
1
<?php
2
3
namespace SourcesTests;
4
5
6
use CommonTestClass;
7
use kalanis\kw_files\Access\Factory;
8
use kalanis\kw_files\Extended\Config;
9
use kalanis\kw_files\FilesException;
10
use kalanis\kw_images\Sources\Thumb;
11
use kalanis\kw_paths\PathsException;
12
use kalanis\kw_storage\Storage\Key;
13
use kalanis\kw_storage\Storage\Target;
14
15
16
/**
17
 * Class ThumbTest
18
 * Stored into memory, process there
19
 * @package SourcesTests
20
 */
21
class ThumbTest extends CommonTestClass
22
{
23
    /**
24
     * @throws FilesException
25
     * @throws PathsException
26
     */
27
    public function testProcessing(): void
28
    {
29
        $lib = $this->getLib();
30
        $this->assertFalse($lib->isHere(['testtree', 'testimage.png']));
31
        $this->assertTrue($lib->set(['testtree', 'testimage.png'], static::TEST_STRING));
32
        $this->assertTrue($lib->isHere(['testtree', 'testimage.png']));
33
        $this->assertEquals(static::TEST_STRING, $lib->get(['testtree', 'testimage.png']));
34
35
        $this->assertTrue($lib->copy('testimage.png', ['testtree'], ['dumptree']));
36
        $this->assertTrue($lib->move('testimage.png', ['testtree'], ['dumptree'] ,true));
37
        $this->assertFalse($lib->isHere(['testtree', 'testimage.png']));
38
        $this->assertTrue($lib->isHere(['dumptree', 'testimage.png']));
39
40
        $this->assertTrue($lib->rename(['dumptree'], 'testimage.png', 'tstimg.png'));
41
        $this->assertFalse($lib->isHere(['dumptree', 'testimage.png']));
42
        $this->assertTrue($lib->isHere(['dumptree', 'tstimg.png']));
43
44
        $this->assertTrue($lib->delete(['dumptree'], 'tstimg.png'));
45
        $this->assertFalse($lib->isHere(['dumptree', 'tstimg.png']));
46
    }
47
48
    /**
49
     * @param array<string, string|int> $params
50
     * @throws FilesException
51
     * @throws PathsException
52
     * @return Thumb
53
     */
54
    protected function getLib(array $params = [])
55
    {
56
        $storage = new \kalanis\kw_storage\Storage\Storage(new Key\DefaultKey(), new Target\Memory());
57
        return new Thumb((new Factory())->getClass($storage), (new Config())->setData($params));
58
    }
59
}
60