From 484d379c6bc1d38c75e4f52f74efcbcd11f7dd2c Mon Sep 17 00:00:00 2001 From: Jeffrey Way Date: Tue, 27 May 2014 10:20:44 -0400 Subject: [PATCH] Fix table seeder underscore issue - closes #329 --- .../Generators/Commands/SeederGeneratorCommand.php | 13 +++++++++++-- tests/features/generators.feature | 10 +++++----- tests/stubs/RecentOrdersTableSeeder.txt | 4 ++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/Way/Generators/Commands/SeederGeneratorCommand.php b/src/Way/Generators/Commands/SeederGeneratorCommand.php index 39959c7a..281770f6 100644 --- a/src/Way/Generators/Commands/SeederGeneratorCommand.php +++ b/src/Way/Generators/Commands/SeederGeneratorCommand.php @@ -1,5 +1,6 @@ getPathByOptionOrConfig('path', 'seed_target_path'); - $tableName = ucwords($this->argument('tableName')); + $tableName = $this->getTableName(); return "{$path}/{$tableName}TableSeeder.php"; } @@ -40,7 +41,7 @@ protected function getFileGenerationPath() */ protected function getTemplateData() { - $tableName = ucwords($this->argument('tableName')); + $tableName = $this->getTableName(); return [ 'CLASS' => "{$tableName}TableSeeder", @@ -70,4 +71,12 @@ protected function getArguments() ); } + /** + * Format the table name + */ + protected function getTableName() + { + return Str::studly($this->argument('tableName')); + } + } diff --git a/tests/features/generators.feature b/tests/features/generators.feature index d1ff0cd0..1dc6ebaa 100644 --- a/tests/features/generators.feature +++ b/tests/features/generators.feature @@ -6,8 +6,8 @@ Feature: Generators And "" 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 | diff --git a/tests/stubs/RecentOrdersTableSeeder.txt b/tests/stubs/RecentOrdersTableSeeder.txt index fb106863..c9938278 100644 --- a/tests/stubs/RecentOrdersTableSeeder.txt +++ b/tests/stubs/RecentOrdersTableSeeder.txt @@ -3,7 +3,7 @@ // Composer: "fzaninotto/faker": "v1.3.0" use Faker\Factory as Faker; -class OrdersTableSeeder extends Seeder { +class RecentOrdersTableSeeder extends Seeder { public function run() { @@ -11,7 +11,7 @@ class OrdersTableSeeder extends Seeder { foreach(range(1, 10) as $index) { - Order::create([ + RecentOrder::create([ ]); }