mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Fix tests.
This commit is contained in:
@@ -133,10 +133,10 @@ class AvailableBudgetControllerTest extends TestCase
|
||||
|
||||
// data to submit
|
||||
$data = [
|
||||
'transaction_currency_id' => '1',
|
||||
'amount' => '100',
|
||||
'start_date' => '2018-01-01',
|
||||
'end_date' => '2018-01-31',
|
||||
'currency_id' => '1',
|
||||
'amount' => '100',
|
||||
'start_date' => '2018-01-01',
|
||||
'end_date' => '2018-01-31',
|
||||
];
|
||||
|
||||
|
||||
@@ -148,37 +148,6 @@ class AvailableBudgetControllerTest extends TestCase
|
||||
$response->assertHeader('Content-Type', 'application/vnd.api+json');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store new available budget but the budget currency is invalid.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AvailableBudgetController
|
||||
* @covers \FireflyIII\Api\V1\Requests\AvailableBudgetRequest
|
||||
*/
|
||||
public function testStoreInvalidCurrency(): void
|
||||
{
|
||||
// mock stuff:
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$currencyRepository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$currencyRepository->shouldReceive('findNull')->andReturn(null);
|
||||
|
||||
// data to submit
|
||||
$data = [
|
||||
'transaction_currency_id' => '1',
|
||||
'amount' => '100',
|
||||
'start_date' => '2018-01-01',
|
||||
'end_date' => '2018-01-31',
|
||||
];
|
||||
|
||||
|
||||
// test API
|
||||
$response = $this->post('/api/v1/available_budgets', $data, ['Accept' => 'application/json']);
|
||||
$response->assertStatus(500);
|
||||
$response->assertSee('Could not find the indicated currency.');
|
||||
$response->assertHeader('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update available budget.
|
||||
@@ -203,10 +172,10 @@ class AvailableBudgetControllerTest extends TestCase
|
||||
|
||||
// data to submit
|
||||
$data = [
|
||||
'transaction_currency_id' => '1',
|
||||
'amount' => '100',
|
||||
'start_date' => '2018-01-01',
|
||||
'end_date' => '2018-01-31',
|
||||
'currency_id' => '1',
|
||||
'amount' => '100',
|
||||
'start_date' => '2018-01-01',
|
||||
'end_date' => '2018-01-31',
|
||||
];
|
||||
|
||||
// test API
|
||||
|
@@ -158,8 +158,8 @@ class JournalLinkControllerTest extends TestCase
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$journalRepos->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('setUser');
|
||||
$journalRepos->shouldReceive('setUser');
|
||||
$collector->shouldReceive('setUser')->withAnyArgs();
|
||||
|
||||
$collector->shouldReceive('setUser')->withAnyArgs();
|
||||
@@ -171,6 +171,7 @@ class JournalLinkControllerTest extends TestCase
|
||||
|
||||
$journalRepos->shouldReceive('findNull')->andReturn($journal);
|
||||
$repository->shouldReceive('storeLink')->once()->andReturn($journalLink);
|
||||
$repository->shouldReceive('findLink')->once()->andReturn(false);
|
||||
|
||||
|
||||
// data to submit
|
||||
@@ -206,8 +207,8 @@ class JournalLinkControllerTest extends TestCase
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$journalRepos->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('setUser');
|
||||
$journalRepos->shouldReceive('setUser');
|
||||
$collector->shouldReceive('setUser')->withAnyArgs();
|
||||
|
||||
$collector->shouldReceive('setUser')->withAnyArgs();
|
||||
@@ -230,8 +231,8 @@ class JournalLinkControllerTest extends TestCase
|
||||
|
||||
// test API
|
||||
$response = $this->post('/api/v1/journal_links', $data, ['Accept' => 'application/json']);
|
||||
$response->assertStatus(500);
|
||||
$response->assertSee('Source or destination is NULL.'); // error message
|
||||
$response->assertStatus(422);
|
||||
$response->assertSee('Invalid inward ID.'); // error message
|
||||
$response->assertHeader('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
@@ -256,7 +257,7 @@ class JournalLinkControllerTest extends TestCase
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser');
|
||||
$journalRepos->shouldReceive('setUser')->once();
|
||||
$journalRepos->shouldReceive('setUser');
|
||||
$collector->shouldReceive('setUser')->withAnyArgs();
|
||||
|
||||
$collector->shouldReceive('setUser')->withAnyArgs();
|
||||
@@ -268,6 +269,7 @@ class JournalLinkControllerTest extends TestCase
|
||||
|
||||
$journalRepos->shouldReceive('findNull')->andReturn($journal);
|
||||
$repository->shouldReceive('updateLink')->once()->andReturn($journalLink);
|
||||
$repository->shouldReceive('findLink')->once()->andReturn(false);
|
||||
|
||||
// data to submit
|
||||
$data = [
|
||||
@@ -305,7 +307,7 @@ class JournalLinkControllerTest extends TestCase
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser');
|
||||
$journalRepos->shouldReceive('setUser')->once();
|
||||
$journalRepos->shouldReceive('setUser');
|
||||
$collector->shouldReceive('setUser')->withAnyArgs();
|
||||
|
||||
$collector->shouldReceive('setUser')->withAnyArgs();
|
||||
@@ -327,8 +329,8 @@ class JournalLinkControllerTest extends TestCase
|
||||
|
||||
// test API
|
||||
$response = $this->put('/api/v1/journal_links/' . $journalLink->id, $data, ['Accept' => 'application/json']);
|
||||
$response->assertStatus(500);
|
||||
$response->assertSee('Source or destination is NULL.'); // the creation moment.
|
||||
$response->assertStatus(422);
|
||||
$response->assertSee('Invalid inward ID.'); // the creation moment.
|
||||
$response->assertHeader('Content-Type', 'application/json');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user