Skip to content

Commit

Permalink
Fix table seeder underscore issue - closes #329
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyWay committed May 27, 2014
1 parent ddb9363 commit 484d379
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
13 changes: 11 additions & 2 deletions src/Way/Generators/Commands/SeederGeneratorCommand.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php namespace Way\Generators\Commands;

use Illuminate\Support\Str;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Config;
Expand Down Expand Up @@ -28,7 +29,7 @@ class SeederGeneratorCommand extends GeneratorCommand {
protected function getFileGenerationPath()
{
$path = $this->getPathByOptionOrConfig('path', 'seed_target_path');
$tableName = ucwords($this->argument('tableName'));
$tableName = $this->getTableName();

return "{$path}/{$tableName}TableSeeder.php";
}
Expand All @@ -40,7 +41,7 @@ protected function getFileGenerationPath()
*/
protected function getTemplateData()
{
$tableName = ucwords($this->argument('tableName'));
$tableName = $this->getTableName();

return [
'CLASS' => "{$tableName}TableSeeder",
Expand Down Expand Up @@ -70,4 +71,12 @@ protected function getArguments()
);
}

/**
* Format the table name
*/
protected function getTableName()
{
return Str::studly($this->argument('tableName'));
}

}
10 changes: 5 additions & 5 deletions tests/features/generators.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +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 |
| controller | OrdersController | workbench/way/generators/tests/tmp/OrdersController.php |
| view | orders.bar.index | workbench/way/generators/tests/tmp/orders/bar/index.blade.php |
| 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 |
4 changes: 2 additions & 2 deletions tests/stubs/RecentOrdersTableSeeder.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
// Composer: "fzaninotto/faker": "v1.3.0"
use Faker\Factory as Faker;

class OrdersTableSeeder extends Seeder {
class RecentOrdersTableSeeder extends Seeder {

public function run()
{
$faker = Faker::create();

foreach(range(1, 10) as $index)
{
Order::create([
RecentOrder::create([

]);
}
Expand Down

0 comments on commit 484d379

Please sign in to comment.