Finalize testing

This commit is contained in:
Josiah Dahl 2017-08-07 11:02:36 -07:00
parent 5e2c21855e
commit a951151697
7 changed files with 53 additions and 51 deletions

View File

@ -1,5 +1,16 @@
<?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) {
return $app->welcome();
});

View File

@ -1,5 +1,16 @@
<?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) {
return [
'name' => $faker->name,
@ -8,4 +19,3 @@ $factory->define(App\User::class, function ($faker) {
'remember_token' => str_random(10),
];
});

View File

@ -39,7 +39,7 @@ $I->deleteFile('./app/Http/Controllers/AuthorsController.php');
$I->deleteFile('./app/Http/Controllers/LibrariesController.php');
$I->deleteFile('./app/Http/Controllers/BooksController.php');
$I->seeFileFound('routes/api.php');
$I->seeFileFound('./routes/api.php');
$I->seeInThisFile('
Route::get(\'author\', \'AuthorsController@all\');

View File

@ -38,14 +38,8 @@ class ControllerCommand extends BaseCommand {
$options = [
'resource' => snake_case($name, '-'),
'--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);
}

View File

@ -64,20 +64,13 @@ class ResourceCommand extends BaseCommand {
if(! $this->fs->exists('./app/Http/Controllers/RESTActions.php')){
$this->call('wn:controller:rest-actions');
}
// generating the controller and routes
$controllerOptions = [
'model' => $modelName,
'--force' => $this->option('force'),
'--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);
// generating model factory

View File

@ -36,16 +36,9 @@ class ResourcesCommand extends BaseCommand {
'--belongs-to-many' => $i['belongsToMany'],
'--path' => $this->option('path'),
'--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);
}

View File

@ -8,7 +8,7 @@ class RouteCommand extends BaseCommand {
protected $signature = 'wn:route
{resource : Name of the resource.}
{--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.';
@ -17,49 +17,50 @@ class RouteCommand extends BaseCommand {
{
$resource = $this->argument('resource');
$laravelRoutes = $this->input->hasOption('laravel') ? $this->option('laravel') : false;
$templateFile = 'routes';
$routesPath = 'routes/web.php';
if ($laravelRoutes) {
$templateFile = 'routes-laravel';
$routesPath = 'routes/api.php';
if (!$this->fs->isFile($routesPath)) {
if (!$this->fs->isDirectory('./routes')) {
$this->fs->makeDirectory('./routes');
}
$this->fs->put($routesPath, "
<?php
<?php
use Illuminate\Http\Request;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the \"api\" middleware group. Enjoy building your API!
|
*/
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
use Illuminate\Http\Request;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the \"api\" middleware group. Enjoy building your API!
|
*/
Route::middleware('auth:api')->get('/user', function (Request \$request) {
return \$request->user();
});
");
}
}
if(!$this->fs->isFile($routesPath)) {
if (!$this->fs->isFile($routesPath)) {
$routesPath = 'app/Http/routes.php';
}
$content = $this->fs->get($routesPath);
$content .= PHP_EOL . $this->getTemplate($templateFile)
->with([
'resource' => $resource,
'controller' => $this->getController()
])
->get();
->with([
'resource' => $resource,
'controller' => $this->getController()
])
->get();
$this->save($content, $routesPath, "{$resource} routes", true);
}