akaunting/tests/Feature/Sales/RevenuesTest.php

90 lines
2.3 KiB
PHP
Raw Normal View History

2018-10-09 14:18:12 +03:00
<?php
2019-12-31 15:49:09 +03:00
namespace Tests\Feature\Sales;
2018-10-09 14:18:12 +03:00
2019-11-17 15:06:00 +03:00
use App\Jobs\Banking\CreateTransaction;
2019-12-16 13:19:09 +03:00
use App\Models\Banking\Transaction;
2018-10-09 14:18:12 +03:00
use Tests\Feature\FeatureTestCase;
class RevenuesTest extends FeatureTestCase
{
public function testItShouldSeeRevenueListPage()
{
$this->loginAs()
->get(route('revenues.index'))
->assertStatus(200)
->assertSeeText(trans_choice('general.revenues', 2));
}
public function testItShouldSeeRevenueCreatePage()
{
$this->loginAs()
->get(route('revenues.create'))
->assertStatus(200)
->assertSeeText(trans('general.title.new', ['type' => trans_choice('general.revenues', 1)]));
}
public function testItShouldCreateRevenue()
{
2020-07-25 17:22:50 +03:00
$request = $this->getRequest();
2018-10-09 14:18:12 +03:00
$this->loginAs()
2020-07-25 17:22:50 +03:00
->post(route('revenues.store'), $request)
2019-11-16 10:21:14 +03:00
->assertStatus(200);
2018-10-09 14:18:12 +03:00
$this->assertFlashLevel('success');
2020-07-25 17:22:50 +03:00
$this->assertDatabaseHas('transactions', $request);
2018-10-09 14:18:12 +03:00
}
2020-01-13 10:55:19 +03:00
public function testItShouldSeeRevenueUpdatePage()
{
2020-07-25 17:22:50 +03:00
$request = $this->getRequest();
$revenue = $this->dispatch(new CreateTransaction($request));
2020-01-13 10:55:19 +03:00
$this->loginAs()
->get(route('revenues.edit', $revenue->id))
->assertStatus(200)
->assertSee($revenue->amount);
}
2018-10-09 14:18:12 +03:00
public function testItShouldUpdateRevenue()
{
2020-01-07 01:28:05 +03:00
$request = $this->getRequest();
2018-10-09 14:18:12 +03:00
2019-11-17 15:06:00 +03:00
$revenue = $this->dispatch(new CreateTransaction($request));
2018-10-09 14:18:12 +03:00
2020-01-13 17:20:28 +03:00
$request['amount'] = $this->faker->randomFloat(2, 1, 1000);
2018-10-09 14:18:12 +03:00
$this->loginAs()
->patch(route('revenues.update', $revenue->id), $request)
2020-01-13 17:20:28 +03:00
->assertStatus(200)
->assertSee($request['amount']);
2018-10-09 14:18:12 +03:00
$this->assertFlashLevel('success');
2020-07-25 17:22:50 +03:00
$this->assertDatabaseHas('transactions', $request);
2018-10-09 14:18:12 +03:00
}
public function testItShouldDeleteRevenue()
{
2020-07-25 17:22:50 +03:00
$request = $this->getRequest();
$revenue = $this->dispatch(new CreateTransaction($request));
2018-10-09 14:18:12 +03:00
$this->loginAs()
->delete(route('revenues.destroy', $revenue->id))
2019-11-16 10:21:14 +03:00
->assertStatus(200);
2018-10-09 14:18:12 +03:00
$this->assertFlashLevel('success');
2020-07-25 17:22:50 +03:00
$this->assertSoftDeleted('transactions', $request);
2018-10-09 14:18:12 +03:00
}
2020-01-07 01:28:05 +03:00
public function getRequest()
{
return factory(Transaction::class)->states('income')->raw();
}
2019-04-02 18:51:06 +03:00
}