Passed
Push — master ( 1b6475...610123 )
by Petr
10:18
created

VolumeTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 18
rs 10
c 2
b 0
f 0
wmc 1
1
<?php
2
3
namespace KeysTests;
4
5
6
use CommonTestClass;
7
use kalanis\UploadPerPartes\Exceptions\UploadException;
8
use kalanis\UploadPerPartes\Keys;
9
use kalanis\UploadPerPartes\Uploader\TargetSearch;
10
use kalanis\UploadPerPartes\Uploader\Translations;
11
use Support;
12
13
14
class VolumeTest extends CommonTestClass
15
{
16
    /**
17
     * @throws UploadException
18
     */
19
    public function testThru(): void
20
    {
21
        $lang = new Translations();
22
        $target = new TargetSearch(new Support\InfoRam($lang), new Support\DataRam($lang), $lang);
23
        $target->setRemoteFileName('poiuztrewq')->setTargetDir('/tmp/')->process();
24
        $lib = new Keys\SimpleVolume($target, $lang);
25
        $lib->generateKeys();
26
27
        $this->assertEquals(base64_encode('/tmp/poiuztrewq' . TargetSearch::FILE_DRIVER_SUFF), $lib->getSharedKey());
28
        $this->assertEquals('/tmp/lkjhg', $lib->fromSharedKey(base64_encode('/tmp/lkjhg')));
29
        $this->expectException(UploadException::class);
30
        $lib->fromSharedKey('**/tmp/lkjhg'); // aaand failed... - chars outside the b64
31
        $this->expectExceptionMessageMatches('SHARED KEY IS INVALID');
32
    }
33
}
34