diff --git a/hugo-content-test/.gitkeep b/hugo-content-test/.gitkeep new file mode 100644 index 0000000..00d6e16 --- /dev/null +++ b/hugo-content-test/.gitkeep @@ -0,0 +1 @@ +# Keep this dir around for unit tests \ No newline at end of file diff --git a/tests/test-write-file.php b/tests/test-write-file.php index 2eca0c9..5908b77 100644 --- a/tests/test-write-file.php +++ b/tests/test-write-file.php @@ -5,10 +5,16 @@ function setUp() { } function tearDown() { - unlink( './hugo-content-test/2016/12/the-post.md' ); - $dirs = array( './2016/12/23', './2016/12', './hugo-content-test/2016/12' ); + $test_file = './hugo-content-test/2016/12/the-post.md'; + if ( file_exists( $test_file ) ) { + unlink( $test_file ); + } + + $dirs = array( './2016/12/23', './2016/12', './2016', './hugo-content-test/2016/12', './hugo-content-test/2016' ); foreach ( $dirs as $dir ) { - rmdir( $dir ); + if ( is_dir( $dir ) ) { + rmdir( $dir ); + } } }