mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-01 11:47:14 -06:00
Expand test coverage.
This commit is contained in:
parent
a7b8470d9e
commit
6ed5be10b1
@ -33,6 +33,7 @@ use Log;
|
||||
use phpseclib\Crypt\RSA;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* Class InstallController
|
||||
*/
|
||||
class InstallController extends Controller
|
||||
|
@ -50,8 +50,8 @@ class BulkControllerTest extends TestCase
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController::edit
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController::__construct
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController
|
||||
*/
|
||||
public function testEdit(): void
|
||||
{
|
||||
@ -75,6 +75,32 @@ class BulkControllerTest extends TestCase
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController
|
||||
*/
|
||||
public function testEditNull(): void
|
||||
{
|
||||
// mock stuff:
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepos->shouldReceive('getActiveBudgets')->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal, null);
|
||||
$journalRepos->shouldReceive('getTransactionType')->andReturn('Transfer');
|
||||
$journalRepos->shouldReceive('isJournalReconciled')->andReturn(false);
|
||||
|
||||
$transfers = TransactionJournal::where('transaction_type_id', 3)->where('user_id', $this->user()->id)->take(4)->get()->pluck('id')->toArray();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.bulk.edit', $transfers));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('Bulk edit a number of transactions');
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController::edit
|
||||
*/
|
||||
@ -141,6 +167,44 @@ class BulkControllerTest extends TestCase
|
||||
->withArgs([Mockery::any(), ['tags' => $tags]]);
|
||||
|
||||
|
||||
$route = route('transactions.bulk.update');
|
||||
$this->be($this->user());
|
||||
$response = $this->post($route, $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController
|
||||
* @covers \FireflyIII\Http\Requests\BulkEditJournalRequest
|
||||
*/
|
||||
public function testUpdateNull(): void
|
||||
{
|
||||
$tags = ['a', 'b', 'c'];
|
||||
$collection = TransactionJournal::where('transaction_type_id', 1)->where('user_id', $this->user()->id)->take(4)->get();
|
||||
$allIds = $collection->pluck('id')->toArray();
|
||||
|
||||
$data = [
|
||||
'category' => 'Some new category',
|
||||
'budget_id' => 1,
|
||||
'tags' => 'a,b,c',
|
||||
'journals' => $allIds,
|
||||
];
|
||||
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('findNull')->times(4)->andReturn(new TransactionJournal, null);
|
||||
|
||||
$repository->shouldReceive('updateCategory')->times(1)->andReturn(new TransactionJournal())
|
||||
->withArgs([Mockery::any(), $data['category']]);
|
||||
|
||||
$repository->shouldReceive('updateBudget')->times(1)->andReturn(new TransactionJournal())
|
||||
->withArgs([Mockery::any(), $data['budget_id']]);
|
||||
|
||||
$repository->shouldReceive('updateTags')->times(1)->andReturn(new TransactionJournal())
|
||||
->withArgs([Mockery::any(), ['tags' => $tags]]);
|
||||
|
||||
|
||||
$route = route('transactions.bulk.update');
|
||||
$this->be($this->user());
|
||||
$response = $this->post($route, $data);
|
||||
|
@ -120,7 +120,7 @@ class MappingConvergerTest extends TestCase
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'linerA' . random_int(1, 1000);
|
||||
$job->key = 'linerB' . random_int(1, 1000);
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'fake';
|
||||
|
Loading…
Reference in New Issue
Block a user