mirror of
https://github.com/ZorgCC/lumen-generators.git
synced 2024-12-27 06:25:28 +03:00
Finalize testing
This commit is contained in:
parent
5e2c21855e
commit
a951151697
@ -1,5 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Routes
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here is where you can register all of the routes for an application.
|
||||||
|
| It is a breeze. Simply tell Lumen the URIs it should respond to
|
||||||
|
| and give it the Closure to call when that URI is requested.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
$app->get("/", function () use ($app) {
|
$app->get("/", function () use ($app) {
|
||||||
return $app->welcome();
|
return $app->welcome();
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Model Factories
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may define all of your model factories. Model factories give
|
||||||
|
| you a convenient way to create models for testing and seeding your
|
||||||
|
| database. Just tell the factory how a default model should look.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
$factory->define(App\User::class, function ($faker) {
|
$factory->define(App\User::class, function ($faker) {
|
||||||
return [
|
return [
|
||||||
'name' => $faker->name,
|
'name' => $faker->name,
|
||||||
@ -8,4 +19,3 @@ $factory->define(App\User::class, function ($faker) {
|
|||||||
'remember_token' => str_random(10),
|
'remember_token' => str_random(10),
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ $I->deleteFile('./app/Http/Controllers/AuthorsController.php');
|
|||||||
$I->deleteFile('./app/Http/Controllers/LibrariesController.php');
|
$I->deleteFile('./app/Http/Controllers/LibrariesController.php');
|
||||||
$I->deleteFile('./app/Http/Controllers/BooksController.php');
|
$I->deleteFile('./app/Http/Controllers/BooksController.php');
|
||||||
|
|
||||||
$I->seeFileFound('routes/api.php');
|
$I->seeFileFound('./routes/api.php');
|
||||||
|
|
||||||
$I->seeInThisFile('
|
$I->seeInThisFile('
|
||||||
Route::get(\'author\', \'AuthorsController@all\');
|
Route::get(\'author\', \'AuthorsController@all\');
|
||||||
|
@ -38,14 +38,8 @@ class ControllerCommand extends BaseCommand {
|
|||||||
$options = [
|
$options = [
|
||||||
'resource' => snake_case($name, '-'),
|
'resource' => snake_case($name, '-'),
|
||||||
'--controller' => $controller,
|
'--controller' => $controller,
|
||||||
|
'--laravel' => $this->input->hasOption('laravel') ? $this->option('laravel') : false
|
||||||
];
|
];
|
||||||
// try {
|
|
||||||
// if($this->option('laravel')) {
|
|
||||||
// $options['--laravel'] = true;
|
|
||||||
// };
|
|
||||||
// } catch (InvalidArgumentException $e) {
|
|
||||||
// // Do nothing
|
|
||||||
// }
|
|
||||||
|
|
||||||
$this->call('wn:route', $options);
|
$this->call('wn:route', $options);
|
||||||
}
|
}
|
||||||
|
@ -64,20 +64,13 @@ class ResourceCommand extends BaseCommand {
|
|||||||
if(! $this->fs->exists('./app/Http/Controllers/RESTActions.php')){
|
if(! $this->fs->exists('./app/Http/Controllers/RESTActions.php')){
|
||||||
$this->call('wn:controller:rest-actions');
|
$this->call('wn:controller:rest-actions');
|
||||||
}
|
}
|
||||||
|
|
||||||
// generating the controller and routes
|
// generating the controller and routes
|
||||||
$controllerOptions = [
|
$controllerOptions = [
|
||||||
'model' => $modelName,
|
'model' => $modelName,
|
||||||
'--force' => $this->option('force'),
|
'--force' => $this->option('force'),
|
||||||
'--no-routes' => false,
|
'--no-routes' => false,
|
||||||
|
'--laravel' => $this->input->hasOption('laravel') ? $this->option('laravel') : false
|
||||||
];
|
];
|
||||||
try {
|
|
||||||
if($this->option('laravel')) {
|
|
||||||
$controllerOptions['--laravel'] = true;
|
|
||||||
};
|
|
||||||
} catch (InvalidArgumentException $e) {
|
|
||||||
// Do nothing
|
|
||||||
}
|
|
||||||
$this->call('wn:controller', $controllerOptions);
|
$this->call('wn:controller', $controllerOptions);
|
||||||
|
|
||||||
// generating model factory
|
// generating model factory
|
||||||
|
@ -36,16 +36,9 @@ class ResourcesCommand extends BaseCommand {
|
|||||||
'--belongs-to-many' => $i['belongsToMany'],
|
'--belongs-to-many' => $i['belongsToMany'],
|
||||||
'--path' => $this->option('path'),
|
'--path' => $this->option('path'),
|
||||||
'--force' => $this->option('force'),
|
'--force' => $this->option('force'),
|
||||||
|
'--laravel' => $this->input->hasOption('laravel') ? $this->option('laravel') : false
|
||||||
];
|
];
|
||||||
|
|
||||||
try {
|
|
||||||
if($this->option('laravel')) {
|
|
||||||
$options['--laravel'] = true;
|
|
||||||
};
|
|
||||||
} catch (InvalidArgumentException $e) {
|
|
||||||
// Do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->call('wn:resource', $options);
|
$this->call('wn:resource', $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ class RouteCommand extends BaseCommand {
|
|||||||
protected $signature = 'wn:route
|
protected $signature = 'wn:route
|
||||||
{resource : Name of the resource.}
|
{resource : Name of the resource.}
|
||||||
{--controller= : Name of the RESTful controller.}
|
{--controller= : Name of the RESTful controller.}
|
||||||
{--laravel= : Boolean (default false) Use Laravel style route definitions
|
{--laravel= : Boolean (default false) Use Laravel style route definitions}
|
||||||
';
|
';
|
||||||
|
|
||||||
protected $description = 'Generates RESTful routes.';
|
protected $description = 'Generates RESTful routes.';
|
||||||
@ -17,15 +17,17 @@ class RouteCommand extends BaseCommand {
|
|||||||
{
|
{
|
||||||
$resource = $this->argument('resource');
|
$resource = $this->argument('resource');
|
||||||
$laravelRoutes = $this->input->hasOption('laravel') ? $this->option('laravel') : false;
|
$laravelRoutes = $this->input->hasOption('laravel') ? $this->option('laravel') : false;
|
||||||
|
|
||||||
$templateFile = 'routes';
|
$templateFile = 'routes';
|
||||||
$routesPath = 'routes/web.php';
|
$routesPath = 'routes/web.php';
|
||||||
if ($laravelRoutes) {
|
if ($laravelRoutes) {
|
||||||
$templateFile = 'routes-laravel';
|
$templateFile = 'routes-laravel';
|
||||||
$routesPath = 'routes/api.php';
|
$routesPath = 'routes/api.php';
|
||||||
if (!$this->fs->isFile($routesPath)) {
|
if (!$this->fs->isFile($routesPath)) {
|
||||||
|
if (!$this->fs->isDirectory('./routes')) {
|
||||||
|
$this->fs->makeDirectory('./routes');
|
||||||
|
}
|
||||||
$this->fs->put($routesPath, "
|
$this->fs->put($routesPath, "
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@ -40,18 +42,17 @@ class RouteCommand extends BaseCommand {
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Route::middleware('auth:api')->get('/user', function (Request $request) {
|
Route::middleware('auth:api')->get('/user', function (Request \$request) {
|
||||||
return $request->user();
|
return \$request->user();
|
||||||
});
|
});
|
||||||
|
|
||||||
");
|
");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$this->fs->isFile($routesPath)) {
|
if (!$this->fs->isFile($routesPath)) {
|
||||||
$routesPath = 'app/Http/routes.php';
|
$routesPath = 'app/Http/routes.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = $this->fs->get($routesPath);
|
$content = $this->fs->get($routesPath);
|
||||||
|
|
||||||
$content .= PHP_EOL . $this->getTemplate($templateFile)
|
$content .= PHP_EOL . $this->getTemplate($templateFile)
|
||||||
|
Loading…
Reference in New Issue
Block a user