Skip to content

Commit 21bbf07

Browse files
committed
Add PathsToIgnoreTest
1 parent a2321bf commit 21bbf07

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace WP2Static;
4+
5+
use PHPUnit\Framework\TestCase;
6+
7+
final class PathsToIgnoreTest extends TestCase {
8+
9+
use ITTrait;
10+
11+
/**
12+
* Test that detect step ignores path patterns
13+
* specified by the pathsToIgnore option.
14+
*/
15+
public function testDetectIgnores(): void {
16+
$dir = ITEnv::getTestContentDir();
17+
$path = ITEnv::getTestContentPath();
18+
file_put_contents( $dir . '/Dckrfile', 'RUN' );
19+
file_put_contents( $dir . '/Dockerfile', 'RUN' );
20+
file_put_contents( $dir . '/THUMBS.DB', 'RUN' );
21+
file_put_contents( $dir . '/wildcard.bat', 'RUN' );
22+
mkdir( $dir . '/node_modules', 0775, true );
23+
file_put_contents( $dir . '/node_modules/hello.html', 'RUN' );
24+
25+
$this->wpCli( [ 'wp2static', 'detect' ] );
26+
$lines = $this->wpCli( [ 'wp2static', 'crawl_queue', 'list' ] )['output'];
27+
$this->assertContains(
28+
$path . '/Dckrfile',
29+
$lines,
30+
'Sanity check that custom files are included'
31+
);
32+
$this->assertNotContains(
33+
$path . '/Dockerfile',
34+
$lines,
35+
'Filenames matching literals are ignored'
36+
);
37+
$this->assertNotContains(
38+
$path . '/THUMBS.DB',
39+
$lines,
40+
'Ignore patterns are not case-sensitive'
41+
);
42+
$this->assertNotContains(
43+
$path . '/wildcard.bat',
44+
$lines,
45+
'File extension glob patterns are ignored'
46+
);
47+
$this->assertNotContains(
48+
$path . '/node_modules/hello.html',
49+
$lines,
50+
'Directory literals are ignored'
51+
);
52+
}
53+
}

0 commit comments

Comments
 (0)