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\Image; |
11
|
|
|
use kalanis\kw_paths\PathsException; |
12
|
|
|
use kalanis\kw_storage\Storage\Key; |
13
|
|
|
use kalanis\kw_storage\Storage\Target; |
14
|
|
|
|
15
|
|
|
|
16
|
|
|
class ImageTest extends CommonTestClass |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @throws FilesException |
20
|
|
|
* @throws PathsException |
21
|
|
|
*/ |
22
|
|
|
public function testProcessing(): void |
23
|
|
|
{ |
24
|
|
|
$lib = $this->getLib(); |
25
|
|
|
$tst1 = ['testtree', 'testimage.png']; |
26
|
|
|
|
27
|
|
|
$this->assertFalse($lib->isHere($tst1)); |
28
|
|
|
$this->assertTrue($lib->set($tst1, static::TEST_STRING)); |
29
|
|
|
$this->assertEquals(static::TEST_STRING, $lib->get($tst1)); |
30
|
|
|
$this->assertEmpty($lib->getCreated($tst1)); |
31
|
|
|
|
32
|
|
|
$this->assertEquals('testimage_0.png', $lib->findFreeName(['testtree'], 'testimage', '.png')); |
33
|
|
|
|
34
|
|
|
$this->assertTrue($lib->copy('testimage.png', ['testtree'], ['testtree', 'ext'])); |
35
|
|
|
$this->assertTrue($lib->delete(['testtree', 'ext'], 'testimage.png')); |
36
|
|
|
|
37
|
|
|
$this->assertTrue($lib->move('testimage.png', ['testtree'], ['testtree', 'tmb'])); |
38
|
|
|
$this->assertFalse($lib->isHere(['testtree', 'testimage.png'])); |
39
|
|
|
$this->assertTrue($lib->isHere(['testtree', 'tmb', 'testimage.png'])); |
40
|
|
|
|
41
|
|
|
$this->assertTrue($lib->rename(['testtree', 'tmb'], 'testimage.png', 'tstimg.png')); |
42
|
|
|
$this->assertFalse($lib->isHere(['testtree', 'tmb', 'testimage.png'])); |
43
|
|
|
$this->assertTrue($lib->isHere(['testtree', 'tmb', 'tstimg.png'])); |
44
|
|
|
|
45
|
|
|
$this->assertTrue($lib->delete(['testtree', 'tmb'], 'tstimg.png')); |
46
|
|
|
$this->assertFalse($lib->isHere(['testtree', 'tmb', 'tstimg.png'])); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @throws FilesException |
51
|
|
|
* @throws PathsException |
52
|
|
|
* @return Image |
53
|
|
|
*/ |
54
|
|
|
protected function getLib(): Image |
55
|
|
|
{ |
56
|
|
|
$storage = new \kalanis\kw_storage\Storage\Storage(new Key\DefaultKey(), new Target\Memory()); |
57
|
|
|
return new Image((new Factory())->getClass($storage), new Config()); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|