Skip to content

Commit

Permalink
Update TableCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
ycs77 committed Oct 14, 2019
1 parent ca2aa70 commit c56fb17
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 18 deletions.
2 changes: 1 addition & 1 deletion config/wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@
|
*/

'table' => 'wizard',
'table' => 'wizards',

];
12 changes: 12 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,18 @@ Or use yarn:
yarn add bootstrap-steps
```

## Cache Driver

### Database

In order to use the `database` wizard cache driver, you will need a database table to hold the wizards cache data. To generate a migration that creates this table, run the `wizard:table` Artisan command:

```
php artisan wizard:table
php artisan migrate
```

## Advanced

### Override wizard configuration on wizard controller
Expand Down
6 changes: 3 additions & 3 deletions src/Console/TableCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class TableCommand extends Command
protected $composer;

/**
* Create a new queue job table command instance.
* Create a new wizard table command instance.
*
* @param \Illuminate\Filesystem\Filesystem $files
* @param \Illuminate\Support\Composer $composer
Expand Down Expand Up @@ -76,7 +76,7 @@ public function handle()
* @param string $table
* @return string
*/
protected function createBaseMigration($table = 'jobs')
protected function createBaseMigration($table = 'wizards')
{
return $this->laravel['migration.creator']->create(
'create_' . $table . '_table',
Expand All @@ -85,7 +85,7 @@ protected function createBaseMigration($table = 'jobs')
}

/**
* Replace the generated migration with the job table stub.
* Replace the generated migration with the wizard table stub.
*
* @param string $path
* @param string $table
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/HttpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function testWizardCacheDatabaseDriver()
]);
$response->assertRedirect('/wizard/test/post-step-stub');

$this->assertDatabaseHas('wizard', [
$this->assertDatabaseHas('wizards', [
'payload' => '{"user-step-stub":{"name":"John"},"_last_index":1}',
'user_id' => 1,
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function up()
$table->timestamps();
});

Schema::create('wizard', function (Blueprint $table) {
Schema::create('wizards', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('user_id')->nullable();
$table->ipAddress('ip_address')->nullable();
Expand All @@ -46,7 +46,7 @@ public function up()
*/
public function down()
{
Schema::dropIfExists('wizard');
Schema::dropIfExists('wizards');
Schema::dropIfExists('posts');
Schema::dropIfExists('users');
}
Expand Down
22 changes: 11 additions & 11 deletions tests/Unit/DatabaseStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function testGetAllData()

// arrange
$expected = ['step' => ['field' => 'data']];
$this->app['db']->table('wizard')->insert([
$this->app['db']->table('wizards')->insert([
'payload' => '{"step":{"field":"data"}}',
'user_id' => 1,
]);
Expand All @@ -64,7 +64,7 @@ public function testGetAllDataFromIpAddress()
{
// arrange
$expected = ['step' => ['field' => 'data']];
$this->app['db']->table('wizard')->insert([
$this->app['db']->table('wizards')->insert([
'payload' => '{"step":{"field":"data"}}',
'ip_address' => '127.0.0.1',
]);
Expand All @@ -82,7 +82,7 @@ public function testGetStepData()

// arrange
$expected = ['field' => 'data'];
$this->app['db']->table('wizard')->insert([
$this->app['db']->table('wizards')->insert([
'payload' => '{"step":{"field":"data"}}',
'user_id' => 1,
]);
Expand All @@ -100,7 +100,7 @@ public function testGetFieldData()

// arrange
$expected = 'data';
$this->app['db']->table('wizard')->insert([
$this->app['db']->table('wizards')->insert([
'payload' => '{"step":{"field":"data"}}',
'user_id' => 1,
]);
Expand All @@ -117,7 +117,7 @@ public function testGetLastProcessedIndexData()
$this->authenticate();

// arrange
$this->app['db']->table('wizard')->insert([
$this->app['db']->table('wizards')->insert([
'payload' => '{"step":{"field":"data"},"_last_index":0}',
'user_id' => 1,
]);
Expand All @@ -137,7 +137,7 @@ public function testSetData()
$this->cache->set(['step' => ['field' => 'data']]);

// assert
$this->assertDatabaseHas('wizard', [
$this->assertDatabaseHas('wizards', [
'payload' => '{"step":{"field":"data"}}',
'user_id' => 1,
]);
Expand All @@ -151,7 +151,7 @@ public function testSetDataIncludeLastProcessed()
$this->cache->set(['step' => ['field' => 'data']], 1);

// assert
$this->assertDatabaseHas('wizard', [
$this->assertDatabaseHas('wizards', [
'payload' => '{"step":{"field":"data"},"_last_index":1}',
'user_id' => 1,
]);
Expand All @@ -165,7 +165,7 @@ public function testPutData()
$this->cache->put('step', ['field' => 'data']);

// assert
$this->assertDatabaseHas('wizard', [
$this->assertDatabaseHas('wizards', [
'payload' => '{"step":{"field":"data"}}',
'user_id' => 1,
]);
Expand All @@ -176,7 +176,7 @@ public function testCheckHasData()
$this->authenticate();

// arrange
$this->app['db']->table('wizard')->insert([
$this->app['db']->table('wizards')->insert([
'payload' => '{"step":{"field":"data"}}',
'user_id' => 1,
]);
Expand All @@ -193,7 +193,7 @@ public function testClearData()
$this->authenticate();

// arrange
$this->app['db']->table('wizard')->insert([
$this->app['db']->table('wizards')->insert([
'payload' => '{"step":{"field":"data"},"_last_index":1}',
'user_id' => 1,
]);
Expand All @@ -202,7 +202,7 @@ public function testClearData()
$this->cache->clear();

// assert
$this->assertDatabaseMissing('wizard',[
$this->assertDatabaseMissing('wizards',[
'payload' => '{"step":{"field":"data"},"_last_index":1}',
'user_id' => 1,
]);
Expand Down

0 comments on commit c56fb17

Please sign in to comment.