akaunting/tests/Feature/Settings/CurrenciesTest.php

67 lines
1.7 KiB
PHP
Raw Normal View History

2018-10-04 16:53:16 +03:00
<?php
namespace Tests\Feature\Settings;
2019-11-17 15:06:00 +03:00
use App\Jobs\Setting\CreateCurrency;
2020-01-13 02:56:14 +03:00
use App\Models\Setting\Currency;
2018-10-04 16:53:16 +03:00
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()
2020-01-13 02:56:14 +03:00
->post(route('currencies.store'), $this->getRequest())
2019-11-16 10:21:14 +03:00
->assertStatus(200);
2018-10-04 16:53:16 +03:00
$this->assertFlashLevel('success');
}
public function testItShouldUpdateCurrency()
{
2020-01-13 02:56:14 +03:00
$request = $this->getRequest();
2018-10-04 16:53:16 +03:00
2019-11-17 15:06:00 +03:00
$currency = $this->dispatch(new CreateCurrency($request));
2018-10-04 16:53:16 +03:00
$request['name'] = $this->faker->text(15);
$this->loginAs()
->patch(route('currencies.update', $currency->id), $request)
2019-11-16 10:21:14 +03:00
->assertStatus(200);
2018-10-04 16:53:16 +03:00
$this->assertFlashLevel('success');
}
public function testItShouldDeleteCurrency()
{
2020-01-13 02:56:14 +03:00
$currency = $this->dispatch(new CreateCurrency($this->getRequest()));
2018-10-04 16:53:16 +03:00
$this->loginAs()
->delete(route('currencies.destroy', $currency->id))
2019-11-16 10:21:14 +03:00
->assertStatus(200);
2018-10-04 16:53:16 +03:00
$this->assertFlashLevel('success');
}
2020-01-13 02:56:14 +03:00
public function getRequest()
2018-10-04 16:53:16 +03:00
{
2020-01-13 02:56:14 +03:00
return factory(Currency::class)->states('enabled')->raw();
2018-10-04 16:53:16 +03:00
}
2019-04-02 18:51:06 +03:00
}