mirror of
https://github.com/ZorgCC/lumen-generators.git
synced 2024-12-30 15:45:30 +03:00
61 lines
2.0 KiB
PHP
61 lines
2.0 KiB
PHP
<?php
|
|
$I = new AcceptanceTester($scenario);
|
|
|
|
$I->wantTo('generate a RESTful controller with short model name');
|
|
$I->runShellCommand('php artisan wn:controller Test --no-routes');
|
|
$I->seeInShellOutput('TestsController generated');
|
|
$I->seeFileFound('./app/Http/Controllers/TestsController.php');
|
|
$I->openFile('./app/Http/Controllers/TestsController.php');
|
|
$I->seeFileContentsEqual('<?php namespace App\Http\Controllers;
|
|
|
|
class TestsController extends Controller {
|
|
|
|
const MODEL = "App\\Test";
|
|
|
|
use RESTActions;
|
|
|
|
}
|
|
');
|
|
$I->deleteFile('./app/Http/Controllers/TestsController.php');
|
|
|
|
$I->wantTo('generate a RESTful controller with full model name and routes');
|
|
$I->runShellCommand('php artisan wn:controller "App\Models\Category"');
|
|
$I->seeInShellOutput('CategoriesController generated');
|
|
$I->seeFileFound('./app/Http/Controllers/CategoriesController.php');
|
|
$I->openFile('./app/Http/Controllers/CategoriesController.php');
|
|
$I->seeFileContentsEqual('<?php namespace App\Http\Controllers;
|
|
|
|
class CategoriesController extends Controller {
|
|
|
|
const MODEL = "App\\Models\\Category";
|
|
|
|
use RESTActions;
|
|
|
|
}
|
|
');
|
|
$I->deleteFile('./app/Http/Controllers/CategoriesController.php');
|
|
$I->openFile('./app/Http/routes.php');
|
|
$I->seeInThisFile("
|
|
\$app->get('category', 'CategoriesController@all');
|
|
\$app->get('category/{id}', 'CategoriesController@get');
|
|
\$app->post('category', 'CategoriesController@add');
|
|
\$app->put('category/{id}', 'CategoriesController@put');
|
|
\$app->delete('category/{id}', 'CategoriesController@remove');
|
|
");
|
|
$I->writeToFile('./app/Http/routes.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) {
|
|
return $app->welcome();
|
|
});
|
|
'); |