Passed
Push — developer ( 0eda90...dedd13 )
by Radosław
15:38
created

Zip::testCreateFileBadDir()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 0
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();
0 ignored issues
show
Bug introduced by
'tests/data/NxFile.zip' of type string is incompatible with the type boolean expected by parameter $fileName of App\Zip::openFile(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

39
		\App\Zip::openFile(/** @scrutinizer ignore-type */ 'tests/data/NxFile.zip')->close();
Loading history...
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');
0 ignored issues
show
Bug introduced by
'tests/data/TestLinux.zip' of type string is incompatible with the type boolean expected by parameter $fileName of App\Zip::openFile(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

49
		$instanceOpen = \App\Zip::openFile(/** @scrutinizer ignore-type */ 'tests/data/TestLinux.zip');
Loading history...
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]);
0 ignored issues
show
Bug introduced by
'tests/data/TestLinux.zip' of type string is incompatible with the type boolean expected by parameter $fileName of App\Zip::openFile(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

60
		$instanceOpen = \App\Zip::openFile(/** @scrutinizer ignore-type */ 'tests/data/TestLinux.zip', ['checkFiles' => false]);
Loading history...
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]);
0 ignored issues
show
Bug introduced by
'tests/data/TestLinux.zip' of type string is incompatible with the type boolean expected by parameter $fileName of App\Zip::openFile(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

74
		$instanceOpen = \App\Zip::openFile(/** @scrutinizer ignore-type */ 'tests/data/TestLinux.zip', ['checkFiles' => false]);
Loading history...
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