From 41b7415b02df4119fa0a97067eaa05e76cd858ca Mon Sep 17 00:00:00 2001 From: Josh Kadis Date: Fri, 23 Dec 2016 07:43:45 -0500 Subject: [PATCH] should fix teardown --- hugo-content-test/.gitkeep | 1 + tests/test-write-file.php | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 hugo-content-test/.gitkeep 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 ); + } } }