-
-
Notifications
You must be signed in to change notification settings - Fork 193
/
Copy pathIgnoreFilesAndFoldersTest.php
88 lines (74 loc) · 2.5 KB
/
IgnoreFilesAndFoldersTest.php
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
84
85
86
87
88
<?php
it('will remove laravel.log by default before building', function () {
$logPath = 'resources/app/storage/logs';
$laravelLog = $logPath.'/laravel.log';
// Create a dummy copy of the file
if (! file_exists($logPath)) {
mkdir($logPath, 0755, true);
}
file_put_contents($laravelLog, 'TEST');
// Run the test
$this->artisan('native:minify resources/app');
$this->assertFalse(file_exists($laravelLog));
// Clean up after ourselves
if (file_exists($laravelLog)) {
unlink($laravelLog);
}
if (file_exists('resources/app/storage/logs')) {
rmdir('resources/app/storage/logs');
}
if (file_exists('resources/app/storage')) {
rmdir('resources/app/storage');
}
removeAppFolder();
});
it('will remove the content folder by default before building', function () {
$contentPath = 'resources/app/content';
// Create a dummy copy of the folder
if (! file_exists($contentPath)) {
mkdir($contentPath, 0755, true);
}
// Run the test
$this->artisan('native:minify resources/app');
$this->assertFalse(file_exists($contentPath));
// Clean up after ourselves
if (file_exists($contentPath)) {
unlink($contentPath);
}
removeAppFolder();
});
it('will remove only files that match a globbed path', function () {
$wildcardPath = 'resources/app/wildcardPath';
$yes1DeletePath = $wildcardPath.'/YES1.txt';
$yes2DeletePath = $wildcardPath.'/YES2.txt';
$noDeletePath = $wildcardPath.'/NO.txt';
config()->set('nativephp.cleanup_exclude_files', [$wildcardPath.'/YES*']);
// Create some dummy files
if (! file_exists($wildcardPath)) {
mkdir($wildcardPath, 0755, true);
}
file_put_contents($yes1DeletePath, 'PLEASE DELETE ME');
file_put_contents($yes2DeletePath, 'PLEASE DELETE ME TOO');
file_put_contents($noDeletePath, 'DO NOT DELETE ME');
// Run the test
$this->artisan('native:minify resources/app');
$this->assertFalse(file_exists($yes1DeletePath));
$this->assertFalse(file_exists($yes2DeletePath));
$this->assertTrue(file_exists($noDeletePath));
// Clean up after ourselves
foreach ([$yes1DeletePath, $yes2DeletePath, $noDeletePath] as $remove) {
if (file_exists($remove)) {
unlink($remove);
}
}
if (file_exists($wildcardPath)) {
rmdir($wildcardPath);
}
removeAppFolder();
});
function removeAppFolder()
{
if (file_exists('resources/app')) {
rmdir('resources/app');
}
}