$I->seeInThisFile(' public function accounts() { return $this->hasMany("Tests\\Tmp\\Account"); } '); $I->seeInThisFile(' public function owner() { return $this->belongsTo("App\\User"); } '); $I->seeInThisFile(' public function number() { return $this->hasOne("Tests\\Tmp\\Phone"); } '); $I->wantTo('generate a model with validation rules'); $I->runShellCommand('php artisan wn:model TestingModel --rules="name=required age=integer|min:13 email=email|unique:users,email_address" --path=tests/tmp'); $I->seeFileFound('./tests/tmp/TestingModel.php'); $I->openFile('./tests/tmp/TestingModel.php'); $I->seeInThisFile(' public static $rules = [ "name" => "required", "age" => "integer|min:13", "email" => "email|unique:users,email_address", ]; '); $I->deleteFile('./tests/tmp/TestingModel.php');
public function tasks() { return $this->hasMany("App\\Task"); } public function project() { return $this->belongsTo("App\\Project"); } public function creator() { return $this->belongsTo("App\\User"); }'); $I->deleteFile('./app/TaskCategory.php'); // Checking the migration $I->seeInShellOutput('task_categories migration generated'); $I->seeFileFound('./database/migrations/create_task_categories.php'); $I->openFile('./database/migrations/create_task_categories.php'); $I->seeInThisFile('class CreateTaskCategoriesMigration extends Migration'); $I->seeInThisFile('Schema::create(\'task_categories\', function(Blueprint $table) { $table->increments(\'id\'); $table->string(\'name\')->unique(); $table->text(\'descr\')->nullable(); $table->integer(\'project_id\'); $table->timestamp(\'due\'); $table->foreign(\'project_id\') ->references(\'id\') ->on(\'projects\'); $table->timestamps();
use Illuminate\\Database\\Schema\\Blueprint; use Illuminate\\Database\\Migrations\\Migration; class CreateProjectTagTable extends Migration { public function up() { Schema::create(\'project_tag\', function(Blueprint $table) { $table->increments(\'id\'); $table->integer(\'project_id\')->unsigned()->index(); $table->integer(\'tag_id\')->unsigned()->index(); $table->foreign(\'project_id\') ->references(\'id\') ->on(\'projects\'); $table->foreign(\'tag_id\') ->references(\'id\') ->on(\'tags\'); $table->timestamps(); }); } public function down() { Schema::drop(\'project_tag\'); } } '); $I->deleteFile('./database/migrations/pivot_table.php');
{ Schema::create(\'tasks\', function(Blueprint $table) { $table->increments(\'id\'); // Schema declaration // Constraints declaration $table->timestamps(); }); } public function down() { Schema::drop(\'tasks\'); } } '); $I->deleteFile('./database/migrations/create_tasks.php'); $I->wantTo('generate a migration with schema'); $I->runShellCommand('php artisan wn:migration tasks --file=create_tasks --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->seeFileContentsEqual('<?php use Illuminate\\Database\\Schema\\Blueprint; use Illuminate\\Database\\Migrations\\Migration; class CreateTasksMigration extends Migration { public function up() {
<?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->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; }