factory command will be added on the next release

This commit is contained in:
Amine Ben hammou 2015-12-05 21:03:15 +01:00
parent 7be47337d8
commit a33ffc7742
3 changed files with 98 additions and 98 deletions

View File

@ -1,69 +1,69 @@
<?php <?php
$I = new AcceptanceTester($scenario); // $I = new AcceptanceTester($scenario);
$I->wantTo('generate model factories without fields'); // $I->wantTo('generate model factories without fields');
$I->runShellCommand('php artisan wn:factory "App\Task"'); // $I->runShellCommand('php artisan wn:factory "App\Task"');
$I->seeInShellOutput('App\Task factory generated'); // $I->seeInShellOutput('App\Task factory generated');
$I->openFile('./database/factories/ModelFactory.php'); // $I->openFile('./database/factories/ModelFactory.php');
$I->seeInThisFile(' // $I->seeInThisFile('
$factory->define(App\Task::class, function ($faker) { // $factory->define(App\Task::class, function ($faker) {
return [ // return [
// Fields here // // Fields here
]; // ];
});'); // });');
$I->writeToFile('./database/factories/ModelFactory.php', "<?php // $I->writeToFile('./database/factories/ModelFactory.php', "<?php
/* // /*
|-------------------------------------------------------------------------- // |--------------------------------------------------------------------------
| Model Factories // | Model Factories
|-------------------------------------------------------------------------- // |--------------------------------------------------------------------------
| // |
| Here you may define all of your model factories. Model factories give // | Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your // | you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look. // | 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,
'email' => \$faker->email, // 'email' => \$faker->email,
'password' => str_random(10), // 'password' => str_random(10),
'remember_token' => str_random(10), // 'remember_token' => str_random(10),
]; // ];
}); // });
"); // ");
$I->wantTo('generate model factories with fields'); // $I->wantTo('generate model factories with fields');
$I->runShellCommand('php artisan wn:factory "App\Task" --fields="title:sentence(3),description:paragraph(3),due:date,hidden:boolean"'); // $I->runShellCommand('php artisan wn:factory "App\Task" --fields="title:sentence(3),description:paragraph(3),due:date,hidden:boolean"');
$I->seeInShellOutput('App\Task factory generated'); // $I->seeInShellOutput('App\Task factory generated');
$I->openFile('./database/factories/ModelFactory.php'); // $I->openFile('./database/factories/ModelFactory.php');
$I->seeInThisFile(" // $I->seeInThisFile("
'title' => \$faker->sentence(3), // 'title' => \$faker->sentence(3),
'description' => \$faker->paragraph(3), // 'description' => \$faker->paragraph(3),
'due' => \$faker->date, // 'due' => \$faker->date,
'hidden' => \$faker->boolean, // 'hidden' => \$faker->boolean,
"); // ");
$I->writeToFile('./database/factories/ModelFactory.php', "<?php // $I->writeToFile('./database/factories/ModelFactory.php', "<?php
/* // /*
|-------------------------------------------------------------------------- // |--------------------------------------------------------------------------
| Model Factories // | Model Factories
|-------------------------------------------------------------------------- // |--------------------------------------------------------------------------
| // |
| Here you may define all of your model factories. Model factories give // | Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your // | you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look. // | 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,
'email' => \$faker->email, // 'email' => \$faker->email,
'password' => str_random(10), // 'password' => str_random(10),
'remember_token' => str_random(10), // 'remember_token' => str_random(10),
]; // ];
}); // });
"); // ");

View File

@ -105,37 +105,37 @@ $app->get("/", function () use ($app) {
'); ');
// Checking model factory // Checking model factory
$I->openFile('./database/factories/ModelFactory.php'); // $I->openFile('./database/factories/ModelFactory.php');
$I->seeInThisFile(" // $I->seeInThisFile("
/** // /**
* Factory definition for model App\TaskCategory. // * Factory definition for model App\TaskCategory.
*/ // */
\$factory->define(App\TaskCategory::class, function (\$faker) { // \$factory->define(App\TaskCategory::class, function (\$faker) {
return [ // return [
'name' => \$faker->word, // 'name' => \$faker->word,
'descr' => \$faker->paragraph, // 'descr' => \$faker->paragraph,
'due' => \$faker->date, // 'due' => \$faker->date,
]; // ];
});"); // });");
$I->writeToFile('./database/factories/ModelFactory.php', "<?php // $I->writeToFile('./database/factories/ModelFactory.php', "<?php
/* // /*
|-------------------------------------------------------------------------- // |--------------------------------------------------------------------------
| Model Factories // | Model Factories
|-------------------------------------------------------------------------- // |--------------------------------------------------------------------------
| // |
| Here you may define all of your model factories. Model factories give // | Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your // | you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look. // | 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,
'email' => \$faker->email, // 'email' => \$faker->email,
'password' => str_random(10), // 'password' => str_random(10),
'remember_token' => str_random(10), // 'remember_token' => str_random(10),
]; // ];
}); // });
"); // ");

View File

@ -61,11 +61,11 @@ class ResourceCommand extends BaseCommand {
]); ]);
// generating model factory // generating model factory
$this->call('wn:factory', [ // $this->call('wn:factory', [
'model' => 'App\\' . $modelName, // 'model' => 'App\\' . $modelName,
'--fields' => $this->factoryFields(), // '--fields' => $this->factoryFields(),
'--parsed' => true // '--parsed' => true
]); // ]);
} }