Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove _authors and _drafts directories #48 #53

Merged
merged 7 commits into from
Apr 1, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions tests/Feature/AuthorPostsIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,39 @@

use Hyde\Framework\Actions\CreatesNewMarkdownPostFile;
use Hyde\Framework\Hyde;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;

/**
* Test that the config/authors.yml feature works in
* conjunction with the static Post generator.
*
*
* @see AuthorServiceTest
* @see StaticSiteBuilderPostModuleTest
*/
class AuthorPostsIntegrationTest extends TestCase
{
/**
* Set up the test environment.
*
* @return void
*/
public function test_setup_integration_test_environment()
{
// If an authors.yml file exists, back it up.
if (file_exists(Hyde::path('config/authors.yml')) && !file_exists(Hyde::path('config/authors.yml.bak'))) {
if (file_exists(Hyde::path('config/authors.yml')) && ! file_exists(Hyde::path('config/authors.yml.bak'))) {
copy(Hyde::path('config/authors.yml'), Hyde::path('config/authors.yml.bak'));
}

// Create a new authors.yml file.
file_put_contents(Hyde::path('config/authors.yml'), "authors:\n");

$this->assertTrue(true);
}

/**
* Baseline test to create a post without a defined author,
* and assert that the username is displayed as is.
*
*
* Check that the author was not defined.
* We do this by building the static site and inspecting the DOM.
*/
Expand All @@ -53,7 +52,7 @@ public function test_create_post_with_undefined_author()

// Check that the post was created
$this->assertFileExists(Hyde::path('_posts/test-2dcbb2c-post-with-undefined-author.md'));

// Build the static page
$this->artisan('rebuild _posts/test-2dcbb2c-post-with-undefined-author.md')->assertExitCode(0);

Expand All @@ -68,7 +67,7 @@ public function test_create_post_with_undefined_author()
unlink(Hyde::path('_posts/test-2dcbb2c-post-with-undefined-author.md'));
unlink(Hyde::path('_site/posts/test-2dcbb2c-post-with-undefined-author.html'));
}

/**
* Test that a defined author has its name injected into the DOM.
*/
Expand All @@ -87,9 +86,9 @@ public function test_create_post_with_defined_author_with_name()

// Add the author to the authors.yml file
file_put_contents(Hyde::path('config/authors.yml'),
"authors:
'authors:
test_named_author:
name: Test Author");
name: Test Author');

// Check that the post was created
$this->assertFileExists(Hyde::path('_posts/test-2dcbb2c-post-with-defined-author-with-name.md'));
Expand Down Expand Up @@ -125,11 +124,11 @@ public function test_create_post_with_defined_author_with_website()

// Add the author to the authors.yml file
file_put_contents(Hyde::path('config/authors.yml'),
"authors:
'authors:
test_author_with_website:
name: Test Author
website: https://example.org
");
');

// Check that the post was created
$this->assertFileExists(Hyde::path('_posts/test-2dcbb2c-post-with-defined-author-with-name.md'));
Expand All @@ -153,10 +152,11 @@ public function test_create_post_with_defined_author_with_website()

/**
* Tear down the test environment.
*
* @return void
*/
public function test_teardown_integration_test_environment()
{
{
// Remove the test authors.yml file.
unlink(Hyde::path('config/authors.yml'));

Expand Down