From ac2e69b2c8e9fbc831c7d51914b08989920d8ab9 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Mon, 15 Mar 2021 22:46:35 +0800 Subject: [PATCH] Fix failed test --- tests/Generators/ModelFactoryGeneratorTest.php | 30 ++++++-------------------- tests/Generators/ModelGeneratorTest.php | 6 ++---- tests/Generators/ModelPolicyGeneratorTest.php | 2 +- 3 files changed, 10 insertions(+), 28 deletions(-) diff --git a/tests/Generators/ModelFactoryGeneratorTest.php b/tests/Generators/ModelFactoryGeneratorTest.php index a9fa8f8..d052bf5 100644 --- a/tests/Generators/ModelFactoryGeneratorTest.php +++ b/tests/Generators/ModelFactoryGeneratorTest.php @@ -85,32 +85,16 @@ class {$this->model_name}Factory extends Factory $this->assertFileExists($modelFactoryPath); $modelFactoryContent = "model_name}Factory extends Factory -{ - /** - * The name of the factory's corresponding model. - * - * @var string - */ - protected \$model = Model::class; - - /** - * Define the model's default state. - * - * @return array - */ - public function definition() - { - return [ - // - ]; - } -} +\$factory->define(Model::class, function (Faker \$faker) { + return [ + // + ]; +}); "; $this->assertEquals($modelFactoryContent, file_get_contents($modelFactoryPath)); } diff --git a/tests/Generators/ModelGeneratorTest.php b/tests/Generators/ModelGeneratorTest.php index b0b3608..e00e95c 100644 --- a/tests/Generators/ModelGeneratorTest.php +++ b/tests/Generators/ModelGeneratorTest.php @@ -94,8 +94,7 @@ class Category extends Model public function it_doesnt_override_the_existing_model() { $this->mockConsoleOutput = true; - config(['auth.providers.users.model' => 'App\Models\User']); - $this->artisan('make:model', ['name' => 'Models/'.$this->model_name, '--no-interaction' => 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); @@ -105,12 +104,11 @@ class Category extends Model namespace App\Models; -use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class {$this->model_name} extends Model { - use HasFactory; + // } "; $this->assertEquals($modelClassContent, file_get_contents($modelPath)); diff --git a/tests/Generators/ModelPolicyGeneratorTest.php b/tests/Generators/ModelPolicyGeneratorTest.php index 4629415..a140378 100644 --- a/tests/Generators/ModelPolicyGeneratorTest.php +++ b/tests/Generators/ModelPolicyGeneratorTest.php @@ -244,8 +244,8 @@ class AuthServiceProvider extends ServiceProvider namespace App\Policies; -use Illuminate\Auth\Access\HandlesAuthorization; use {$userModel}; +use Illuminate\Auth\Access\HandlesAuthorization; class {$this->model_name}Policy {