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 4e30713
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions packages/framework/tests/Feature/PostsAuthorIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Hyde\Framework\Testing\Feature;

use Hyde\Facades\Author;
use Hyde\Facades\Filesystem;
use Hyde\Framework\Actions\CreatesNewMarkdownPostFile;
use Hyde\Hyde;
use Hyde\Testing\TestCase;
Expand Down Expand Up @@ -42,9 +41,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 +63,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 +91,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 4e30713

Please sign in to comment.