Skip to content

Commit

Permalink
Behat tests for controllers and views
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyWay committed Mar 7, 2014
1 parent 3025e5b commit 0b5ed61
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 3 deletions.
28 changes: 28 additions & 0 deletions tests/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,34 @@ public function iGenerateAModelWith($modelName)
]);
}

/**
* @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 "([^"]*)"$/
*/
Expand Down
8 changes: 5 additions & 3 deletions tests/features/generators.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Feature: Generators
And "<generatedFilePath>" should match my stub

Examples:
| command | argument | generatedFilePath |
| model | Order | workbench/way/generators/tests/tmp/Order.php |
| seed | orders | workbench/way/generators/tests/tmp/OrdersTableSeeder.php |
| command | argument | generatedFilePath |
| model | Order | workbench/way/generators/tests/tmp/Order.php |
| seed | orders | workbench/way/generators/tests/tmp/OrdersTableSeeder.php |
| controller | OrdersController | workbench/way/generators/tests/tmp/OrdersController.php |
| view | orders.bar.index | workbench/way/generators/tests/tmp/orders/bar/index.blade.php |
79 changes: 79 additions & 0 deletions tests/stubs/OrdersController.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php

class OrdersController extends \BaseController {

/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
//
}

/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
//
}

/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
//
}

/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
//
}

/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
//
}

/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
//
}

/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
//
}

}
1 change: 1 addition & 0 deletions tests/stubs/index.blade.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/Users/jeffreyway/code/open-source/generators/workbench/way/generators/tests/features/bootstrap/../../tmp/orders/bar/index.blade.php

0 comments on commit 0b5ed61

Please sign in to comment.