mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
Fix tests.
This commit is contained in:
@@ -52,98 +52,6 @@ class JsonControllerTest extends TestCase
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\JsonController::boxBillsPaid
|
||||
*/
|
||||
public function testBoxBillsPaid()
|
||||
{
|
||||
// mock stuff
|
||||
|
||||
$billRepos = $this->mock(BillRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$billRepos->shouldReceive('getBillsPaidInRange')->andReturn('-100');
|
||||
|
||||
$this->be($this->user());
|
||||
$currency = Amount::getDefaultCurrency();
|
||||
$response = $this->get(route('json.box.paid'));
|
||||
$response->assertStatus(200);
|
||||
$response->assertExactJson(['amount' => Amount::formatAnything($currency, '100', false), 'amount_raw' => '100', 'box' => 'bills-paid']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\JsonController::boxBillsUnpaid
|
||||
*/
|
||||
public function testBoxBillsUnpaid()
|
||||
{
|
||||
// mock stuff
|
||||
|
||||
$billRepos = $this->mock(BillRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$billRepos->shouldReceive('getBillsUnpaidInRange')->andReturn('100');
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$currency = Amount::getDefaultCurrency();
|
||||
$response = $this->get(route('json.box.unpaid'));
|
||||
$response->assertStatus(200);
|
||||
$response->assertExactJson(['amount' => Amount::formatAnything($currency, '100', false), 'amount_raw' => '100', 'box' => 'bills-unpaid']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\JsonController::boxIn
|
||||
*/
|
||||
public function testBoxIn()
|
||||
{
|
||||
// mock stuff
|
||||
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$transaction = factory(Transaction::class)->make();
|
||||
$transaction->transaction_amount = '100.00';
|
||||
|
||||
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('setRange')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('getJournals')->andReturn(new Collection([$transaction]))->once();
|
||||
$collector->shouldReceive('setTypes')->withArgs([[TransactionType::DEPOSIT]])->andReturnSelf()->once();
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf()->once();
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$currency = Amount::getDefaultCurrency();
|
||||
$response = $this->get(route('json.box.in'));
|
||||
$response->assertStatus(200);
|
||||
$response->assertExactJson(['amount' => Amount::formatAnything($currency, '100', false), 'amount_raw' => '100', 'box' => 'in']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\JsonController::boxOut
|
||||
*/
|
||||
public function testBoxOut()
|
||||
{
|
||||
// mock stuff
|
||||
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$transaction = factory(Transaction::class)->make();
|
||||
$transaction->transaction_amount = '100.00';
|
||||
|
||||
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('setRange')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('getJournals')->andReturn(new Collection([$transaction]))->once();
|
||||
$collector->shouldReceive('setTypes')->withArgs([[TransactionType::WITHDRAWAL]])->andReturnSelf()->once();
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf()->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$currency = Amount::getDefaultCurrency();
|
||||
$response = $this->get(route('json.box.out'));
|
||||
$response->assertStatus(200);
|
||||
$response->assertExactJson(['amount' => Amount::formatAnything($currency, '100', false), 'amount_raw' => '100', 'box' => 'out']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\JsonController::budgets
|
||||
*/
|
||||
|
Reference in New Issue
Block a user