Skip to content

Commit

Permalink
Automatically handle test file cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Jul 3, 2024
1 parent 123b592 commit 65ec6f6
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions packages/framework/tests/Feature/PostsAuthorIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ public function testCreatePostWithUndefinedAuthor()
'>test_undefined_author</span>',
file_get_contents(Hyde::path('_site/posts/post-with-undefined-author.html'))
);

Filesystem::unlink('_posts/post-with-undefined-author.md');
Filesystem::unlink('_site/posts/post-with-undefined-author.html');
}

/**
Expand All @@ -67,9 +64,6 @@ public function testCreatePostWithDefinedAuthorWithName()
'<span itemprop="name" aria-label="The author\'s name" title=@named_author>Test Author</span>',
file_get_contents(Hyde::path('_site/posts/post-with-defined-author-with-name.html'))
);

Filesystem::unlink('_posts/post-with-defined-author-with-name.md');
Filesystem::unlink('_site/posts/post-with-defined-author-with-name.html');
}

/**
Expand Down Expand Up @@ -98,15 +92,15 @@ public function testCreatePostWithDefinedAuthorWithWebsite()
'<a href="https://example.org" rel="author" itemprop="url" aria-label="The author\'s website">',
file_get_contents(Hyde::path('_site/posts/post-with-defined-author-with-name.html'))
);

Filesystem::unlink('_posts/post-with-defined-author-with-name.md');
Filesystem::unlink('_site/posts/post-with-defined-author-with-name.html');
}

protected function createPostFile(string $title, string $author): void
{
(new CreatesNewMarkdownPostFile(title: $title, description: '', category: '', author: $author))->save();

$this->assertFileExists(Hyde::path('_posts/'.$title.'.md'));

$this->cleanUpWhenDone('_posts/'.$title.'.md');
$this->cleanUpWhenDone('_site/posts/'.$title.'.html');
}
}

0 comments on commit 65ec6f6

Please sign in to comment.