Passed
Push — master ( af3dcf...3709c1 )
by Petr
02:16
created

FilesTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 29
rs 10
wmc 2
1
<?php
2
3
namespace ProcessingTests;
4
5
6
use kalanis\kw_files\FilesException;
7
use kalanis\kw_menu\EntriesSource;
8
use kalanis\kw_menu\MetaProcessor;
9
use kalanis\kw_menu\MetaSource;
10
use kalanis\kw_menu\MenuException;
11
use kalanis\kw_menu\MoreEntries;
12
use kalanis\kw_paths\PathsException;
13
14
15
class FilesTest extends \CommonTestClass
16
{
17
    /**
18
     * @throws FilesException
19
     * @throws MenuException
20
     * @throws PathsException
21
     */
22
    public function testExisting(): void
23
    {
24
        // in meta source the path targets the meta file with records of entries
25
        // in entries source the path targets the directory with files or or group identifier of entries
26
        $path = $this->getTargetPath();
27
        $lib = $this->getLib($path); // meta with data
28
        $lib->setMeta(['target.meta']); // file with meta data
29
        $lib->load();
30
        $this->assertNotEmpty($lib->getMeta());
31
    }
32
33
    /**
34
     * @throws FilesException
35
     * @throws MenuException
36
     * @throws PathsException
37
     */
38
    public function testNew(): void
39
    {
40
        $path = $this->getTargetPath();
41
        $lib = $this->getLib($path); // meta with data
42
        $lib->setGroupKey(['dummy3']); // dir with data
43
        $lib->setMeta(['copy.meta']); // file with meta data
44
        $lib->load();
45
        $this->assertNotEmpty($lib->getMeta());
46
    }
47
48
    /**
49
     * @param mixed $params
50
     * @throws FilesException
51
     * @throws MenuException
52
     * @throws PathsException
53
     * @return MoreEntries
54
     */
55
    protected function getLib($params): MoreEntries
56
    {
57
        return new MoreEntries(
58
            new MetaProcessor(
59
                (new MetaSource\Factory())->getSource($params)
60
            ),
61
            (new EntriesSource\Factory())->getSource($params)
62
        );
63
    }
64
}
65