From 895762ff18db932826ad20eb75ef11f4c34e30e8 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 1 Aug 2020 05:31:26 +0200 Subject: [PATCH] Move tests --- .../Correction/CreateAccessTokensTest.php | 0 .../Correction/CreateLinkTypesTest.php | 0 .../Correction/DeleteEmptyGroupsTest.php | 0 .../Correction/DeleteEmptyJournalsTest.php | 0 .../DeleteOrphanedTransactionsTest.php | 0 .../Correction/DeleteZeroAmountTest.php | 0 .../Correction/EnableCurrenciesTest.php | 0 .../Correction/FixAccountTypesTest.php | 0 .../Commands/Correction/FixPiggiesTest.php | 0 .../Correction/FixUnevenAmountTest.php | 0 .../Commands/Correction/RemoveBillsTest.php | 0 .../Correction/RenameMetaFieldsTest.php | 0 .../Correction/TransferBudgetsTest.php | 0 .../Console/Commands/DecryptDatabaseTest.php | 0 .../Integrity/ReportEmptyObjectsTest.php | 0 .../Commands/Integrity/ReportSumTest.php | 0 .../Console/Commands/Tools/ApplyRulesTest.php | 0 .../Upgrade/AccountCurrenciesTest.php | 0 .../Commands/Upgrade/BackToJournalsTest.php | 0 .../Upgrade/BudgetLimitCurrencyTest.php | 0 .../Commands/Upgrade/CCLiabilitiesTest.php | 0 .../Upgrade/MigrateAttachmentsTest.php | 0 .../Upgrade/MigrateJournalNotesTest.php | 0 .../Commands/Upgrade/MigrateToGroupsTest.php | 0 .../Commands/Upgrade/MigrateToRulesTest.php | 0 .../OtherCurrenciesCorrectionsTest.php | 0 .../Upgrade/RenameAccountMetaTest.php | 0 .../Upgrade/TransactionIdentifierTest.php | 0 .../TransferCurrenciesCorrectionsTest.php | 0 tests/Support/TestDataTrait.php | 495 ------------------ tests/{ => Unit}/Support/AmountTest.php | 0 31 files changed, 495 deletions(-) rename tests/{Unit => Feature}/Console/Commands/Correction/CreateAccessTokensTest.php (100%) rename tests/{Unit => Feature}/Console/Commands/Correction/CreateLinkTypesTest.php (100%) rename tests/{Unit => Feature}/Console/Commands/Correction/DeleteEmptyGroupsTest.php (100%) rename tests/{Unit => Feature}/Console/Commands/Correction/DeleteEmptyJournalsTest.php (100%) rename tests/{Unit => Feature}/Console/Commands/Correction/DeleteOrphanedTransactionsTest.php (100%) rename tests/{Unit => Feature}/Console/Commands/Correction/DeleteZeroAmountTest.php (100%) rename tests/{Unit => Feature}/Console/Commands/Correction/EnableCurrenciesTest.php (100%) rename tests/{Unit => Feature}/Console/Commands/Correction/FixAccountTypesTest.php (100%) rename tests/{Unit => Feature}/Console/Commands/Correction/FixPiggiesTest.php (100%) rename tests/{Unit => Feature}/Console/Commands/Correction/FixUnevenAmountTest.php (100%) rename tests/{Unit => Feature}/Console/Commands/Correction/RemoveBillsTest.php (100%) rename tests/{Unit => Feature}/Console/Commands/Correction/RenameMetaFieldsTest.php (100%) rename tests/{Unit => Feature}/Console/Commands/Correction/TransferBudgetsTest.php (100%) rename tests/{Unit => Feature}/Console/Commands/DecryptDatabaseTest.php (100%) rename tests/{Unit => Feature}/Console/Commands/Integrity/ReportEmptyObjectsTest.php (100%) rename tests/{Unit => Feature}/Console/Commands/Integrity/ReportSumTest.php (100%) rename tests/{Unit => Feature}/Console/Commands/Tools/ApplyRulesTest.php (100%) rename tests/{Unit => Feature}/Console/Commands/Upgrade/AccountCurrenciesTest.php (100%) rename tests/{Unit => Feature}/Console/Commands/Upgrade/BackToJournalsTest.php (100%) rename tests/{Unit => Feature}/Console/Commands/Upgrade/BudgetLimitCurrencyTest.php (100%) rename tests/{Unit => Feature}/Console/Commands/Upgrade/CCLiabilitiesTest.php (100%) rename tests/{Unit => Feature}/Console/Commands/Upgrade/MigrateAttachmentsTest.php (100%) rename tests/{Unit => Feature}/Console/Commands/Upgrade/MigrateJournalNotesTest.php (100%) rename tests/{Unit => Feature}/Console/Commands/Upgrade/MigrateToGroupsTest.php (100%) rename tests/{Unit => Feature}/Console/Commands/Upgrade/MigrateToRulesTest.php (100%) rename tests/{Unit => Feature}/Console/Commands/Upgrade/OtherCurrenciesCorrectionsTest.php (100%) rename tests/{Unit => Feature}/Console/Commands/Upgrade/RenameAccountMetaTest.php (100%) rename tests/{Unit => Feature}/Console/Commands/Upgrade/TransactionIdentifierTest.php (100%) rename tests/{Unit => Feature}/Console/Commands/Upgrade/TransferCurrenciesCorrectionsTest.php (100%) delete mode 100644 tests/Support/TestDataTrait.php rename tests/{ => Unit}/Support/AmountTest.php (100%) diff --git a/tests/Unit/Console/Commands/Correction/CreateAccessTokensTest.php b/tests/Feature/Console/Commands/Correction/CreateAccessTokensTest.php similarity index 100% rename from tests/Unit/Console/Commands/Correction/CreateAccessTokensTest.php rename to tests/Feature/Console/Commands/Correction/CreateAccessTokensTest.php diff --git a/tests/Unit/Console/Commands/Correction/CreateLinkTypesTest.php b/tests/Feature/Console/Commands/Correction/CreateLinkTypesTest.php similarity index 100% rename from tests/Unit/Console/Commands/Correction/CreateLinkTypesTest.php rename to tests/Feature/Console/Commands/Correction/CreateLinkTypesTest.php diff --git a/tests/Unit/Console/Commands/Correction/DeleteEmptyGroupsTest.php b/tests/Feature/Console/Commands/Correction/DeleteEmptyGroupsTest.php similarity index 100% rename from tests/Unit/Console/Commands/Correction/DeleteEmptyGroupsTest.php rename to tests/Feature/Console/Commands/Correction/DeleteEmptyGroupsTest.php diff --git a/tests/Unit/Console/Commands/Correction/DeleteEmptyJournalsTest.php b/tests/Feature/Console/Commands/Correction/DeleteEmptyJournalsTest.php similarity index 100% rename from tests/Unit/Console/Commands/Correction/DeleteEmptyJournalsTest.php rename to tests/Feature/Console/Commands/Correction/DeleteEmptyJournalsTest.php diff --git a/tests/Unit/Console/Commands/Correction/DeleteOrphanedTransactionsTest.php b/tests/Feature/Console/Commands/Correction/DeleteOrphanedTransactionsTest.php similarity index 100% rename from tests/Unit/Console/Commands/Correction/DeleteOrphanedTransactionsTest.php rename to tests/Feature/Console/Commands/Correction/DeleteOrphanedTransactionsTest.php diff --git a/tests/Unit/Console/Commands/Correction/DeleteZeroAmountTest.php b/tests/Feature/Console/Commands/Correction/DeleteZeroAmountTest.php similarity index 100% rename from tests/Unit/Console/Commands/Correction/DeleteZeroAmountTest.php rename to tests/Feature/Console/Commands/Correction/DeleteZeroAmountTest.php diff --git a/tests/Unit/Console/Commands/Correction/EnableCurrenciesTest.php b/tests/Feature/Console/Commands/Correction/EnableCurrenciesTest.php similarity index 100% rename from tests/Unit/Console/Commands/Correction/EnableCurrenciesTest.php rename to tests/Feature/Console/Commands/Correction/EnableCurrenciesTest.php diff --git a/tests/Unit/Console/Commands/Correction/FixAccountTypesTest.php b/tests/Feature/Console/Commands/Correction/FixAccountTypesTest.php similarity index 100% rename from tests/Unit/Console/Commands/Correction/FixAccountTypesTest.php rename to tests/Feature/Console/Commands/Correction/FixAccountTypesTest.php diff --git a/tests/Unit/Console/Commands/Correction/FixPiggiesTest.php b/tests/Feature/Console/Commands/Correction/FixPiggiesTest.php similarity index 100% rename from tests/Unit/Console/Commands/Correction/FixPiggiesTest.php rename to tests/Feature/Console/Commands/Correction/FixPiggiesTest.php diff --git a/tests/Unit/Console/Commands/Correction/FixUnevenAmountTest.php b/tests/Feature/Console/Commands/Correction/FixUnevenAmountTest.php similarity index 100% rename from tests/Unit/Console/Commands/Correction/FixUnevenAmountTest.php rename to tests/Feature/Console/Commands/Correction/FixUnevenAmountTest.php diff --git a/tests/Unit/Console/Commands/Correction/RemoveBillsTest.php b/tests/Feature/Console/Commands/Correction/RemoveBillsTest.php similarity index 100% rename from tests/Unit/Console/Commands/Correction/RemoveBillsTest.php rename to tests/Feature/Console/Commands/Correction/RemoveBillsTest.php diff --git a/tests/Unit/Console/Commands/Correction/RenameMetaFieldsTest.php b/tests/Feature/Console/Commands/Correction/RenameMetaFieldsTest.php similarity index 100% rename from tests/Unit/Console/Commands/Correction/RenameMetaFieldsTest.php rename to tests/Feature/Console/Commands/Correction/RenameMetaFieldsTest.php diff --git a/tests/Unit/Console/Commands/Correction/TransferBudgetsTest.php b/tests/Feature/Console/Commands/Correction/TransferBudgetsTest.php similarity index 100% rename from tests/Unit/Console/Commands/Correction/TransferBudgetsTest.php rename to tests/Feature/Console/Commands/Correction/TransferBudgetsTest.php diff --git a/tests/Unit/Console/Commands/DecryptDatabaseTest.php b/tests/Feature/Console/Commands/DecryptDatabaseTest.php similarity index 100% rename from tests/Unit/Console/Commands/DecryptDatabaseTest.php rename to tests/Feature/Console/Commands/DecryptDatabaseTest.php diff --git a/tests/Unit/Console/Commands/Integrity/ReportEmptyObjectsTest.php b/tests/Feature/Console/Commands/Integrity/ReportEmptyObjectsTest.php similarity index 100% rename from tests/Unit/Console/Commands/Integrity/ReportEmptyObjectsTest.php rename to tests/Feature/Console/Commands/Integrity/ReportEmptyObjectsTest.php diff --git a/tests/Unit/Console/Commands/Integrity/ReportSumTest.php b/tests/Feature/Console/Commands/Integrity/ReportSumTest.php similarity index 100% rename from tests/Unit/Console/Commands/Integrity/ReportSumTest.php rename to tests/Feature/Console/Commands/Integrity/ReportSumTest.php diff --git a/tests/Unit/Console/Commands/Tools/ApplyRulesTest.php b/tests/Feature/Console/Commands/Tools/ApplyRulesTest.php similarity index 100% rename from tests/Unit/Console/Commands/Tools/ApplyRulesTest.php rename to tests/Feature/Console/Commands/Tools/ApplyRulesTest.php diff --git a/tests/Unit/Console/Commands/Upgrade/AccountCurrenciesTest.php b/tests/Feature/Console/Commands/Upgrade/AccountCurrenciesTest.php similarity index 100% rename from tests/Unit/Console/Commands/Upgrade/AccountCurrenciesTest.php rename to tests/Feature/Console/Commands/Upgrade/AccountCurrenciesTest.php diff --git a/tests/Unit/Console/Commands/Upgrade/BackToJournalsTest.php b/tests/Feature/Console/Commands/Upgrade/BackToJournalsTest.php similarity index 100% rename from tests/Unit/Console/Commands/Upgrade/BackToJournalsTest.php rename to tests/Feature/Console/Commands/Upgrade/BackToJournalsTest.php diff --git a/tests/Unit/Console/Commands/Upgrade/BudgetLimitCurrencyTest.php b/tests/Feature/Console/Commands/Upgrade/BudgetLimitCurrencyTest.php similarity index 100% rename from tests/Unit/Console/Commands/Upgrade/BudgetLimitCurrencyTest.php rename to tests/Feature/Console/Commands/Upgrade/BudgetLimitCurrencyTest.php diff --git a/tests/Unit/Console/Commands/Upgrade/CCLiabilitiesTest.php b/tests/Feature/Console/Commands/Upgrade/CCLiabilitiesTest.php similarity index 100% rename from tests/Unit/Console/Commands/Upgrade/CCLiabilitiesTest.php rename to tests/Feature/Console/Commands/Upgrade/CCLiabilitiesTest.php diff --git a/tests/Unit/Console/Commands/Upgrade/MigrateAttachmentsTest.php b/tests/Feature/Console/Commands/Upgrade/MigrateAttachmentsTest.php similarity index 100% rename from tests/Unit/Console/Commands/Upgrade/MigrateAttachmentsTest.php rename to tests/Feature/Console/Commands/Upgrade/MigrateAttachmentsTest.php diff --git a/tests/Unit/Console/Commands/Upgrade/MigrateJournalNotesTest.php b/tests/Feature/Console/Commands/Upgrade/MigrateJournalNotesTest.php similarity index 100% rename from tests/Unit/Console/Commands/Upgrade/MigrateJournalNotesTest.php rename to tests/Feature/Console/Commands/Upgrade/MigrateJournalNotesTest.php diff --git a/tests/Unit/Console/Commands/Upgrade/MigrateToGroupsTest.php b/tests/Feature/Console/Commands/Upgrade/MigrateToGroupsTest.php similarity index 100% rename from tests/Unit/Console/Commands/Upgrade/MigrateToGroupsTest.php rename to tests/Feature/Console/Commands/Upgrade/MigrateToGroupsTest.php diff --git a/tests/Unit/Console/Commands/Upgrade/MigrateToRulesTest.php b/tests/Feature/Console/Commands/Upgrade/MigrateToRulesTest.php similarity index 100% rename from tests/Unit/Console/Commands/Upgrade/MigrateToRulesTest.php rename to tests/Feature/Console/Commands/Upgrade/MigrateToRulesTest.php diff --git a/tests/Unit/Console/Commands/Upgrade/OtherCurrenciesCorrectionsTest.php b/tests/Feature/Console/Commands/Upgrade/OtherCurrenciesCorrectionsTest.php similarity index 100% rename from tests/Unit/Console/Commands/Upgrade/OtherCurrenciesCorrectionsTest.php rename to tests/Feature/Console/Commands/Upgrade/OtherCurrenciesCorrectionsTest.php diff --git a/tests/Unit/Console/Commands/Upgrade/RenameAccountMetaTest.php b/tests/Feature/Console/Commands/Upgrade/RenameAccountMetaTest.php similarity index 100% rename from tests/Unit/Console/Commands/Upgrade/RenameAccountMetaTest.php rename to tests/Feature/Console/Commands/Upgrade/RenameAccountMetaTest.php diff --git a/tests/Unit/Console/Commands/Upgrade/TransactionIdentifierTest.php b/tests/Feature/Console/Commands/Upgrade/TransactionIdentifierTest.php similarity index 100% rename from tests/Unit/Console/Commands/Upgrade/TransactionIdentifierTest.php rename to tests/Feature/Console/Commands/Upgrade/TransactionIdentifierTest.php diff --git a/tests/Unit/Console/Commands/Upgrade/TransferCurrenciesCorrectionsTest.php b/tests/Feature/Console/Commands/Upgrade/TransferCurrenciesCorrectionsTest.php similarity index 100% rename from tests/Unit/Console/Commands/Upgrade/TransferCurrenciesCorrectionsTest.php rename to tests/Feature/Console/Commands/Upgrade/TransferCurrenciesCorrectionsTest.php diff --git a/tests/Support/TestDataTrait.php b/tests/Support/TestDataTrait.php deleted file mode 100644 index d6ef309a1d..0000000000 --- a/tests/Support/TestDataTrait.php +++ /dev/null @@ -1,495 +0,0 @@ -. - */ - -declare(strict_types=1); - -namespace Tests\Support; - -use Carbon\Carbon; -use Exception; -use FireflyIII\Models\TransactionCurrency; - -/** - * Trait TestDataTrait - * - * @package Tests\Support - */ -trait TestDataTrait -{ - /** - * Method that returns default data for when the category OperationsRepos - * "listExpenses" method is called. - * - * @return array - */ - protected function categoryListExpenses(): array - { - $eur = TransactionCurrency::where('code', 'EUR')->first(); - $usd = TransactionCurrency::where('code', 'USD')->first(); - $cat1 = $this->user()->categories()->inRandomOrder()->first(); - $cat2 = $this->user()->categories()->inRandomOrder()->where('id', '!=', $cat1->id)->first(); - $data = []; - $amount = 400; - $date = null; - try { - $amount = random_int(100, 2500); - $date = new Carbon; - } catch (Exception $e) { - $e->getMessage(); - } - $amount = bcmul((string)round($amount / 100, 2), '-1'); - - foreach ([$eur, $usd] as $currency) { - $data[$currency->id] = [ - 'currency_id' => $currency->id, - 'currency_name' => $currency->name, - 'currency_symbol' => $currency->symbol, - 'currency_code' => $currency->code, - 'currency_decimal_places' => $currency->decimal_places, - 'categories' => [], - ]; - foreach ([$cat1, $cat2] as $category) { - $data[$currency->id]['categories'][$category->id] = [ - 'id' => $category->id, - 'name' => $category->name, - 'transaction_journals' => [], - ]; - // add two random amounts: - for ($i = 0; $i < 2; $i++) { - $data[$currency->id]['categories'][$category->id]['transaction_journals'][$i] = [ - 'amount' => $amount, - 'date' => $date, - ]; - } - } - } - - return $data; - } - - /** - * Method that returns default data for when the tag OperationsRepos - * "listExpenses" method is called. - * - * @return array - */ - protected function tagListExpenses(): array - { - $eur = TransactionCurrency::where('code', 'EUR')->first(); - $usd = TransactionCurrency::where('code', 'USD')->first(); - $tag1 = $this->user()->tags()->inRandomOrder()->first(); - $tag2 = $this->user()->tags()->inRandomOrder()->where('id', '!=', $tag1->id)->first(); - $data = []; - $amount = 400; - $date = null; - try { - $amount = random_int(100, 2500); - $date = new Carbon; - } catch (Exception $e) { - $e->getMessage(); - } - $amount = bcmul((string)round($amount / 100, 2), '-1'); - - foreach ([$eur, $usd] as $currency) { - $data[$currency->id] = [ - 'currency_id' => $currency->id, - 'currency_name' => $currency->name, - 'currency_symbol' => $currency->symbol, - 'currency_code' => $currency->code, - 'currency_decimal_places' => $currency->decimal_places, - 'categories' => [], - ]; - foreach ([$tag1, $tag2] as $tag) { - $data[$currency->id]['tags'][$tag->id] = [ - 'id' => $tag->id, - 'name' => $tag->tag, - 'transaction_journals' => [], - ]; - // add two random amounts: - for ($i = 0; $i < 2; $i++) { - $data[$currency->id]['categories'][$tag->id]['transaction_journals'][$i] = [ - 'amount' => $amount, - 'date' => $date, - ]; - } - } - } - - return $data; - } - - /** - * Method that returns default data for when the tag OperationsRepos - * "listIncome" method is called. - * - * @return array - */ - protected function tagListIncome(): array - { - $eur = TransactionCurrency::where('code', 'EUR')->first(); - $usd = TransactionCurrency::where('code', 'USD')->first(); - $tag1 = $this->user()->tags()->inRandomOrder()->first(); - $tag2 = $this->user()->tags()->inRandomOrder()->where('id', '!=', $tag1->id)->first(); - $data = []; - $amount = 400; - $date = null; - try { - $amount = random_int(100, 2500); - $date = new Carbon; - } catch (Exception $e) { - $e->getMessage(); - } - $amount = (string)round($amount / 100, 2); - - foreach ([$eur, $usd] as $currency) { - $data[$currency->id] = [ - 'currency_id' => $currency->id, - 'currency_name' => $currency->name, - 'currency_symbol' => $currency->symbol, - 'currency_code' => $currency->code, - 'currency_decimal_places' => $currency->decimal_places, - 'categories' => [], - ]; - foreach ([$tag1, $tag2] as $tag) { - $data[$currency->id]['tags'][$tag->id] = [ - 'id' => $tag->id, - 'name' => $tag->tag, - 'transaction_journals' => [], - ]; - // add two random amounts: - for ($i = 0; $i < 2; $i++) { - $data[$currency->id]['categories'][$tag->id]['transaction_journals'][$i] = [ - 'amount' => $amount, - 'date' => $date, - ]; - } - } - } - - return $data; - } - - /** - * Method that returns default data for when the category OperationsRepos - * "listExpenses" method is called. - * - * @return array - */ - protected function budgetListExpenses(): array - { - $eur = TransactionCurrency::where('code', 'EUR')->first(); - $usd = TransactionCurrency::where('code', 'USD')->first(); - $bud1 = $this->user()->budgets()->inRandomOrder()->first(); - $bud2 = $this->user()->budgets()->inRandomOrder()->where('id', '!=', $bud1->id)->first(); - $data = []; - $amount = 400; - $date = null; - try { - $amount = random_int(100, 2500); - $date = new Carbon; - } catch (Exception $e) { - $e->getMessage(); - } - $amount = bcmul((string)round($amount / 100, 2), '-1'); - - foreach ([$eur, $usd] as $currency) { - $data[$currency->id] = [ - 'currency_id' => $currency->id, - 'currency_name' => $currency->name, - 'currency_symbol' => $currency->symbol, - 'currency_code' => $currency->code, - 'currency_decimal_places' => $currency->decimal_places, - 'categories' => [], - ]; - foreach ([$bud1, $bud2] as $budget) { - $data[$currency->id]['budgets'][$budget->id] = [ - 'id' => $budget->id, - 'name' => $budget->name, - 'transaction_journals' => [], - ]; - // add two random amounts: - for ($i = 0; $i < 2; $i++) { - $data[$currency->id]['budgets'][$budget->id]['transaction_journals'][$i] = [ - 'amount' => $amount, - 'date' => $date, - ]; - } - } - } - - return $data; - } - - /** - * Method that returns default data for when the category OperationsRepos - * "listExpenses" method is called. - * - * @return array - */ - protected function categoryListIncome(): array - { - $eur = TransactionCurrency::where('code', 'EUR')->first(); - $usd = TransactionCurrency::where('code', 'USD')->first(); - $cat1 = $this->user()->categories()->inRandomOrder()->first(); - $cat2 = $this->user()->categories()->inRandomOrder()->where('id', '!=', $cat1->id)->first(); - $data = []; - $amount = 400; - $date = null; - try { - $amount = random_int(100, 2500); - $date = new Carbon; - } catch (Exception $e) { - $e->getMessage(); - } - $amount = (string)round($amount / 100, 2); - - foreach ([$eur, $usd] as $currency) { - $data[$currency->id] = [ - 'currency_id' => $currency->id, - 'currency_name' => $currency->name, - 'currency_symbol' => $currency->symbol, - 'currency_code' => $currency->code, - 'currency_decimal_places' => $currency->decimal_places, - 'categories' => [], - ]; - foreach ([$cat1, $cat2] as $category) { - $data[$currency->id]['categories'][$category->id] = [ - 'id' => $category->id, - 'name' => $category->name, - 'transaction_journals' => [], - ]; - // add two random amounts: - for ($i = 0; $i < 2; $i++) { - $data[$currency->id]['categories'][$category->id]['transaction_journals'][$i] = [ - 'amount' => $amount, - 'date' => $date, - ]; - } - } - } - - return $data; - } - - /** - * Method that returns default data for when the category OperationsController - * "sumExpenses" method is called. - * - * Also applies to NoCategoryRepos::sumExpenses. - * - * @return array - */ - protected function categorySumExpenses(): array - { - $eur = TransactionCurrency::where('code', 'EUR')->first(); - $usd = TransactionCurrency::where('code', 'USD')->first(); - $data = []; - $amount = 400; - try { - $amount = random_int(100, 2500); - } catch (Exception $e) { - $e->getMessage(); - } - $amount = bcmul((string)round($amount / 100, 2), '-1'); - - foreach ([$eur, $usd] as $currency) { - $data[$currency->id] = [ - 'currency_id' => $currency->id, - 'currency_name' => $currency->name, - 'currency_symbol' => $currency->symbol, - 'currency_code' => $currency->code, - 'currency_decimal_places' => $currency->decimal_places, - 'sum' => $amount, - ]; - } - - return $data; - } - - /** - * Method that returns default data for when the budget OperationsController - * "sumExpenses" method is called. - * - * Also works for NoBudgetRepos::sumExpenses - * - * @return array - */ - protected function budgetSumExpenses(): array - { - $eur = TransactionCurrency::where('code', 'EUR')->first(); - $usd = TransactionCurrency::where('code', 'USD')->first(); - $data = []; - $amount = 400; - try { - $amount = random_int(100, 2500); - } catch (Exception $e) { - $e->getMessage(); - } - $amount = bcmul((string)round($amount / 100, 2), '-1'); - - foreach ([$eur, $usd] as $currency) { - $data[$currency->id] = [ - 'currency_id' => $currency->id, - 'currency_name' => $currency->name, - 'currency_symbol' => $currency->symbol, - 'currency_code' => $currency->code, - 'currency_decimal_places' => $currency->decimal_places, - 'sum' => $amount, - ]; - } - - return $data; - } - - /** - * Method that returns default data for when the category OperationsController - * "sumIncome" method is called. - * - * Also applies to NoCategoryRepos::sumIncome. - * - * @return array - */ - protected function categorySumIncome(): array - { - $eur = TransactionCurrency::where('code', 'EUR')->first(); - $usd = TransactionCurrency::where('code', 'USD')->first(); - $data = []; - $amount = 400; - try { - $amount = random_int(100, 2500); - } catch (Exception $e) { - $e->getMessage(); - } - $amount = (string)round($amount / 100, 2); - - foreach ([$eur, $usd] as $currency) { - $data[$currency->id] = [ - 'currency_id' => $currency->id, - 'currency_name' => $currency->name, - 'currency_symbol' => $currency->symbol, - 'currency_code' => $currency->code, - 'currency_decimal_places' => $currency->decimal_places, - 'sum' => $amount, - ]; - } - - return $data; - } - - /** - * Method that returns default data for when the category NoCategoryRepos - * "listExpenses" method is called. - * - * @return array - */ - protected function noCategoryListExpenses(): array - { - $eur = TransactionCurrency::where('code', 'EUR')->first(); - $usd = TransactionCurrency::where('code', 'USD')->first(); - $data = []; - $amount = 400; - $date = null; - try { - $amount = random_int(100, 2500); - $date = new Carbon; - } catch (Exception $e) { - $e->getMessage(); - } - $amount = bcmul((string)round($amount / 100, 2), '-1'); - - foreach ([$eur, $usd] as $currency) { - $data[$currency->id] = [ - 'currency_id' => $currency->id, - 'currency_name' => $currency->name, - 'currency_symbol' => $currency->symbol, - 'currency_code' => $currency->code, - 'currency_decimal_places' => $currency->decimal_places, - 'categories' => [ - 0 => [ - 'id' => 0, - 'name' => 'no cat', - 'transaction_journals' => [], - ], - ], - ]; - - // add two random amounts: - for ($i = 0; $i < 2; $i++) { - $data[$currency->id]['categories'][0]['transaction_journals'][$i] = [ - 'amount' => $amount, - 'date' => $date, - ]; - } - } - - return $data; - } - - /** - * Method that returns default data for when the category NoCategoryRepos - * "listExpenses" method is called. - * - * @return array - */ - protected function noCategoryListIncome(): array - { - $eur = TransactionCurrency::where('code', 'EUR')->first(); - $usd = TransactionCurrency::where('code', 'USD')->first(); - $data = []; - $amount = 400; - $date = null; - try { - $amount = random_int(100, 2500); - $date = new Carbon; - } catch (Exception $e) { - $e->getMessage(); - } - $amount = (string)round($amount / 100, 2); - - foreach ([$eur, $usd] as $currency) { - $data[$currency->id] = [ - 'currency_id' => $currency->id, - 'currency_name' => $currency->name, - 'currency_symbol' => $currency->symbol, - 'currency_code' => $currency->code, - 'currency_decimal_places' => $currency->decimal_places, - 'categories' => [ - 0 => [ - 'id' => 0, - 'name' => 'no cat', - 'transaction_journals' => [], - ], - ], - ]; - - // add two random amounts: - for ($i = 0; $i < 2; $i++) { - $data[$currency->id]['categories'][0]['transaction_journals'][$i] = [ - 'amount' => $amount, - 'date' => $date, - ]; - } - } - - return $data; - } - -} diff --git a/tests/Support/AmountTest.php b/tests/Unit/Support/AmountTest.php similarity index 100% rename from tests/Support/AmountTest.php rename to tests/Unit/Support/AmountTest.php