blob: a71be8d956684861681cd9bfaae037869da15171 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
<?php
declare(strict_types = 1);
namespace Pablotron\ZipStream\Tests;
use \PHPUnit\Framework\TestCase;
use \Pablotron\ZipStream\ZipStream;
final class PathTest extends BaseTestCase {
public function testAddEmptyPath() : void {
$this->expectException(\Pablotron\ZipStream\PathError::class);
$this->with_temp_zip(function(ZipStream &$zip) {
$zip->add_file('', 'empty test');
});
}
public function testAddLongPath() : void {
$this->expectException(\Pablotron\ZipStream\PathError::class);
$this->with_temp_zip(function(ZipStream &$zip) {
$long_path = str_repeat('x', 65535);
$zip->add_file($long_path, 'long path test');
});
}
public function testAddPathWithLeadingSlash() : void {
$this->expectException(\Pablotron\ZipStream\PathError::class);
$this->with_temp_zip(function(ZipStream &$zip) {
$zip->add_file('/foo', 'leading slash path test');
});
}
public function testAddPathWithTrailingSlash() : void {
$this->expectException(\Pablotron\ZipStream\PathError::class);
$this->with_temp_zip(function(ZipStream &$zip) {
$zip->add_file('foo/', 'trailing slash path test');
});
}
public function testAddPathWithDoubleSlashes() : void {
$this->expectException(\Pablotron\ZipStream\PathError::class);
$this->with_temp_zip(function(ZipStream &$zip) {
$zip->add_file('foo//bar', 'double slash path test');
});
}
public function testAddPathWithBackslashes() : void {
$this->expectException(\Pablotron\ZipStream\PathError::class);
$this->with_temp_zip(function(ZipStream &$zip) {
$zip->add_file('foo\\bar', 'backslash path test');
});
}
public function testLeadingRelativePath() : void {
$this->expectException(\Pablotron\ZipStream\PathError::class);
$this->with_temp_zip(function(ZipStream &$zip) {
$zip->add_file('../bar', 'leading relative path test');
});
}
public function testMiddleRelativePath() : void {
$this->expectException(\Pablotron\ZipStream\PathError::class);
$this->with_temp_zip(function(ZipStream &$zip) {
$zip->add_file('foo/../bar', 'middle relative path test');
});
}
public function testTrailingRelativePath() : void {
$this->expectException(\Pablotron\ZipStream\PathError::class);
$this->with_temp_zip(function(ZipStream &$zip) {
$zip->add_file('foo/../bar', 'trailing relative path test');
});
}
};
|