commit
fe81e2de80
84
tests/Feature/Settings/CategoriesTest.php
Normal file
84
tests/Feature/Settings/CategoriesTest.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Settings;
|
||||
|
||||
use App\Models\Setting\Category;
|
||||
use Tests\Feature\FeatureTestCase;
|
||||
|
||||
class CategoriesTest extends FeatureTestCase
|
||||
{
|
||||
public function testItShouldSeeCategoryListPage()
|
||||
{
|
||||
$this->loginAs()
|
||||
->get(route('categories.index'))
|
||||
->assertStatus(200)
|
||||
->assertSeeText(trans_choice('general.categories', 2));
|
||||
}
|
||||
|
||||
public function testItShouldSeeCategoryCreatePage()
|
||||
{
|
||||
$this->loginAs()
|
||||
->get(route('categories.create'))
|
||||
->assertStatus(200)
|
||||
->assertSeeText(trans('general.title.new', ['type' => trans_choice('general.categories', 1)]));
|
||||
}
|
||||
|
||||
public function testItShouldCreateCategory()
|
||||
{
|
||||
$this->loginAs()
|
||||
->post(route('categories.store'), $this->getCategoryRequest())
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('categories.index'));
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
}
|
||||
|
||||
public function testItShouldSeeCategoryUpdatePage()
|
||||
{
|
||||
$category = Category::create($this->getCategoryRequest());
|
||||
|
||||
$this->loginAs()
|
||||
->get(route('categories.edit', ['category' => $category->id]))
|
||||
->assertStatus(200)
|
||||
->assertSee($category->name);
|
||||
}
|
||||
|
||||
public function testItShouldUpdateCategory()
|
||||
{
|
||||
$request = $this->getCategoryRequest();
|
||||
|
||||
$category = Category::create($request);
|
||||
|
||||
$request['name'] = $this->faker->text(15);
|
||||
|
||||
$this->loginAs()
|
||||
->patch(route('categories.update', $category->id), $request)
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('categories.index'));
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
}
|
||||
|
||||
public function testItShouldDeleteCategory()
|
||||
{
|
||||
$category = Category::create($this->getCategoryRequest());
|
||||
|
||||
$this->loginAs()
|
||||
->delete(route('categories.destroy', $category->id))
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('categories.index'));
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
}
|
||||
|
||||
private function getCategoryRequest()
|
||||
{
|
||||
return [
|
||||
'company_id' => $this->company->id,
|
||||
'name' => $this->faker->text(15),
|
||||
'type' => 'other',
|
||||
'color' => $this->faker->text(15),
|
||||
'enabled' => $this->faker->boolean ? 1 : 0
|
||||
];
|
||||
}
|
||||
}
|
83
tests/Feature/Settings/CurrenciesTest.php
Normal file
83
tests/Feature/Settings/CurrenciesTest.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Settings;
|
||||
|
||||
use App\Models\Setting\Currency;
|
||||
use Tests\Feature\FeatureTestCase;
|
||||
|
||||
class CurrenciesTest extends FeatureTestCase
|
||||
{
|
||||
|
||||
public function testItShouldSeeCurrencyListPage()
|
||||
{
|
||||
$this->loginAs()
|
||||
->get(route('currencies.index'))
|
||||
->assertStatus(200)
|
||||
->assertSeeText(trans_choice('general.currencies', 2));
|
||||
}
|
||||
|
||||
public function testItShouldSeeCurrencyCreatePage()
|
||||
{
|
||||
$this->loginAs()
|
||||
->get(route('currencies.create'))
|
||||
->assertStatus(200)
|
||||
->assertSeeText(trans('general.title.new', ['type' => trans_choice('general.currencies', 1)]));
|
||||
}
|
||||
|
||||
public function testItShouldCreateCurrency()
|
||||
{
|
||||
$this->loginAs()
|
||||
->post(route('currencies.store'), $this->getCurrencyRequest())
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('currencies.index'));
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
}
|
||||
|
||||
public function testItShouldUpdateCurrency()
|
||||
{
|
||||
$request = $this->getCurrencyRequest();
|
||||
|
||||
$currency = Currency::create($request);
|
||||
|
||||
$request['name'] = $this->faker->text(15);
|
||||
|
||||
$this->loginAs()
|
||||
->patch(route('currencies.update', $currency->id), $request)
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('currencies.index'));
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
}
|
||||
|
||||
public function testItShouldDeleteCurrency()
|
||||
{
|
||||
$currency = Currency::create($this->getCurrencyRequest());
|
||||
|
||||
$this->loginAs()
|
||||
->delete(route('currencies.destroy', $currency->id))
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('currencies.index'));
|
||||
|
||||
$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' => $this->faker->boolean ? 1 : 0
|
||||
];
|
||||
}
|
||||
}
|
73
tests/Feature/Settings/TaxesTest.php
Normal file
73
tests/Feature/Settings/TaxesTest.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Settings;
|
||||
|
||||
use App\Models\Setting\Tax;
|
||||
use Tests\Feature\FeatureTestCase;
|
||||
|
||||
class TaxesTest extends FeatureTestCase
|
||||
{
|
||||
public function testItShouldSeeTaxListPage()
|
||||
{
|
||||
$this->loginAs()
|
||||
->get(route('taxes.index'))
|
||||
->assertStatus(200)
|
||||
->assertSeeText(trans_choice('general.tax_rates', 2));
|
||||
}
|
||||
|
||||
public function testItShouldSeeTaxCreatePage()
|
||||
{
|
||||
$this->loginAs()
|
||||
->get(route('taxes.create'))
|
||||
->assertStatus(200)
|
||||
->assertSeeText(trans('general.title.new', ['type' => trans_choice('general.taxes', 1)]));
|
||||
}
|
||||
|
||||
public function testItShouldCreateTax()
|
||||
{
|
||||
$this->loginAs()
|
||||
->post(route('taxes.store'), $this->getTaxRequest())
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('taxes.index'));
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
}
|
||||
|
||||
public function testItShouldUpdateTax()
|
||||
{
|
||||
$request = $this->getTaxRequest();
|
||||
|
||||
$tax = Tax::create($request);
|
||||
|
||||
$request['name'] = $this->faker->text(15);
|
||||
|
||||
$this->loginAs()
|
||||
->patch(route('taxes.update', $tax->id), $request)
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('taxes.index'));
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
}
|
||||
|
||||
public function testItShouldDeleteTax()
|
||||
{
|
||||
$tax = Tax::create($this->getTaxRequest());
|
||||
|
||||
$this->loginAs()
|
||||
->delete(route('taxes.destroy', $tax->id))
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('taxes.index'));
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
}
|
||||
|
||||
private function getTaxRequest()
|
||||
{
|
||||
return [
|
||||
'company_id' => $this->company->id,
|
||||
'name' => $this->faker->text(15),
|
||||
'rate' => $this->faker->randomFloat(2, 10, 20),
|
||||
'enabled' => $this->faker->boolean ? 1 : 0
|
||||
];
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user