artisan('make:crud', ['name' => $this->model_name, '--no-interaction' => true]); $modelPath = app_path($this->model_name.'.php'); $this->assertFileExists($modelPath); $modelClassContent = "model_name} extends Model { protected \$fillable = ['name', 'description', 'creator_id']; public function getNameLinkAttribute() { \$title = __('app.show_detail_title', [ 'name' => \$this->name, 'type' => __('{$this->lang_name}.{$this->lang_name}'), ]); \$link = 'table_name}.show', \$this).'\"'; \$link .= ' title=\"'.\$title.'\">'; \$link .= \$this->name; \$link .= ''; return \$link; } public function creator() { return \$this->belongsTo(User::class); } } "; $this->assertEquals($modelClassContent, file_get_contents($modelPath)); } /** @test */ public function it_creates_correct_namespaced_model_class_content() { $this->artisan('make:crud', ['name' => 'Entities/References/Category', '--no-interaction' => true]); $modelPath = app_path('Entities/References/Category.php'); $this->assertFileExists($modelPath); $modelClassContent = " \$this->name, 'type' => __('category.category'), ]); \$link = ''; \$link .= \$this->name; \$link .= ''; return \$link; } public function creator() { return \$this->belongsTo(User::class); } } "; $this->assertEquals($modelClassContent, file_get_contents($modelPath)); // tearDown $this->removeFileOrDir(resource_path('views/categories')); $this->removeFileOrDir(resource_path("lang/en/category.php")); } /** @test */ public function it_doesnt_override_the_existing_model() { $this->mockConsoleOutput = true; $this->artisan('make:model', ['name' => $this->model_name, '--no-interaction' => true]); $this->artisan('make:crud', ['name' => $this->model_name, '--no-interaction' => true]) ->expectsQuestion('Model file exists, are you sure to generate CRUD files?', true); $modelPath = app_path($this->model_name.'.php'); $this->assertFileExists($modelPath); $modelClassContent = "model_name} extends Model { // } "; $this->assertEquals($modelClassContent, file_get_contents($modelPath)); } }