mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
API updates.
This commit is contained in:
@@ -50,6 +50,8 @@ class AccountControllerTest extends TestCase
|
||||
* Opening balance without date.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AccountController
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountStoreRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testStoreInvalidBalance(): void
|
||||
@@ -95,10 +97,10 @@ class AccountControllerTest extends TestCase
|
||||
$transformer->shouldReceive('setParameters')->atLeast()->once();
|
||||
$transformer->shouldReceive('transform')->atLeast()->once()->andReturn(
|
||||
[
|
||||
'id' => 1,
|
||||
'id' => 1,
|
||||
'attributes' => [
|
||||
'name' => 'Account'
|
||||
]
|
||||
'name' => 'Account',
|
||||
],
|
||||
]);
|
||||
$transformer->shouldReceive('setCurrentScope')->atLeast()->once();
|
||||
$transformer->shouldReceive('getDefaultIncludes')->atLeast()->once()->andReturn([]);
|
||||
@@ -116,6 +118,8 @@ class AccountControllerTest extends TestCase
|
||||
* Send correct data. Should call account repository store method.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AccountController
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountStoreRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testStoreLiability(): void
|
||||
@@ -162,13 +166,15 @@ class AccountControllerTest extends TestCase
|
||||
* CC type present when account is a credit card.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AccountController
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountStoreRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testStoreNoCreditCardData(): void
|
||||
{
|
||||
// mock repositories
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$transformer = $this->mock(AccountTransformer::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$this->mock(AccountTransformer::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
@@ -201,6 +207,8 @@ class AccountControllerTest extends TestCase
|
||||
* No currency information (is allowed).
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AccountController
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountStoreRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testStoreNoCurrencyInfo(): void
|
||||
@@ -238,6 +246,8 @@ class AccountControllerTest extends TestCase
|
||||
* Name already in use.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AccountController
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountStoreRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
*/
|
||||
public function testStoreNotUnique(): void
|
||||
{
|
||||
@@ -277,6 +287,8 @@ class AccountControllerTest extends TestCase
|
||||
* Send correct data. Should call account repository store method.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AccountController
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountStoreRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testStoreValid(): void
|
||||
@@ -315,6 +327,8 @@ class AccountControllerTest extends TestCase
|
||||
* Send correct data. Should call account repository store method.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AccountController
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountStoreRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testStoreWithCurrencyCode(): void
|
||||
@@ -355,6 +369,8 @@ class AccountControllerTest extends TestCase
|
||||
* Update first asset account we find. Name can be the same as it was.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AccountController
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountUpdateRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
*/
|
||||
public function testUpdate(): void
|
||||
{
|
||||
@@ -396,6 +412,8 @@ class AccountControllerTest extends TestCase
|
||||
* Update first asset account we find. Name can be the same as it was.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AccountController
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountUpdateRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
*/
|
||||
public function testUpdateCurrencyCode(): void
|
||||
{
|
||||
@@ -437,6 +455,8 @@ class AccountControllerTest extends TestCase
|
||||
* Update a liability
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AccountController
|
||||
* @covers \FireflyIII\Api\V1\Requests\AccountUpdateRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
*/
|
||||
public function testUpdateLiability(): void
|
||||
{
|
||||
|
@@ -60,6 +60,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RecurrenceStoreRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
*/
|
||||
public function testStoreAssetId(): void
|
||||
{
|
||||
@@ -125,6 +126,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RecurrenceStoreRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
*/
|
||||
public function testStoreAssetName(): void
|
||||
{
|
||||
@@ -191,6 +193,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RecurrenceStoreRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
*/
|
||||
public function testStoreDeposit(): void
|
||||
{
|
||||
@@ -259,6 +262,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RecurrenceStoreRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
*/
|
||||
public function testStoreDestinationId(): void
|
||||
{
|
||||
@@ -328,6 +332,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RecurrenceStoreRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
*/
|
||||
public function testStoreDestinationName(): void
|
||||
{
|
||||
@@ -397,6 +402,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RecurrenceStoreRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
*/
|
||||
public function testStoreFailBothRepetitions(): void
|
||||
{
|
||||
@@ -469,6 +475,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RecurrenceStoreRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
*/
|
||||
public function testStoreFailForeignCurrency(): void
|
||||
{
|
||||
@@ -534,6 +541,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RecurrenceStoreRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
*/
|
||||
public function testStoreFailInvalidDaily(): void
|
||||
{
|
||||
@@ -599,18 +607,13 @@ class RecurrenceControllerTest extends TestCase
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RecurrenceStoreRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
*/
|
||||
public function testStoreFailInvalidDestinationId(): void
|
||||
{
|
||||
// mock stuff:
|
||||
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
$transformer = $this->mock(RecurrenceTransformer::class);
|
||||
$validator = $this->mock(AccountValidator::class);
|
||||
|
||||
$assetAccount = $this->getRandomAsset();
|
||||
|
||||
// mock calls to validator:
|
||||
@@ -621,26 +624,6 @@ class RecurrenceControllerTest extends TestCase
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
//$factory->shouldReceive('setUser')->atLeast()->once();
|
||||
//$budgetRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
//$accountRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
// used by the validator to find the source_id:
|
||||
// $accountRepos->shouldReceive('getAccountsById')->withArgs([[1]])->once()
|
||||
// ->andReturn(new Collection([$assetAccount]));
|
||||
// $accountRepos->shouldReceive('getAccountsById')->withArgs([[$assetAccount->id]])->once()
|
||||
// ->andReturn(new Collection([$assetAccount]));
|
||||
//
|
||||
//
|
||||
// // entries used by the transformer
|
||||
// $repository->shouldReceive('getNoteText')->andReturn('Note text')->atLeast()->once();
|
||||
// $repository->shouldReceive('repetitionDescription')->andReturn('Some description.')->atLeast()->once();
|
||||
// $repository->shouldReceive('getXOccurrences')->andReturn([])->atLeast()->once();
|
||||
//
|
||||
// // entries used by the transformer (the fake entry has a category + a budget):
|
||||
// $factory->shouldReceive('findOrCreate')->andReturn(null)->atLeast()->once();
|
||||
// $budgetRepos->shouldReceive('findNull')->andReturn(null)->atLeast()->once();
|
||||
|
||||
|
||||
// data to submit
|
||||
$firstDate = new Carbon;
|
||||
@@ -695,32 +678,21 @@ class RecurrenceControllerTest extends TestCase
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RecurrenceStoreRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
*/
|
||||
public function testStoreFailInvalidMonthly(): void
|
||||
{
|
||||
/** @var Recurrence $recurrence */
|
||||
$recurrence = $this->user()->recurrences()->first();
|
||||
|
||||
// mock stuff:
|
||||
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
$transformer = $this->mock(RecurrenceTransformer::class);
|
||||
$validator = $this->mock(AccountValidator::class);
|
||||
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
$factory->shouldReceive('setUser')->atLeast()->once();
|
||||
$budgetRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$accountRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
// used by the validator to find the source_id:
|
||||
$accountRepos->shouldReceive('getAccountsById')->withArgs([[1]])->once()
|
||||
->andReturn(new Collection([$assetAccount]));
|
||||
// mock calls to validator:
|
||||
$validator->shouldReceive('setTransactionType')->atLeast()->once()->withArgs(['withdrawal']);
|
||||
$validator->shouldReceive('validateSource')->atLeast()->once()->withArgs([1, null])->andReturn(true);
|
||||
$validator->shouldReceive('validateDestination')->atLeast()->once()->withArgs([null, null])->andReturn(true);
|
||||
|
||||
// data to submit
|
||||
$firstDate = new Carbon;
|
||||
@@ -771,32 +743,21 @@ class RecurrenceControllerTest extends TestCase
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RecurrenceStoreRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
*/
|
||||
public function testStoreFailInvalidNdom(): void
|
||||
{
|
||||
/** @var Recurrence $recurrence */
|
||||
$recurrence = $this->user()->recurrences()->first();
|
||||
|
||||
// mock stuff:
|
||||
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
$transformer = $this->mock(RecurrenceTransformer::class);
|
||||
$validator = $this->mock(AccountValidator::class);
|
||||
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
// mock calls to validator:
|
||||
$validator->shouldReceive('setTransactionType')->atLeast()->once()->withArgs(['withdrawal']);
|
||||
$validator->shouldReceive('validateSource')->atLeast()->once()->withArgs([1, null])->andReturn(true);
|
||||
$validator->shouldReceive('validateDestination')->atLeast()->once()->withArgs([null, null])->andReturn(true);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
$factory->shouldReceive('setUser')->atLeast()->once();
|
||||
$budgetRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$accountRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
// used by the validator to find the source_id:
|
||||
$accountRepos->shouldReceive('getAccountsById')->withArgs([[1]])->once()
|
||||
->andReturn(new Collection([$assetAccount]));
|
||||
|
||||
// data to submit
|
||||
$firstDate = new Carbon;
|
||||
@@ -847,32 +808,21 @@ class RecurrenceControllerTest extends TestCase
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RecurrenceStoreRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
*/
|
||||
public function testStoreFailInvalidNdomCount(): void
|
||||
{
|
||||
/** @var Recurrence $recurrence */
|
||||
$recurrence = $this->user()->recurrences()->first();
|
||||
|
||||
// mock stuff:
|
||||
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
$transformer = $this->mock(RecurrenceTransformer::class);
|
||||
$validator = $this->mock(AccountValidator::class);
|
||||
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
// mock calls to validator:
|
||||
$validator->shouldReceive('setTransactionType')->atLeast()->once()->withArgs(['withdrawal']);
|
||||
$validator->shouldReceive('validateSource')->atLeast()->once()->withArgs([1, null])->andReturn(true);
|
||||
$validator->shouldReceive('validateDestination')->atLeast()->once()->withArgs([null, null])->andReturn(true);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
$factory->shouldReceive('setUser')->atLeast()->once();
|
||||
$budgetRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$accountRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
// used by the validator to find the source_id:
|
||||
$accountRepos->shouldReceive('getAccountsById')->withArgs([[1]])->once()
|
||||
->andReturn(new Collection([$assetAccount]));
|
||||
|
||||
// data to submit
|
||||
$firstDate = new Carbon;
|
||||
@@ -923,33 +873,22 @@ class RecurrenceControllerTest extends TestCase
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RecurrenceStoreRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
*/
|
||||
public function testStoreFailInvalidNdomHigh(): void
|
||||
{
|
||||
|
||||
/** @var Recurrence $recurrence */
|
||||
$recurrence = $this->user()->recurrences()->first();
|
||||
|
||||
// mock stuff:
|
||||
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
$transformer = $this->mock(RecurrenceTransformer::class);
|
||||
$validator = $this->mock(AccountValidator::class);
|
||||
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
$factory->shouldReceive('setUser')->atLeast()->once();
|
||||
$budgetRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$accountRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
// used by the validator to find the source_id:
|
||||
$accountRepos->shouldReceive('getAccountsById')->withArgs([[1]])->once()
|
||||
->andReturn(new Collection([$assetAccount]));
|
||||
// mock calls to validator:
|
||||
$validator->shouldReceive('setTransactionType')->atLeast()->once()->withArgs(['withdrawal']);
|
||||
$validator->shouldReceive('validateSource')->atLeast()->once()->withArgs([1, null])->andReturn(true);
|
||||
$validator->shouldReceive('validateDestination')->atLeast()->once()->withArgs([null, null])->andReturn(true);
|
||||
|
||||
|
||||
// data to submit
|
||||
$firstDate = new Carbon;
|
||||
@@ -1000,33 +939,22 @@ class RecurrenceControllerTest extends TestCase
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RecurrenceStoreRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
*/
|
||||
public function testStoreFailInvalidWeekly(): void
|
||||
{
|
||||
|
||||
/** @var Recurrence $recurrence */
|
||||
$recurrence = $this->user()->recurrences()->first();
|
||||
|
||||
// mock stuff:
|
||||
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
$transformer = $this->mock(RecurrenceTransformer::class);
|
||||
$validator = $this->mock(AccountValidator::class);
|
||||
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
// mock calls to validator:
|
||||
$validator->shouldReceive('setTransactionType')->atLeast()->once()->withArgs(['withdrawal']);
|
||||
$validator->shouldReceive('validateSource')->atLeast()->once()->withArgs([1, null])->andReturn(true);
|
||||
$validator->shouldReceive('validateDestination')->atLeast()->once()->withArgs([null, null])->andReturn(true);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
$factory->shouldReceive('setUser')->atLeast()->once();
|
||||
$budgetRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$accountRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
// used by the validator to find the source_id:
|
||||
$accountRepos->shouldReceive('getAccountsById')->withArgs([[1]])->once()
|
||||
->andReturn(new Collection([$assetAccount]));
|
||||
|
||||
// data to submit
|
||||
$firstDate = new Carbon;
|
||||
@@ -1077,24 +1005,21 @@ class RecurrenceControllerTest extends TestCase
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RecurrenceStoreRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
*/
|
||||
public function testStoreFailNoAsset(): void
|
||||
{
|
||||
/** @var Recurrence $recurrence */
|
||||
$recurrence = $this->user()->recurrences()->first();
|
||||
|
||||
// mock stuff:
|
||||
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
$transformer = $this->mock(RecurrenceTransformer::class);
|
||||
$validator = $this->mock(AccountValidator::class);
|
||||
|
||||
// mock calls to validator:
|
||||
$validator->shouldReceive('setTransactionType')->atLeast()->once()->withArgs(['withdrawal']);
|
||||
$validator->shouldReceive('validateSource')->atLeast()->once()->withArgs([0, null])->andReturn(false);
|
||||
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
$accountRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
// data to submit
|
||||
$firstDate = new Carbon;
|
||||
@@ -1131,8 +1056,11 @@ class RecurrenceControllerTest extends TestCase
|
||||
'message' => 'The given data was invalid.',
|
||||
'errors' => [
|
||||
'transactions.0.source_id' => [
|
||||
null,
|
||||
'This value is invalid for this field.',
|
||||
'The transactions.0.source_id field is required.',
|
||||
],
|
||||
'transactions.0.source_name' => [
|
||||
null,
|
||||
],
|
||||
],
|
||||
]
|
||||
@@ -1147,32 +1075,23 @@ class RecurrenceControllerTest extends TestCase
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RecurrenceStoreRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
*/
|
||||
public function testStoreFailNotAsset(): void
|
||||
{
|
||||
|
||||
/** @var Recurrence $recurrence */
|
||||
$recurrence = $this->user()->recurrences()->first();
|
||||
|
||||
// expense account:
|
||||
$expenseAccount = $this->user()->accounts()->where('account_type_id', 4)->first();
|
||||
$expenseAccount = $this->getRandomExpense();
|
||||
|
||||
// mock stuff:
|
||||
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
$transformer = $this->mock(RecurrenceTransformer::class);
|
||||
$validator = $this->mock(AccountValidator::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
$accountRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
// used to find the source_id:
|
||||
$accountRepos->shouldReceive('getAccountsById')->withArgs([[$expenseAccount->id]])->once()
|
||||
->andReturn(new Collection([$expenseAccount]));
|
||||
// mock calls to validator:
|
||||
$validator->shouldReceive('setTransactionType')->atLeast()->once()->withArgs(['withdrawal']);
|
||||
$validator->shouldReceive('validateSource')->atLeast()->once()->withArgs([$expenseAccount->id, null])->andReturn(false);
|
||||
|
||||
// data to submit
|
||||
$firstDate = new Carbon;
|
||||
@@ -1209,7 +1128,10 @@ class RecurrenceControllerTest extends TestCase
|
||||
'message' => 'The given data was invalid.',
|
||||
'errors' => [
|
||||
'transactions.0.source_id' => [
|
||||
'This value is invalid for this field.',
|
||||
null
|
||||
],
|
||||
'transactions.0.source_name' => [
|
||||
null
|
||||
],
|
||||
],
|
||||
]
|
||||
@@ -1224,35 +1146,20 @@ class RecurrenceControllerTest extends TestCase
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RecurrenceStoreRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
*/
|
||||
public function testStoreFailNotAssetName(): void
|
||||
{
|
||||
|
||||
/** @var Recurrence $recurrence */
|
||||
$recurrence = $this->user()->recurrences()->first();
|
||||
|
||||
// expense account:
|
||||
$expenseAccount = $this->user()->accounts()->where('account_type_id', 4)->first();
|
||||
|
||||
// mock stuff:
|
||||
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
$transformer = $this->mock(RecurrenceTransformer::class);
|
||||
$validator = $this->mock(AccountValidator::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
$accountRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
// used to find the source_id:
|
||||
$accountRepos->shouldReceive('getAccountsById')->withArgs([[0]])->once()
|
||||
->andReturn(new Collection);
|
||||
// used to search by name.
|
||||
$accountRepos->shouldReceive('findByName')->withArgs(['Fake name', [AccountType::ASSET]])->once()
|
||||
->andReturn(null);
|
||||
// mock calls to validator:
|
||||
$validator->shouldReceive('setTransactionType')->atLeast()->once()->withArgs(['withdrawal']);
|
||||
$validator->shouldReceive('validateSource')->atLeast()->once()->withArgs([0, 'Fake name'])->andReturn(false);
|
||||
|
||||
// data to submit
|
||||
$firstDate = new Carbon;
|
||||
@@ -1289,11 +1196,12 @@ class RecurrenceControllerTest extends TestCase
|
||||
[
|
||||
'message' => 'The given data was invalid.',
|
||||
'errors' => [
|
||||
'transactions.0.source_id' => [
|
||||
'transactions.0.source_id' => [
|
||||
null,
|
||||
'This value is invalid for this field.',
|
||||
],
|
||||
'transactions.0.source_name' => [
|
||||
'This value is invalid for this field.',
|
||||
null
|
||||
],
|
||||
],
|
||||
]
|
||||
@@ -1308,32 +1216,21 @@ class RecurrenceControllerTest extends TestCase
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RecurrenceStoreRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
*/
|
||||
public function testStoreFailRepetitions(): void
|
||||
{
|
||||
/** @var Recurrence $recurrence */
|
||||
$recurrence = $this->user()->recurrences()->first();
|
||||
|
||||
// mock stuff:
|
||||
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
$transformer = $this->mock(RecurrenceTransformer::class);
|
||||
$validator = $this->mock(AccountValidator::class);
|
||||
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
$factory->shouldReceive('setUser')->atLeast()->once();
|
||||
$budgetRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$accountRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
// used by the validator to find the source_id:
|
||||
$accountRepos->shouldReceive('getAccountsById')->withArgs([[1]])->once()
|
||||
->andReturn(new Collection([$assetAccount]));
|
||||
// mock calls to validator:
|
||||
$validator->shouldReceive('setTransactionType')->atLeast()->once()->withArgs(['withdrawal']);
|
||||
$validator->shouldReceive('validateSource')->atLeast()->once()->withArgs([1, null])->andReturn(true);
|
||||
$validator->shouldReceive('validateDestination')->atLeast()->once()->withArgs([null, null])->andReturn(true);
|
||||
|
||||
// data to submit
|
||||
$firstDate = new Carbon;
|
||||
@@ -1376,28 +1273,15 @@ class RecurrenceControllerTest extends TestCase
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RecurrenceStoreRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
*/
|
||||
public function testStoreFailTransactions(): void
|
||||
{
|
||||
/** @var Recurrence $recurrence */
|
||||
$recurrence = $this->user()->recurrences()->first();
|
||||
|
||||
// mock stuff:
|
||||
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
$transformer = $this->mock(RecurrenceTransformer::class);
|
||||
$validator = $this->mock(AccountValidator::class);
|
||||
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
|
||||
$this->mock(AccountValidator::class);
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
$factory->shouldReceive('setUser')->atLeast()->once();
|
||||
$budgetRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$accountRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
// data to submit
|
||||
$firstDate = new Carbon;
|
||||
@@ -1442,6 +1326,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RecurrenceStoreRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
*/
|
||||
public function testStoreTransfer(): void
|
||||
{
|
||||
@@ -1450,13 +1335,12 @@ class RecurrenceControllerTest extends TestCase
|
||||
|
||||
// mock stuff:
|
||||
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
$transformer = $this->mock(RecurrenceTransformer::class);
|
||||
$validator = $this->mock(AccountValidator::class);
|
||||
|
||||
$assetAccount = $this->getRandomAsset();
|
||||
$otherAssetAccount = $this->getRandomAsset($assetAccount->id);
|
||||
|
||||
// mock calls to transformer:
|
||||
$transformer->shouldReceive('setParameters')->withAnyArgs()->atLeast()->once();
|
||||
$transformer->shouldReceive('setCurrentScope')->withAnyArgs()->atLeast()->once()->andReturnSelf();
|
||||
@@ -1464,32 +1348,15 @@ class RecurrenceControllerTest extends TestCase
|
||||
$transformer->shouldReceive('getAvailableIncludes')->withAnyArgs()->atLeast()->once()->andReturn([]);
|
||||
$transformer->shouldReceive('transform')->atLeast()->once()->andReturn(['id' => 5]);
|
||||
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
$otherAssetAccount = $this->user()->accounts()->where('account_type_id', 3)->where('id', '!=', $assetAccount->id)->first();
|
||||
// mock calls to validator:
|
||||
$validator->shouldReceive('setTransactionType')->atLeast()->once()->withArgs(['transfer']);
|
||||
$validator->shouldReceive('validateSource')->atLeast()->once()->withArgs([$assetAccount->id, null])->andReturn(true);
|
||||
$validator->shouldReceive('validateDestination')->atLeast()->once()->withArgs([$otherAssetAccount->id, null])->andReturn(true);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
$factory->shouldReceive('setUser')->atLeast()->once();
|
||||
$budgetRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$accountRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$repository->shouldReceive('store')->once()->andReturn($recurrence);
|
||||
|
||||
|
||||
// used by the validator to find the source_id:
|
||||
$accountRepos->shouldReceive('getAccountsById')->withArgs([[$assetAccount->id]])->once()->andReturn(new Collection([$assetAccount]));
|
||||
$accountRepos->shouldReceive('getAccountsById')->withArgs([[$otherAssetAccount->id]])->once()->andReturn(new Collection([$otherAssetAccount]));
|
||||
|
||||
|
||||
// entries used by the transformer
|
||||
$repository->shouldReceive('getNoteText')->andReturn('Note text')->atLeast()->once();
|
||||
$repository->shouldReceive('repetitionDescription')->andReturn('Some description.')->atLeast()->once();
|
||||
$repository->shouldReceive('getXOccurrences')->andReturn([])->atLeast()->once();
|
||||
|
||||
// entries used by the transformer (the fake entry has a category + a budget):
|
||||
$factory->shouldReceive('findOrCreate')->andReturn(null)->atLeast()->once();
|
||||
$budgetRepos->shouldReceive('findNull')->andReturn(null)->atLeast()->once();
|
||||
|
||||
|
||||
// data to submit
|
||||
$firstDate = new Carbon;
|
||||
$firstDate->addDays(2);
|
||||
@@ -1531,6 +1398,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RecurrenceUpdateRequest
|
||||
* @covers \FireflyIII\Api\V1\Requests\Request
|
||||
*/
|
||||
public function testUpdate(): void
|
||||
{
|
||||
@@ -1539,10 +1407,6 @@ class RecurrenceControllerTest extends TestCase
|
||||
|
||||
// mock stuff:
|
||||
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
$transformer = $this->mock(RecurrenceTransformer::class);
|
||||
$validator = $this->mock(AccountValidator::class);
|
||||
|
||||
@@ -1553,30 +1417,17 @@ class RecurrenceControllerTest extends TestCase
|
||||
$transformer->shouldReceive('getAvailableIncludes')->withAnyArgs()->atLeast()->once()->andReturn([]);
|
||||
$transformer->shouldReceive('transform')->atLeast()->once()->andReturn(['id' => 5]);
|
||||
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
|
||||
// mock calls to validator:
|
||||
$validator->shouldReceive('setTransactionType')->atLeast()->once()->withArgs(['deposit']);
|
||||
$validator->shouldReceive('validateSource')->atLeast()->once()->withArgs([null, 'Some expense account'])->andReturn(true);
|
||||
$validator->shouldReceive('validateDestination')->atLeast()->once()->withArgs([1, null])->andReturn(true);
|
||||
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
$factory->shouldReceive('setUser')->atLeast()->once();
|
||||
$budgetRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$accountRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$repository->shouldReceive('update')->once()->andReturn($recurrence);
|
||||
|
||||
|
||||
// used by the validator to find the source_id:
|
||||
$accountRepos->shouldReceive('getAccountsById')->withArgs([[1]])->once()->andReturn(new Collection([$assetAccount]));
|
||||
|
||||
|
||||
// entries used by the transformer
|
||||
$repository->shouldReceive('getNoteText')->andReturn('Note text')->atLeast()->once();
|
||||
$repository->shouldReceive('repetitionDescription')->andReturn('Some description.')->atLeast()->once();
|
||||
$repository->shouldReceive('getXOccurrences')->andReturn([])->atLeast()->once();
|
||||
|
||||
// entries used by the transformer (the fake entry has a category + a budget):
|
||||
$factory->shouldReceive('findOrCreate')->andReturn(null)->atLeast()->once();
|
||||
$budgetRepos->shouldReceive('findNull')->andReturn(null)->atLeast()->once();
|
||||
|
||||
|
||||
// data to submit
|
||||
$firstDate = new Carbon;
|
||||
$firstDate->addDays(2);
|
||||
|
@@ -32,6 +32,7 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
||||
use FireflyIII\TransactionRules\TransactionMatcher;
|
||||
use FireflyIII\Transformers\RuleTransformer;
|
||||
use FireflyIII\Transformers\TransactionGroupTransformer;
|
||||
use FireflyIII\Transformers\TransactionTransformer;
|
||||
use Illuminate\Support\Collection;
|
||||
use Laravel\Passport\Passport;
|
||||
@@ -42,6 +43,8 @@ use Tests\TestCase;
|
||||
/**
|
||||
*
|
||||
* Class RuleControllerTest
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*/
|
||||
class RuleControllerTest extends TestCase
|
||||
{
|
||||
@@ -102,7 +105,7 @@ class RuleControllerTest extends TestCase
|
||||
$ruleRepos->shouldReceive('store')->once()->andReturn($rule);
|
||||
|
||||
// test API
|
||||
$response = $this->post('/api/v1/rules', $data, ['Accept' => 'application/json']);
|
||||
$response = $this->post(route('api.v1.rules.store'), $data, ['Accept' => 'application/json']);
|
||||
$response->assertStatus(200);
|
||||
|
||||
}
|
||||
@@ -115,11 +118,10 @@ class RuleControllerTest extends TestCase
|
||||
{
|
||||
$ruleRepos = $this->mock(RuleRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$transformer = $this->mock(RuleTransformer::class);
|
||||
$this->mock(RuleTransformer::class);
|
||||
|
||||
$accountRepos->shouldReceive('setUser')->once();
|
||||
$ruleRepos->shouldReceive('setUser')->once();
|
||||
$rule = $this->user()->rules()->first();
|
||||
$data = [
|
||||
'title' => 'Store new rule',
|
||||
'rule_group_id' => 1,
|
||||
@@ -139,7 +141,7 @@ class RuleControllerTest extends TestCase
|
||||
];
|
||||
|
||||
// test API
|
||||
$response = $this->post('/api/v1/rules', $data, ['Accept' => 'application/json']);
|
||||
$response = $this->post(route('api.v1.rules.store'), $data, ['Accept' => 'application/json']);
|
||||
$response->assertStatus(422);
|
||||
}
|
||||
|
||||
@@ -151,11 +153,10 @@ class RuleControllerTest extends TestCase
|
||||
{
|
||||
$ruleRepos = $this->mock(RuleRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$transformer = $this->mock(RuleTransformer::class);
|
||||
$this->mock(RuleTransformer::class);
|
||||
|
||||
$accountRepos->shouldReceive('setUser')->once();
|
||||
$ruleRepos->shouldReceive('setUser')->once();
|
||||
$rule = $this->user()->rules()->first();
|
||||
$data = [
|
||||
'title' => 'Store new rule',
|
||||
'rule_group_id' => 1,
|
||||
@@ -175,7 +176,7 @@ class RuleControllerTest extends TestCase
|
||||
];
|
||||
|
||||
// test API
|
||||
$response = $this->post('/api/v1/rules', $data, ['Accept' => 'application/json']);
|
||||
$response = $this->post(route('api.v1.rules.store'), $data, ['Accept' => 'application/json']);
|
||||
$response->assertStatus(422);
|
||||
$response->assertSee('');
|
||||
|
||||
@@ -186,27 +187,23 @@ class RuleControllerTest extends TestCase
|
||||
*/
|
||||
public function testTestRule(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$rule = $this->user()->rules()->first();
|
||||
|
||||
// mock used classes.
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$matcher = $this->mock(TransactionMatcher::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$ruleRepos = $this->mock(RuleRepositoryInterface::class);
|
||||
$transformer = $this->mock(TransactionTransformer::class);
|
||||
|
||||
$transformer->shouldReceive('setParameters')->atLeast()->once();
|
||||
$transformer = $this->mock(TransactionGroupTransformer::class);
|
||||
|
||||
$asset = $this->getRandomAsset();
|
||||
$expense= $this->getRandomExpense();
|
||||
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$ruleRepos->shouldReceive('setUser')->once();
|
||||
|
||||
$repository->shouldReceive('findNull')->withArgs([1])->andReturn($asset);
|
||||
$repository->shouldReceive('findNull')->withArgs([2])->andReturn($asset);
|
||||
$repository->shouldReceive('findNull')->withArgs([2])->andReturn($expense);
|
||||
$repository->shouldReceive('findNull')->withArgs([3])->andReturn(null);
|
||||
$repository->shouldReceive('isAsset')->withArgs([1])->andReturn(true);
|
||||
$repository->shouldReceive('isAsset')->withArgs([2])->andReturn(false);
|
||||
|
||||
$matcher->shouldReceive('setRule')->once();
|
||||
$matcher->shouldReceive('setEndDate')->once();
|
||||
@@ -214,7 +211,16 @@ class RuleControllerTest extends TestCase
|
||||
$matcher->shouldReceive('setSearchLimit')->once();
|
||||
$matcher->shouldReceive('setTriggeredLimit')->once();
|
||||
$matcher->shouldReceive('setAccounts')->once();
|
||||
$matcher->shouldReceive('findTransactionsByRule')->once()->andReturn(new Collection);
|
||||
$matcher->shouldReceive('findTransactionsByRule')->once()->andReturn([[1]]);
|
||||
|
||||
// mock calls to transformer:
|
||||
$transformer->shouldReceive('setParameters')->withAnyArgs()->atLeast()->once();
|
||||
$transformer->shouldReceive('setCurrentScope')->withAnyArgs()->atLeast()->once()->andReturnSelf();
|
||||
$transformer->shouldReceive('getDefaultIncludes')->withAnyArgs()->atLeast()->once()->andReturn([]);
|
||||
$transformer->shouldReceive('getAvailableIncludes')->withAnyArgs()->atLeast()->once()->andReturn([]);
|
||||
$transformer->shouldReceive('transform')->atLeast()->once()->andReturn(['id' => 5]);
|
||||
|
||||
|
||||
|
||||
|
||||
$response = $this->get(route('api.v1.rules.test', [$rule->id]) . '?accounts=1,2,3');
|
||||
@@ -226,7 +232,9 @@ class RuleControllerTest extends TestCase
|
||||
*/
|
||||
public function testTriggerRule(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$rule = $this->user()->rules()->first();
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$matcher = $this->mock(TransactionMatcher::class);
|
||||
@@ -261,6 +269,9 @@ class RuleControllerTest extends TestCase
|
||||
*/
|
||||
public function testUpdate(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$ruleRepos = $this->mock(RuleRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$transformer = $this->mock(RuleTransformer::class);
|
||||
|
@@ -60,6 +60,9 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreFailDescription(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$source = $this->getRandomAsset();
|
||||
|
||||
@@ -110,6 +113,9 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreFailDestination(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$source = $this->getRandomAsset();
|
||||
|
||||
@@ -163,6 +169,9 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreFailForeignCurrencyAmount(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$source = $this->getRandomAsset();
|
||||
|
||||
@@ -214,6 +223,9 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreFailForeignCurrencyInfo(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$source = $this->getRandomAsset();
|
||||
|
||||
@@ -265,6 +277,9 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreFailSource(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$source = $this->getRandomAsset();
|
||||
|
||||
@@ -317,6 +332,9 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreFailStoreGroupTitle(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$source = $this->getRandomAsset();
|
||||
|
||||
@@ -374,6 +392,9 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreFailStoreNoTransactions(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock repository
|
||||
$repository = $this->mock(TransactionGroupRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
@@ -410,6 +431,9 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreFailTypes(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$source = $this->getRandomAsset();
|
||||
|
||||
@@ -470,6 +494,9 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreFailTypesDeposit(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$source = $this->getRandomAsset();
|
||||
|
||||
@@ -531,6 +558,9 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreFailTypesTransfer(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$source = $this->getRandomAsset();
|
||||
$dest = $this->getRandomAsset($source->id);
|
||||
@@ -596,6 +626,9 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreOK(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$source = $this->getRandomAsset();
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
@@ -677,6 +710,9 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testUpdateFailBadJournal(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
|
||||
@@ -734,6 +770,9 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testUpdateFailDepositDestination(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
|
||||
@@ -794,6 +833,9 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testUpdateFailTransferDestination(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
|
||||
@@ -855,6 +897,8 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testUpdateFailTypes(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
return;
|
||||
// mock data:
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
|
||||
@@ -913,6 +957,8 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testUpdateFailWithdrawalSource(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
return;
|
||||
// mock data:
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
|
||||
@@ -973,6 +1019,8 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testUpdateOK(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
return;
|
||||
// mock data:
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
|
||||
|
@@ -228,7 +228,7 @@ abstract class TestCase extends BaseTestCase
|
||||
TransactionCollectorInterface::class,
|
||||
];
|
||||
if (in_array($class, $deprecated, true)) {
|
||||
throw new RuntimeException('Should not be mocking the transaction collector.');
|
||||
throw new RuntimeException(strtoupper('Must not be mocking the transaction collector or transformer.'));
|
||||
}
|
||||
Log::debug(sprintf('Will now mock %s', $class));
|
||||
$object = Mockery::mock($class);
|
||||
|
Reference in New Issue
Block a user