1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace VolumeTests; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
use kalanis\kw_files\FilesException; |
7
|
|
|
use kalanis\kw_paths\PathsException; |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
class DirFailTest extends AVolume |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @throws FilesException |
14
|
|
|
* @throws PathsException |
15
|
|
|
*/ |
16
|
|
|
public function testCopyUnknown(): void |
17
|
|
|
{ |
18
|
|
|
$lib = $this->getDirLib(); |
19
|
|
|
$this->assertFalse($lib->copyDir(['not source'], ['extra2'])); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @throws FilesException |
24
|
|
|
* @throws PathsException |
25
|
|
|
*/ |
26
|
|
|
public function testCopyToUnknownDir(): void |
27
|
|
|
{ |
28
|
|
|
$lib = $this->getDirLib(); |
29
|
|
|
$this->assertFalse($lib->copyDir(['next_one', 'sub_one'], ['unknown', 'last_one'])); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @throws FilesException |
34
|
|
|
* @throws PathsException |
35
|
|
|
*/ |
36
|
|
|
public function testCopyToExisting(): void |
37
|
|
|
{ |
38
|
|
|
$lib = $this->getDirLib(); |
39
|
|
|
$this->assertFalse($lib->copyDir(['next_one', 'sub_one'], ['last_one'])); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @throws FilesException |
44
|
|
|
* @throws PathsException |
45
|
|
|
*/ |
46
|
|
|
public function testCopyToSub(): void |
47
|
|
|
{ |
48
|
|
|
$lib = $this->getDirLib(); |
49
|
|
|
$this->assertFalse($lib->copyDir(['next_one', 'sub_one'], ['next_one', 'sub_one', 'deeper'])); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @throws FilesException |
54
|
|
|
* @throws PathsException |
55
|
|
|
*/ |
56
|
|
|
public function testMoveUnknown(): void |
57
|
|
|
{ |
58
|
|
|
$lib = $this->getDirLib(); |
59
|
|
|
$this->assertFalse($lib->moveDir(['not source'], ['extra2'])); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @throws FilesException |
64
|
|
|
* @throws PathsException |
65
|
|
|
*/ |
66
|
|
|
public function testMoveToUnknownDir(): void |
67
|
|
|
{ |
68
|
|
|
$lib = $this->getDirLib(); |
69
|
|
|
$this->assertFalse($lib->moveDir(['next_one', 'sub_one'], ['unknown', 'last_one'])); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @throws FilesException |
74
|
|
|
* @throws PathsException |
75
|
|
|
*/ |
76
|
|
|
public function testMoveToExisting(): void |
77
|
|
|
{ |
78
|
|
|
$lib = $this->getDirLib(); |
79
|
|
|
$this->assertFalse($lib->moveDir(['next_one', 'sub_one'], ['last_one'])); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @throws FilesException |
84
|
|
|
* @throws PathsException |
85
|
|
|
*/ |
86
|
|
|
public function testMoveToSub(): void |
87
|
|
|
{ |
88
|
|
|
$lib = $this->getDirLib(); |
89
|
|
|
$this->assertFalse($lib->moveDir(['next_one', 'sub_one'], ['next_one', 'sub_one', 'deeper'])); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @throws FilesException |
94
|
|
|
* @throws PathsException |
95
|
|
|
*/ |
96
|
|
|
public function testDeleteFile(): void |
97
|
|
|
{ |
98
|
|
|
$lib = $this->getDirLib(); |
99
|
|
|
$this->assertFalse($lib->deleteDir(['sub', 'dummy3.txt'])); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @throws FilesException |
104
|
|
|
* @throws PathsException |
105
|
|
|
*/ |
106
|
|
|
public function testDeleteNonEmpty(): void |
107
|
|
|
{ |
108
|
|
|
$lib = $this->getDirLib(); |
109
|
|
|
$this->assertFalse($lib->deleteDir(['next_one'])); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @throws FilesException |
114
|
|
|
* @throws PathsException |
115
|
|
|
*/ |
116
|
|
|
public function testDeepDeleteFail(): void |
117
|
|
|
{ |
118
|
|
|
$lib = $this->getDirLib(); |
119
|
|
|
$this->assertTrue($lib->createDir(['some', 'more'], true)); |
120
|
|
|
$this->assertFalse($lib->deleteDir(['some'])); |
121
|
|
|
$this->assertTrue($lib->deleteDir(['some'], true)); |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|