更新代码
This commit is contained in:
0
vendor/xethron/laravel-4-generators/tests/.gitkeep
vendored
Normal file
0
vendor/xethron/laravel-4-generators/tests/.gitkeep
vendored
Normal file
154
vendor/xethron/laravel-4-generators/tests/features/bootstrap/FeatureContext.php
vendored
Normal file
154
vendor/xethron/laravel-4-generators/tests/features/bootstrap/FeatureContext.php
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
use Behat\Behat\Context\ClosuredContextInterface,
|
||||
Behat\Behat\Context\TranslatedContextInterface,
|
||||
Behat\Behat\Context\BehatContext,
|
||||
Behat\Behat\Exception\PendingException;
|
||||
use Behat\Gherkin\Node\PyStringNode,
|
||||
Behat\Gherkin\Node\TableNode;
|
||||
use Behat\MinkExtension\Context\MinkContext;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Symfony\Component\Console\Application;
|
||||
|
||||
require_once __DIR__.'/../../../vendor/phpunit/phpunit/PHPUnit/Framework/Assert/Functions.php';
|
||||
|
||||
/**
|
||||
* Features context.
|
||||
*/
|
||||
class FeatureContext extends BehatContext
|
||||
{
|
||||
/**
|
||||
* The command that we're testing
|
||||
*
|
||||
* @var CommandTester
|
||||
*/
|
||||
protected $tester;
|
||||
|
||||
/**
|
||||
* @beforeSuite
|
||||
*/
|
||||
public static function bootstrapLaravel()
|
||||
{
|
||||
require __DIR__.'/../../../../../../vendor/autoload.php';
|
||||
require __DIR__.'/../../../../../../bootstrap/start.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @AfterScenario
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
\Illuminate\Support\Facades\File::deleteDirectory(base_path('workbench/way/generators/tests/tmp'), true);
|
||||
|
||||
$this->tester = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^I generate a migration with name \'([^\']*)\' and fields \'([^\']*)\'$/
|
||||
*/
|
||||
public function iGenerateAMigrationWithNameAndFields($migrationName, $fields)
|
||||
{
|
||||
$this->tester = new CommandTester(App::make('Way\Generators\Commands\MigrationGeneratorCommand'));
|
||||
|
||||
$this->tester->execute([
|
||||
'migrationName' => $migrationName,
|
||||
'--fields' => $fields,
|
||||
'--testing' => true,
|
||||
'--path' => __DIR__.'/../../tmp',
|
||||
'--templatePath' => __DIR__.'/../../../src/Way/Generators/templates/migration.txt'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^I generate a model with "([^"]*)"$/
|
||||
*/
|
||||
public function iGenerateAModelWith($modelName)
|
||||
{
|
||||
$this->tester = new CommandTester(App::make('Way\Generators\Commands\ModelGeneratorCommand'));
|
||||
|
||||
$this->tester->execute([
|
||||
'modelName' => $modelName,
|
||||
'--path' => __DIR__.'/../../tmp',
|
||||
'--templatePath' => __DIR__.'/../../../src/Way/Generators/templates/model.txt'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^I generate a controller with "([^"]*)"$/
|
||||
*/
|
||||
public function iGenerateAControllerWith($controllerName)
|
||||
{
|
||||
$this->tester = new CommandTester(App::make('Way\Generators\Commands\ControllerGeneratorCommand'));
|
||||
|
||||
$this->tester->execute([
|
||||
'controllerName' => $controllerName,
|
||||
'--path' => __DIR__.'/../../tmp',
|
||||
'--templatePath' => __DIR__.'/../../../src/Way/Generators/templates/controller.txt'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^I generate a view with "([^"]*)"$/
|
||||
*/
|
||||
public function iGenerateAViewWith($viewName)
|
||||
{
|
||||
$this->tester = new CommandTester(App::make('Way\Generators\Commands\ViewGeneratorCommand'));
|
||||
|
||||
$this->tester->execute([
|
||||
'viewName' => $viewName,
|
||||
'--path' => __DIR__.'/../../tmp',
|
||||
'--templatePath' => __DIR__.'/../../../src/Way/Generators/templates/view.txt'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^I generate a seed with "([^"]*)"$/
|
||||
*/
|
||||
public function iGenerateASeedWith($tableName)
|
||||
{
|
||||
$this->tester = new CommandTester(App::make('Way\Generators\Commands\SeederGeneratorCommand'));
|
||||
|
||||
$this->tester->execute([
|
||||
'tableName' => $tableName,
|
||||
'--path' => __DIR__.'/../../tmp',
|
||||
'--templatePath' => __DIR__.'/../../../src/Way/Generators/templates/seed.txt'
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^the generated migration should match my \'([^\']*)\' stub$/
|
||||
*/
|
||||
public function theGeneratedMigrationShouldMatchMyStub($stubName)
|
||||
{
|
||||
$expected = file_get_contents(__DIR__."/../../stubs/{$stubName}.txt");
|
||||
$actual = file_get_contents(glob(__DIR__."/../../tmp/*")[0]);
|
||||
|
||||
// Let's compare the stub against what was actually generated.
|
||||
assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^I should see "([^"]*)"$/
|
||||
*/
|
||||
public function iShouldSee($output)
|
||||
{
|
||||
assertContains($output, $this->tester->getDisplay());
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^"([^"]*)" should match my stub$/
|
||||
*/
|
||||
public function shouldMatchMyStub($generatedFilePath)
|
||||
{
|
||||
// We'll use the name of the generated file as
|
||||
// the basic for our stub lookup.
|
||||
$stubName = pathinfo($generatedFilePath)['filename'];
|
||||
|
||||
$expected = file_get_contents(__DIR__."/../../stubs/{$stubName}.txt");
|
||||
$actual = file_get_contents(base_path($generatedFilePath));
|
||||
|
||||
// Let's compare the stub against what was actually generated.
|
||||
assertEquals($expected, $actual);
|
||||
}
|
||||
}
|
||||
13
vendor/xethron/laravel-4-generators/tests/features/generators.feature
vendored
Normal file
13
vendor/xethron/laravel-4-generators/tests/features/generators.feature
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
Feature: Generators
|
||||
|
||||
Scenario Outline: Generation
|
||||
When I generate a <command> with "<argument>"
|
||||
Then I should see "Created:"
|
||||
And "<generatedFilePath>" should match my stub
|
||||
|
||||
Examples:
|
||||
| command | argument | generatedFilePath |
|
||||
| model | Order | workbench/way/generators/tests/tmp/Order.php |
|
||||
| seed | recent_orders | workbench/way/generators/tests/tmp/RecentOrdersTableSeeder.php |
|
||||
| controller | OrdersController | workbench/way/generators/tests/tmp/OrdersController.php |
|
||||
| view | orders.bar.index | workbench/way/generators/tests/tmp/orders/bar/index.blade.php |
|
||||
26
vendor/xethron/laravel-4-generators/tests/features/migrations.feature
vendored
Normal file
26
vendor/xethron/laravel-4-generators/tests/features/migrations.feature
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
Feature: Migrations With Schema
|
||||
|
||||
Scenario: Creating a Table
|
||||
When I generate a migration with name 'create_orders_table' and fields 'name:string'
|
||||
Then I should see "Created:"
|
||||
And the generated migration should match my 'CreateOrdersTable' stub
|
||||
|
||||
Scenario: Creating a Table With Complex Fields
|
||||
When I generate a migration with name 'create_orders_table' and fields 'title:string(50):unique, body:text:unique:nullable'
|
||||
Then I should see "Created:"
|
||||
And the generated migration should match my 'CreateComplexOrdersTable' stub
|
||||
|
||||
Scenario: Dropping a Table
|
||||
When I generate a migration with name 'drop_orders_table' and fields 'title:string'
|
||||
Then I should see "Created:"
|
||||
And the generated migration should match my 'DropOrdersTable' stub
|
||||
|
||||
Scenario: Adding to a Table
|
||||
When I generate a migration with name 'add_title_to_orders_table' and fields 'title:string'
|
||||
Then I should see "Created:"
|
||||
And the generated migration should match my 'AddTitleToOrdersTable' stub
|
||||
|
||||
Scenario: Removing from a Table
|
||||
When I generate a migration with name 'remove_title_from_orders_table' and fields 'title:string'
|
||||
Then I should see "Created:"
|
||||
And the generated migration should match my 'RemoveTitleFromOrdersTable' stub
|
||||
35
vendor/xethron/laravel-4-generators/tests/stubs/AddTitleToOrdersTable.txt
vendored
Normal file
35
vendor/xethron/laravel-4-generators/tests/stubs/AddTitleToOrdersTable.txt
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class AddTitleToOrdersTable extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('orders', function(Blueprint $table)
|
||||
{
|
||||
$table->string('title');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('orders', function(Blueprint $table)
|
||||
{
|
||||
$table->dropColumn('title');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
35
vendor/xethron/laravel-4-generators/tests/stubs/CreateComplexOrdersTable.txt
vendored
Normal file
35
vendor/xethron/laravel-4-generators/tests/stubs/CreateComplexOrdersTable.txt
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateOrdersTable extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('orders', function(Blueprint $table)
|
||||
{
|
||||
$table->increments('id');
|
||||
$table->string('title', 50)->unique();
|
||||
$table->text('body')->unique()->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('orders');
|
||||
}
|
||||
|
||||
}
|
||||
34
vendor/xethron/laravel-4-generators/tests/stubs/CreateOrdersTable.txt
vendored
Normal file
34
vendor/xethron/laravel-4-generators/tests/stubs/CreateOrdersTable.txt
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateOrdersTable extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('orders', function(Blueprint $table)
|
||||
{
|
||||
$table->increments('id');
|
||||
$table->string('name');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('orders');
|
||||
}
|
||||
|
||||
}
|
||||
34
vendor/xethron/laravel-4-generators/tests/stubs/DropOrdersTable.txt
vendored
Normal file
34
vendor/xethron/laravel-4-generators/tests/stubs/DropOrdersTable.txt
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class DropOrdersTable extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::drop('orders');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::create('orders', function(Blueprint $table)
|
||||
{
|
||||
$table->increments('id');
|
||||
$table->string('title');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
9
vendor/xethron/laravel-4-generators/tests/stubs/Order.txt
vendored
Normal file
9
vendor/xethron/laravel-4-generators/tests/stubs/Order.txt
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Order extends Model {
|
||||
|
||||
protected $fillable = [];
|
||||
|
||||
}
|
||||
88
vendor/xethron/laravel-4-generators/tests/stubs/OrdersController.txt
vendored
Normal file
88
vendor/xethron/laravel-4-generators/tests/stubs/OrdersController.txt
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
class OrdersController extends Controller {
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* GET /orders
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* GET /orders/create
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* POST /orders
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function store()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
* GET /orders/{id}
|
||||
*
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
* GET /orders/{id}/edit
|
||||
*
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
* PUT /orders/{id}
|
||||
*
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function update($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* DELETE /orders/{id}
|
||||
*
|
||||
* @param int $id
|
||||
* @return Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
}
|
||||
21
vendor/xethron/laravel-4-generators/tests/stubs/RecentOrdersTableSeeder.txt
vendored
Normal file
21
vendor/xethron/laravel-4-generators/tests/stubs/RecentOrdersTableSeeder.txt
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
// Composer: "fzaninotto/faker": "v1.4.0"
|
||||
use Faker\Factory as Faker;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class RecentOrdersTableSeeder extends Seeder {
|
||||
|
||||
public function run()
|
||||
{
|
||||
$faker = Faker::create();
|
||||
|
||||
foreach(range(1, 10) as $index)
|
||||
{
|
||||
RecentOrder::create([
|
||||
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
35
vendor/xethron/laravel-4-generators/tests/stubs/RemoveTitleFromOrdersTable.txt
vendored
Normal file
35
vendor/xethron/laravel-4-generators/tests/stubs/RemoveTitleFromOrdersTable.txt
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class RemoveTitleFromOrdersTable extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('orders', function(Blueprint $table)
|
||||
{
|
||||
$table->dropColumn('title');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('orders', function(Blueprint $table)
|
||||
{
|
||||
$table->string('title');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
1
vendor/xethron/laravel-4-generators/tests/stubs/index.blade.txt
vendored
Normal file
1
vendor/xethron/laravel-4-generators/tests/stubs/index.blade.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/Users/jeffreyway/code/open-source/generators/workbench/way/generators/tests/features/bootstrap/../../tmp/orders/bar/index.blade.php
|
||||
Reference in New Issue
Block a user