2016-12-29 16:35:34 +01:00
|
|
|
<?php
|
2015-09-26 02:43:35 +01:00
|
|
|
$I = new AcceptanceTester($scenario);
|
|
|
|
|
|
|
|
$I->wantTo('generate a migration without schema');
|
2015-09-26 22:43:06 +01:00
|
|
|
$I->runShellCommand('php artisan wn:migration tasks --file=create_tasks');
|
2015-09-26 02:43:35 +01:00
|
|
|
$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;
|
|
|
|
|
2015-10-07 17:49:26 +01:00
|
|
|
class CreateTasksTable extends Migration
|
2015-09-26 02:43:35 +01:00
|
|
|
{
|
2016-12-29 16:35:34 +01:00
|
|
|
|
2015-09-26 02:43:35 +01:00
|
|
|
public function up()
|
|
|
|
{
|
|
|
|
Schema::create(\'tasks\', function(Blueprint $table) {
|
|
|
|
$table->increments(\'id\');
|
2015-09-26 22:43:06 +01:00
|
|
|
// Schema declaration
|
|
|
|
// Constraints declaration
|
2015-09-26 02:43:35 +01:00
|
|
|
$table->timestamps();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function down()
|
|
|
|
{
|
|
|
|
Schema::drop(\'tasks\');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
');
|
|
|
|
$I->deleteFile('./database/migrations/create_tasks.php');
|
|
|
|
|
2015-09-26 22:43:06 +01:00
|
|
|
$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"');
|
2015-09-26 02:43:35 +01:00
|
|
|
$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;
|
|
|
|
|
2015-10-07 17:49:26 +01:00
|
|
|
class CreateTasksTable extends Migration
|
2015-09-26 02:43:35 +01:00
|
|
|
{
|
2016-12-29 16:35:34 +01:00
|
|
|
|
2015-09-26 02:43:35 +01:00
|
|
|
public function up()
|
|
|
|
{
|
|
|
|
Schema::create(\'tasks\', function(Blueprint $table) {
|
|
|
|
$table->increments(\'id\');
|
2015-09-26 22:43:06 +01:00
|
|
|
$table->decimal(\'amount\', 5, 2)->after(\'size\')->default(8);
|
|
|
|
$table->string(\'title\')->nullable();
|
|
|
|
// Constraints declaration
|
2015-09-26 02:43:35 +01:00
|
|
|
$table->timestamps();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function down()
|
|
|
|
{
|
|
|
|
Schema::drop(\'tasks\');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
');
|
2015-09-26 22:43:06 +01:00
|
|
|
$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\');');
|
2016-12-29 16:35:34 +01:00
|
|
|
$I->seeInThisFile("\$table->foreign('user_id')
|
|
|
|
->references('identifier')
|
|
|
|
->on('members')
|
|
|
|
->onDelete('cascade');");
|
2015-09-26 02:43:35 +01:00
|
|
|
$I->deleteFile('./database/migrations/create_tasks.php');
|