diff --git a/changelog.md b/changelog.md index 6ad7daa6..94c139d1 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,7 @@ ## Version {next} - Add support for ownyourgram.com sending h-card locations - change sluggable implementation + - Add tests for uploading new articles from .md files ## Version 0.5.14 (2017-06-11) - Remove some Log statements in-appropriate for porduction diff --git a/tests/Feature/ArticlesAdminTest.php b/tests/Feature/ArticlesAdminTest.php new file mode 100644 index 00000000..7981e3bd --- /dev/null +++ b/tests/Feature/ArticlesAdminTest.php @@ -0,0 +1,47 @@ +withSession(['loggedin' => true]) + ->post('/admin/blog', [ + 'title' => 'Test Title', + 'main' => 'Article content' + ]); + $this->assertDatabaseHas('articles', ['title' => 'Test Title']); + } + + public function test_create_new_article_with_upload() + { + $faker = \Faker\Factory::create(); + $text = $faker->text; + if ($fh = fopen(sys_get_temp_dir() . '/article.md', 'w')) { + fwrite($fh, $text); + fclose($fh); + } + $path = sys_get_temp_dir() . '/article.md'; + $file = new UploadedFile($path, 'article.md', 'text/plain', filesize($path), null, true); + + $this->withSession(['loggedin' => true]) + ->post('/admin/blog', [ + 'title' => 'Uploaded Article', + 'article' => $file, + ]); + + $this->assertDatabaseHas('articles', [ + 'title' => 'Uploaded Article', + 'main' => $text, + ]); + } +}