Browse Source

Fix failed test

pull/36/head
Nafies Luthfi 5 years ago
parent
commit
ac2e69b2c8
  1. 30
      tests/Generators/ModelFactoryGeneratorTest.php
  2. 6
      tests/Generators/ModelGeneratorTest.php
  3. 2
      tests/Generators/ModelPolicyGeneratorTest.php

30
tests/Generators/ModelFactoryGeneratorTest.php

@ -85,32 +85,16 @@ class {$this->model_name}Factory extends Factory
$this->assertFileExists($modelFactoryPath);
$modelFactoryContent = "<?php
namespace Database\Factories;
/* @var \$factory \Illuminate\Database\Eloquent\Factory */
use App\Model;
use Illuminate\Database\Eloquent\Factories\Factory;
use Faker\Generator as Faker;
class {$this->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));
}

6
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));

2
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
{

Loading…
Cancel
Save