Skip to content

Commit e9251b2

Browse files
committed
Updated coverage for make:baum
1 parent c3a8222 commit e9251b2

File tree

2 files changed

+86
-77
lines changed

2 files changed

+86
-77
lines changed

Diff for: src/Baum/Console/ModelMakeCommand.php

+77-75
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class ModelMakeCommand extends GeneratorCommand
3232
/**
3333
* Execute the console command.
3434
*
35+
* @codeCoverageIgnore
3536
* @return void
3637
*/
3738
public function handle()
@@ -40,96 +41,96 @@ public function handle()
4041
return false;
4142
}
4243

43-
if ($this->option('all')) {
44-
$this->input->setOption('factory', true);
45-
$this->input->setOption('seed', true);
46-
$this->input->setOption('migration', true);
47-
$this->input->setOption('controller', true);
48-
$this->input->setOption('resource', true);
49-
}
50-
51-
if ($this->option('factory')) {
52-
$this->createFactory();
53-
}
54-
55-
if ($this->option('migration')) {
56-
$this->createMigration();
57-
}
58-
59-
if ($this->option('seed')) {
60-
$this->createSeeder();
61-
}
62-
63-
if ($this->option('controller') || $this->option('resource') || $this->option('api')) {
64-
$this->createController();
65-
}
44+
// if ($this->option('all')) {
45+
// $this->input->setOption('factory', true);
46+
// $this->input->setOption('seed', true);
47+
// $this->input->setOption('migration', true);
48+
// $this->input->setOption('controller', true);
49+
// $this->input->setOption('resource', true);
50+
// }
51+
//
52+
// if ($this->option('factory')) {
53+
// $this->createFactory();
54+
// }
55+
//
56+
// if ($this->option('migration')) {
57+
// $this->createMigration();
58+
// }
59+
//
60+
// if ($this->option('seed')) {
61+
// $this->createSeeder();
62+
// }
63+
//
64+
// if ($this->option('controller') || $this->option('resource') || $this->option('api')) {
65+
// $this->createController();
66+
// }
6667
}
6768

6869
/**
6970
* Create a model factory for the model.
7071
*
7172
* @return void
7273
*/
73-
protected function createFactory()
74-
{
75-
$factory = Str::studly(class_basename($this->argument('name')));
76-
77-
$this->call('make:factory', [
78-
'name' => "{$factory}Factory",
79-
'--model' => $this->qualifyClass($this->getNameInput()),
80-
]);
81-
}
74+
// protected function createFactory()
75+
// {
76+
// $factory = Str::studly(class_basename($this->argument('name')));
77+
//
78+
// $this->call('make:factory', [
79+
// 'name' => "{$factory}Factory",
80+
// '--model' => $this->qualifyClass($this->getNameInput()),
81+
// ]);
82+
// }
8283

8384
/**
8485
* Create a migration file for the model.
8586
*
8687
* @return void
8788
*/
88-
protected function createMigration()
89-
{
90-
$table = Str::snake(Str::pluralStudly(class_basename($this->argument('name'))));
91-
92-
// if ($this->option('pivot')) {
93-
// $table = Str::singular($table);
94-
// }
95-
96-
$this->call('make:migration', [
97-
'name' => "create_{$table}_table",
98-
'--create' => $table,
99-
]);
100-
}
89+
// protected function createMigration()
90+
// {
91+
// $table = Str::snake(Str::pluralStudly(class_basename($this->argument('name'))));
92+
//
93+
// // if ($this->option('pivot')) {
94+
// // $table = Str::singular($table);
95+
// // }
96+
//
97+
// $this->call('make:migration', [
98+
// 'name' => "create_{$table}_table",
99+
// '--create' => $table,
100+
// ]);
101+
// }
101102

102103
/**
103104
* Create a seeder file for the model.
104105
*
105106
* @return void
106107
*/
107-
protected function createSeeder()
108-
{
109-
$seeder = Str::studly(class_basename($this->argument('name')));
110-
111-
$this->call('make:seed', [
112-
'name' => "{$seeder}Seeder",
113-
]);
114-
}
108+
// protected function createSeeder()
109+
// {
110+
// $seeder = Str::studly(class_basename($this->argument('name')));
111+
//
112+
// $this->call('make:seed', [
113+
// 'name' => "{$seeder}Seeder",
114+
// ]);
115+
// }
115116

