protected $dates = [];

	public static $rules = [
		// Validation rules
	];

	// Relationships

}
');
$I->wantTo('generate a model with fillable fields');
$I->runShellCommand('php artisan wn:model TestingModel --fillable=name,title --path=tests/tmp');
$I->seeFileFound('./tests/tmp/TestingModel.php');
$I->openFile('./tests/tmp/TestingModel.php');
$I->seeInThisFile('protected $fillable = ["name", "title"];');
$I->wantTo('generate a model with dates fields');
$I->runShellCommand('php artisan wn:model TestingModel --dates=started_at --path=tests/tmp');
$I->seeFileFound('./tests/tmp/TestingModel.php');
$I->openFile('./tests/tmp/TestingModel.php');
$I->seeInThisFile('protected $dates = ["started_at"];');
$I->wantTo('generate a model with relations');
$I->runShellCommand('php artisan wn:model TestingModel --has-many=accounts --belongs-to="owner:App\\User" --has-one=number:Phone --path=tests/tmp');
$I->seeFileFound('./tests/tmp/TestingModel.php');
$I->openFile('./tests/tmp/TestingModel.php');
$I->seeInThisFile('
	public function accounts()
	{
		return $this->hasMany("Tests\\Tmp\\Account");
	}
');
<?php

$I = new AcceptanceTester($scenario);
$I->wantTo('generate a RESTful resource');
$I->runShellCommand('php artisan wn:resource task_category "name;string:unique;requied;fillable descr;text:nullable;;fillable project_id;integer;required;key,fillable due;timestamp;;fillable,date" --has-many="tags,tasks" --belongs-to="project,creator:User" --migration-file=create_task_categories');
// Checking the model
$I->seeInShellOutput('TaskCategory model generated');
$I->seeFileFound('./app/TaskCategory.php');
$I->openFile('./app/TaskCategory.php');
$I->seeInThisFile('namespace App;');
$I->seeInThisFile('class TaskCategory extends Model');
$I->seeInThisFile('protected $fillable = ["name", "descr", "project_id", "due"];');
$I->seeInThisFile('protected $dates = ["due"];');
$I->seeInThisFile('public static $rules = [
		"name" => "requied",
		"project_id" => "required",
	];');
$I->seeInThisFile('
	public function tags()
	{
		return $this->hasMany("App\\Tag");
	}

	public function tasks()
	{
		return $this->hasMany("App\\Task");
	}

	public function project()
	{
		return $this->belongsTo("App\\Project");
<?php

$I = new AcceptanceTester($scenario);
$I->wantTo('generate RESTful routes for a resource with default controller');
$I->runShellCommand('php artisan wn:route project-type');
$I->seeInShellOutput('project-type routes generated');
$I->openFile('./app/Http/routes.php');
$I->seeInThisFile("\n\$app->get('project-type', 'ProjectTypesController@all');\n\$app->get('project-type/{id}', 'ProjectTypesController@get');\n\$app->post('project-type', 'ProjectTypesController@add');\n\$app->put('project-type/{id}', 'ProjectTypesController@put');\n\$app->delete('project-type/{id}', 'ProjectTypesController@remove');\n");
$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();
});
');
$I->wantTo('generate RESTful routes for a resource with custom controller');
$I->runShellCommand('php artisan wn:route foo --controller=customController');
$I->seeInShellOutput('foo routes generated');
$I->openFile('./app/Http/routes.php');
$I->seeInThisFile("\n\$app->get('foo', 'customController@all');\n\$app->get('foo/{id}', 'customController@get');\n\$app->post('foo', 'customController@add');\n\$app->put('foo/{id}', 'customController@put');\n\$app->delete('foo/{id}', 'customController@remove');\n");
$I->writeToFile('./app/Http/routes.php', '<?php
    public function up()
    {
        Schema::create(\'tasks\', function(Blueprint $table) {
            $table->increments(\'id\');
            $table->decimal(\'amount\', 5, 2)->after(\'size\')->default(8);
            $table->string(\'title\')->nullable();
            // Constraints declaration
            $table->timestamps();
        });
    }

    public function down()
    {
        Schema::drop(\'tasks\');
    }
}
');
$I->deleteFile('./database/migrations/create_tasks.php');
$I->wantTo('generate a migration with schema and foreign keys');
$I->runShellCommand('php artisan wn:migration tasks --file=create_tasks --keys="category_type_id user_id:identifier:members:cascade" --schema="amount:decimal.5,2:after.\'size\':default.8 title:string:nullable"');
$I->seeInShellOutput('tasks migration generated');
$I->seeFileFound('./database/migrations/create_tasks.php');
$I->openFile('./database/migrations/create_tasks.php');
$I->seeInThisFile('$table->foreign(\'category_type_id\')
                ->references(\'id\')
                ->on(\'category_types\');');
$I->seeInThisFile('$table->foreign(\'user_id\')
                ->references(\'identifier\')
                ->on(\'members\')
                ->onDelete(\'cascade\');');
$I->deleteFile('./database/migrations/create_tasks.php');
<?php

$I = new AcceptanceTester($scenario);
$I->wantTo('generate the REST actions trait');
$I->runShellCommand('php artisan wn:controller:rest-actions');
$I->seeInShellOutput('REST actions trait generated');
$I->seeFileFound('./app/Http/Controllers/RESTActions.php');
$I->openFile('./app/Http/Controllers/RESTActions.php');
$I->seeInThisFile('trait RESTActions {');
$I->deleteFile('./app/Http/Controllers/RESTActions.php');
$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("\n\$app->get('category', 'CategoriesController@all');\n\$app->get('category/{id}', 'CategoriesController@get');\n\$app->post('category', 'CategoriesController@add');\n\$app->put('category/{id}', 'CategoriesController@put');\n\$app->delete('category/{id}', 'CategoriesController@remove');\n");
$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();