akaunting/tests/Feature/Banking/ReconciliationsTest.php

92 lines
2.6 KiB
PHP
Raw Normal View History

2018-11-07 21:59:03 +03:00
<?php
namespace Tests\Feature\Banking;
2019-04-02 18:51:06 +03:00
2019-11-17 15:06:00 +03:00
use App\Jobs\Banking\CreateReconciliation;
2018-11-07 21:59:03 +03:00
use Tests\Feature\FeatureTestCase;
class ReconciliationsTest extends FeatureTestCase
{
public function testItShouldSeeReconciliationtListPage()
{
$this->loginAs()
->get(route('reconciliations.index'))
->assertStatus(200)
->assertSeeText(trans_choice('general.reconciliations', 2));
}
public function testItShouldSeeReconciliationCreatePage()
{
$this->loginAs()
->get(route('reconciliations.create'))
->assertStatus(200)
->assertSeeText(trans('general.title.new', ['type' => trans_choice('general.reconciliations', 1)]));
}
public function testItShouldCreateReconciliation()
{
2020-06-21 01:34:44 +03:00
$request = $this->getRequest();
2020-06-21 01:27:20 +03:00
2018-11-07 21:59:03 +03:00
$this->loginAs()
2020-06-21 01:27:20 +03:00
->post(route('reconciliations.store'), $request)
2019-11-16 10:21:14 +03:00
->assertStatus(200);
2018-11-07 21:59:03 +03:00
$this->assertFlashLevel('success');
}
public function testItShouldSeeReconciliationUpdatePage()
{
2020-06-21 01:34:44 +03:00
$request = $this->getRequest();
2020-06-21 01:27:20 +03:00
$reconciliation = $this->dispatch(new CreateReconciliation($request));
2018-11-07 21:59:03 +03:00
$this->loginAs()
2020-01-13 10:55:19 +03:00
->get(route('reconciliations.edit', $reconciliation->id))
2018-11-07 21:59:03 +03:00
->assertStatus(200)
->assertSeeText(trans_choice('general.reconciliations', 2));
}
public function testItShouldUpdateReconciliation()
{
2020-06-21 01:27:20 +03:00
$request = $this->getRequest();
2018-11-07 21:59:03 +03:00
2019-11-17 15:06:00 +03:00
$reconciliation= $this->dispatch(new CreateReconciliation($request));
2018-11-07 21:59:03 +03:00
$request['description'] = $this->faker->text(10);
$this->loginAs()
2019-11-16 10:21:14 +03:00
->patch(route('reconciliations.update', $reconciliation->id), $request)
->assertStatus(200);
2018-11-07 21:59:03 +03:00
$this->assertFlashLevel('success');
}
public function testItShouldDeleteReconciliation()
{
2020-06-21 01:34:44 +03:00
$request = $this->getRequest();
2020-06-21 01:27:20 +03:00
$reconciliation = $this->dispatch(new CreateReconciliation($request));
2018-11-07 21:59:03 +03:00
$this->loginAs()
2020-01-13 10:55:19 +03:00
->delete(route('reconciliations.destroy', $reconciliation->id))
2019-11-16 10:21:14 +03:00
->assertStatus(200);
2018-11-07 21:59:03 +03:00
$this->assertFlashLevel('success');
}
2020-06-21 01:27:20 +03:00
private function getRequest()
2018-11-07 21:59:03 +03:00
{
return [
'company_id' => $this->company->id,
'account_id' => '1',
2019-11-16 10:21:14 +03:00
'currency_code' => setting('default.currency'),
2018-11-07 21:59:03 +03:00
'opening_balance' => '0',
'closing_balance' => '10',
'started_at' => $this->faker->date(),
'ended_at' => $this->faker->date(),
'reconcile' => null,
'reconciled' => '1',
];
}
2019-04-02 18:51:06 +03:00
}