Skip to content

Commit

Permalink
Unit test save method
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Oct 21, 2023
1 parent 12db0fc commit 73f3439
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/framework/tests/Unit/CreatesNewMarkdownPostFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Hyde\Framework\Testing\Unit;

use Hyde\Hyde;
use Hyde\Testing\TestCase;
use Illuminate\Support\Carbon;
use Hyde\Framework\Actions\CreatesNewMarkdownPostFile;
Expand Down Expand Up @@ -46,4 +47,29 @@ public function testWithCustomData()
'date' => '2024-01-01 00:00',
], $array);
}

public function testSave()
{
Carbon::setTestNow(Carbon::create(2024));

$action = new CreatesNewMarkdownPostFile('Example Post', null, null, null);
$action->save();

$path = Hyde::path('_posts/example-post.md');

$this->assertSame(<<<'MARKDOWN'
---
title: 'Example Post'
description: 'A short description used in previews and SEO'
category: blog
author: default
date: '2024-01-01 00:00'
---
## Write something awesome.

MARKDOWN, file_get_contents($path));

unlink($path);
}
}

0 comments on commit 73f3439

Please sign in to comment.