|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Zip test file. |
|
4
|
|
|
* |
|
5
|
|
|
* @package Tests |
|
6
|
|
|
* |
|
7
|
|
|
* @copyright YetiForce S.A. |
|
8
|
|
|
* @license YetiForce Public License 5.0 (licenses/LicenseEN.txt or yetiforce.com) |
|
9
|
|
|
* @author Sławomir Kłos <[email protected]> |
|
10
|
|
|
* @author Mariusz Krzaczkowski <[email protected]> |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace Tests\App; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Zip test class. |
|
17
|
|
|
*/ |
|
18
|
|
|
class Zip extends \Tests\Base |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* Testing instance from file with no file name provided. |
|
22
|
|
|
* |
|
23
|
|
|
* @throws \App\Exceptions\AppException |
|
24
|
|
|
*/ |
|
25
|
|
|
public function testInstanceOpenNoFileName(): void |
|
26
|
|
|
{ |
|
27
|
|
|
$this->expectException(\App\Exceptions\AppException::class); |
|
28
|
|
|
\App\Zip::openFile(false); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Testing instance from not existing file. |
|
33
|
|
|
* |
|
34
|
|
|
* @throws \App\Exceptions\AppException |
|
35
|
|
|
*/ |
|
36
|
|
|
public function testInstanceOpenFileNotExists(): void |
|
37
|
|
|
{ |
|
38
|
|
|
$this->expectException(\App\Exceptions\AppException::class); |
|
39
|
|
|
\App\Zip::openFile('tests/data/NxFile.zip')->close(); |
|
|
|
|
|
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Testing instance from linux generated zip file. |
|
44
|
|
|
* |
|
45
|
|
|
* @throws \App\Exceptions\AppException |
|
46
|
|
|
*/ |
|
47
|
|
|
public function testInstanceOpenLinuxFile(): void |
|
48
|
|
|
{ |
|
49
|
|
|
$instanceOpen = \App\Zip::openFile('tests/data/TestLinux.zip'); |
|
|
|
|
|
|
50
|
|
|
$this->assertInstanceOf('\App\Zip', $instanceOpen, 'Expected zip object instance'); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Testing linux file unzip. |
|
55
|
|
|
* |
|
56
|
|
|
* @throws \App\Exceptions\AppException |
|
57
|
|
|
*/ |
|
58
|
|
|
public function testUnzipLinuxFile(): void |
|
59
|
|
|
{ |
|
60
|
|
|
$instanceOpen = \App\Zip::openFile('tests/data/TestLinux.zip', ['checkFiles' => false]); |
|
|
|
|
|
|
61
|
|
|
$instanceOpen->unzip('tests/tmp/TestLinux/'); |
|
62
|
|
|
$this->assertFileExists('tests/tmp/TestLinux/manifest.xml'); |
|
63
|
|
|
$this->assertFileExists('tests/tmp/TestLinux/languages/pl-PL/TestLinux.json'); |
|
64
|
|
|
\vtlib\Functions::recurseDelete('tests' . \DIRECTORY_SEPARATOR . 'tmp' . \DIRECTORY_SEPARATOR . 'TestLinux'); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Testing linux file extract. |
|
69
|
|
|
* |
|
70
|
|
|
* @throws \App\Exceptions\AppException |
|
71
|
|
|
*/ |
|
72
|
|
|
public function testExtractLinuxFile(): void |
|
73
|
|
|
{ |
|
74
|
|
|
$instanceOpen = \App\Zip::openFile('tests/data/TestLinux.zip', ['checkFiles' => false]); |
|
|
|
|
|
|
75
|
|
|
$instanceOpen->extract('tests/tmp/TestLinux/'); |
|
76
|
|
|
$this->assertFileExists('tests/tmp/TestLinux/manifest.xml'); |
|
77
|
|
|
$this->assertFileExists('tests/tmp/TestLinux/languages/pl-PL/TestLinux.json'); |
|
78
|
|
|
\vtlib\Functions::recurseDelete('tests' . \DIRECTORY_SEPARATOR . 'tmp' . \DIRECTORY_SEPARATOR . 'TestLinux'); |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|