From 0c9425dd5b745081af3fc6630fb5bbadb225fd7d Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Sun, 20 Aug 2017 21:42:26 +0800 Subject: [PATCH] Test the command creates correct model class content --- tests/CrudMakeCommandTest.php | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/CrudMakeCommandTest.php b/tests/CrudMakeCommandTest.php index 93b49f3..fbcc822 100644 --- a/tests/CrudMakeCommandTest.php +++ b/tests/CrudMakeCommandTest.php @@ -27,7 +27,33 @@ class CrudMakeCommandTest extends TestCase exec('rm '.app_path('Item.php')); exec('rm -r '.app_path('Http')); - exec('rm '.$migrationFilePath); + exec('rm '.database_path('migrations/*')); + exec('rm -r '.resource_path('views/items')); + exec('rm -r '.base_path('tests/Feature')); + exec('rm -r '.base_path('tests/Unit')); + } + + /** @test */ + public function it_creates_correct_model_class_content() + { + $this->artisan('make:crud', ['name' => 'Item', '--no-interaction' => true]); + + $this->assertFileExists(app_path('Item.php')); + $modelClassContent = "assertEquals($modelClassContent, file_get_contents(app_path('Item.php'))); + exec('rm '.app_path('Item.php')); + exec('rm -r '.app_path('Http')); + exec('rm '.database_path('migrations/*')); exec('rm -r '.resource_path('views/items')); exec('rm -r '.base_path('tests/Feature')); exec('rm -r '.base_path('tests/Unit'));