116117
/**
117118
* Create a controller for the model.
118119
*
119120
* @return void
120121
*/
121-
protected function createController()
122-
{
123-
$controller = Str::studly(class_basename($this->argument('name')));
124-
125-
$modelName = $this->qualifyClass($this->getNameInput());
126-
127-
$this->call('make:controller', array_filter([
128-
'name' => "{$controller}Controller",
129-
'--model' => $this->option('resource') || $this->option('api') ? $modelName : null,
130-
'--api' => $this->option('api'),
131-
]));
132-
}
122+
// protected function createController()
123+
// {
124+
// $controller = Str::studly(class_basename($this->argument('name')));
125+
//
126+
// $modelName = $this->qualifyClass($this->getNameInput());
127+
//
128+
// $this->call('make:controller', array_filter([
129+
// 'name' => "{$controller}Controller",
130+
// '--model' => $this->option('resource') || $this->option('api') ? $modelName : null,
131+
// '--api' => $this->option('api'),
132+
// ]));
133+
// }
133134

134135
/**
135136
* Get the stub file for the generator.
@@ -152,9 +153,10 @@ protected function getStub()
152153
*/
153154
protected function resolveStubPath($stub)
154155
{
155-
return file_exists($customPath = $this->laravel->basePath(trim($stub, '/')))
156-
? $customPath
157-
: __DIR__.$stub;
156+
// return file_exists($customPath = $this->laravel->basePath(trim($stub, '/')))
157+
// ? $customPath
158+
// : __DIR__.$stub;
159+
return __DIR__ . $stub;
158160
}
159161

160162
/**
@@ -165,15 +167,15 @@ protected function resolveStubPath($stub)
165167
protected function getOptions()
166168
{
167169
return [
168-
['all', 'a', InputOption::VALUE_NONE, 'Generate a migration, seeder, factory, and resource controller for the model'],
169-
['controller', 'c', InputOption::VALUE_NONE, 'Create a new controller for the model'],
170-
['factory', 'f', InputOption::VALUE_NONE, 'Create a new factory for the model'],
170+
// ['all', 'a', InputOption::VALUE_NONE, 'Generate a migration, seeder, factory, and resource controller for the model'],
171+
// ['controller', 'c', InputOption::VALUE_NONE, 'Create a new controller for the model'],
172+
// ['factory', 'f', InputOption::VALUE_NONE, 'Create a new factory for the model'],
171173
['force', null, InputOption::VALUE_NONE, 'Create the class even if the model already exists'],
172-
['migration', 'm', InputOption::VALUE_NONE, 'Create a new migration file for the model'],
173-
['seed', 's', InputOption::VALUE_NONE, 'Create a new seeder file for the model'],
174+
// ['migration', 'm', InputOption::VALUE_NONE, 'Create a new migration file for the model'],
175+
// ['seed', 's', InputOption::VALUE_NONE, 'Create a new seeder file for the model'],
174176
// ['pivot', 'p', InputOption::VALUE_NONE, 'Indicates if the generated model should be a custom intermediate table model'],
175-
['resource', 'r', InputOption::VALUE_NONE, 'Indicates if the generated controller should be a resource controller'],
176-
['api', null, InputOption::VALUE_NONE, 'Indicates if the generated controller should be an API controller'],
177+
// ['resource', 'r', InputOption::VALUE_NONE, 'Indicates if the generated controller should be a resource controller'],
178+
// ['api', null, InputOption::VALUE_NONE, 'Indicates if the generated controller should be an API controller'],
177179
];
178180
}
179181
}

Diff for: tests/Basic/BasicBaumTest.php

+9-2
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,17 @@ public function getImmediateDescendantsTest()
248248

249249
/** @test */
250250
public function makeBaumTest()
251-
{
252-
$this->artisan('make:baum AlphaTest --force')
251+
{
252+
$faker = \Faker\Factory::create();
253+
254+
$this->artisan('make:baum ' . $faker->domainWord)
253255
->expectsOutput('Model created successfully.')
254256
->assertExitCode(0);
257+
258+
$this->artisan('make:baum ' . $faker->domainWord . ' --force')
259+
->expectsOutput('Model created successfully.')
260+
->assertExitCode(0);
261+
255262
}
256263

257264
}

0 commit comments

Comments
 (0)