Deleting problem of currencies at wizard step is fixed. It also solves issue #934

Feature tests are added.
This commit is contained in:
Sevan Nerse 2019-12-12 00:04:07 +03:00
parent e1b2c74b44
commit 0051f43c67
3 changed files with 91 additions and 20 deletions

View File

@ -76,7 +76,7 @@ class Roles extends Seeder
'settings-schedule' => 'r',
'settings-taxes' => 'c,r,u,d',
'wizard-companies' => 'c,r,u',
'wizard-currencies' => 'c,r,u',
'wizard-currencies' => 'c,r,u,d',
'wizard-finish' => 'c,r,u',
'wizard-taxes' => 'c,r,u',
],

View File

@ -5,7 +5,7 @@ Route::group(['as' => 'wizard.'], function () {
Route::patch('companies', 'Wizard\Companies@update')->name('companies.update');
Route::get('currencies', 'Wizard\Currencies@index')->name('currencies.index');
Route::get('currencies/{currency}/delete', 'Wizard\Currencies@destroy')->name('currencies.delete');
Route::delete('currencies/{currency}', 'Wizard\Currencies@destroy')->name('currencies.delete');
Route::post('currencies', 'Wizard\Currencies@store')->name('currencies.store');
Route::patch('currencies/{currency}', 'Wizard\Currencies@update')->name('currencies.update');
@ -16,3 +16,4 @@ Route::group(['as' => 'wizard.'], function () {
Route::get('finish', 'Wizard\Finish@index')->name('finish.index');
});

View File

@ -0,0 +1,70 @@
<?php
namespace Tests\Feature\Wizard;
use App\Jobs\Setting\CreateCurrency;
use Tests\Feature\FeatureTestCase;
class CurrenciesTest extends FeatureTestCase
{
public function testItShouldSeeCurrencyListPage()
{
$this->loginAs()
->get(route('wizard.currencies.index'))
->assertStatus(200)
->assertSeeText(trans_choice('general.currencies', 2));
}
public function testItShouldCreateCurrency()
{
$this->loginAs()
->post(route('wizard.currencies.store'), $this->getCurrencyRequest())
->assertStatus(200);
$this->assertFlashLevel('success');
}
public function testItShouldUpdateCurrency()
{
$request = $this->getCurrencyRequest();
$currency = $this->dispatch(new CreateCurrency($request));
$request['name'] = $this->faker->text(15);
$this->loginAs()
->patch(route('wizard.currencies.update', $currency->id), $request)
->assertStatus(200);
$this->assertFlashLevel('success');
}
public function testItShouldDeleteCurrency()
{
$currency = $this->dispatch(new CreateCurrency($this->getCurrencyRequest()));
$this->loginAs()
->delete(route('wizard.currencies.delete', $currency->id))
->assertStatus(200);
$this->assertFlashLevel('success');
}
private function getCurrencyRequest()
{
return [
'company_id' => $this->company->id,
'name' => $this->faker->text(15),
'code' => $this->faker->text(strtoupper(5)),
'rate' => $this->faker->boolean(1),
'precision' => $this->faker->text(5),
'symbol' => $this->faker->text(5),
'symbol_first' => 1,
'symbol_position' => 'after_amount',
'decimal_mark' => $this->faker->text(5),
'thousands_separator' => $this->faker->text(5),
'enabled' => $this->faker->boolean ? 1 : 0,
'default_currency' => 0
];
}
}