Skip to content

Firefly III: a personal finances manager

Fix test coverage.

James Coleae4612f1340d
diff --git a/app/Api/V1/Controllers/AccountController.php b/app/Api/V1/Controllers/AccountController.php
index f82f2881aa..73301d199a 100644
--- a/app/Api/V1/Controllers/AccountController.php
+++ b/app/Api/V1/Controllers/AccountController.php
@@ -256,9 +256,7 @@ class AccountController extends Controller
$paginator = $collector->getPaginatedTransactions();
$paginator->setPath(route('api.v1.accounts.transactions', [$account->id]) . $this->buildParams());
$transactions = $paginator->getCollection();
- $repository = app(JournalRepositoryInterface::class);
-
- $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters, $repository), 'transactions');
+ $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters), 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
diff --git a/app/Api/V1/Controllers/BillController.php b/app/Api/V1/Controllers/BillController.php
index cda5100045..a7ffec5b0f 100644
--- a/app/Api/V1/Controllers/BillController.php
+++ b/app/Api/V1/Controllers/BillController.php
@@ -260,8 +260,7 @@ class BillController extends Controller
$paginator = $collector->getPaginatedTransactions();
$paginator->setPath(route('api.v1.bills.transactions', [$bill->id]) . $this->buildParams());
$transactions = $paginator->getCollection();
- $repository = app(JournalRepositoryInterface::class);
- $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters, $repository), 'transactions');
+ $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters), 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
diff --git a/app/Api/V1/Controllers/BudgetController.php b/app/Api/V1/Controllers/BudgetController.php
index b8ee458896..bd45020a7e 100644
--- a/app/Api/V1/Controllers/BudgetController.php
+++ b/app/Api/V1/Controllers/BudgetController.php
@@ -256,9 +256,7 @@ class BudgetController extends Controller
$paginator = $collector->getPaginatedTransactions();
$paginator->setPath(route('api.v1.budgets.transactions', [$budget->id]) . $this->buildParams());
$transactions = $paginator->getCollection();
- $repository = app(JournalRepositoryInterface::class);
-
- $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters, $repository), 'transactions');
+ $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters), 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
diff --git a/app/Api/V1/Controllers/BudgetLimitController.php b/app/Api/V1/Controllers/BudgetLimitController.php
index 42383442d6..e227c77200 100644
--- a/app/Api/V1/Controllers/BudgetLimitController.php
+++ b/app/Api/V1/Controllers/BudgetLimitController.php
@@ -208,9 +208,7 @@ class BudgetLimitController extends Controller
$paginator = $collector->getPaginatedTransactions();
$paginator->setPath(route('api.v1.budget_limits.transactions', [$budgetLimit->id]) . $this->buildParams());
$transactions = $paginator->getCollection();
- $repository = app(JournalRepositoryInterface::class);
-
- $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters, $repository), 'transactions');
+ $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters), 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
diff --git a/app/Api/V1/Controllers/CategoryController.php b/app/Api/V1/Controllers/CategoryController.php
index cb631a6957..c8fb61a2b3 100644
--- a/app/Api/V1/Controllers/CategoryController.php
+++ b/app/Api/V1/Controllers/CategoryController.php
@@ -206,9 +206,7 @@ class CategoryController extends Controller
$paginator = $collector->getPaginatedTransactions();
$paginator->setPath(route('api.v1.categories.transactions', [$category->id]) . $this->buildParams());
$transactions = $paginator->getCollection();
- $repository = app(JournalRepositoryInterface::class);
-
- $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters, $repository), 'transactions');
+ $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters), 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
diff --git a/app/Api/V1/Controllers/CurrencyController.php b/app/Api/V1/Controllers/CurrencyController.php
index e721820a2c..8bb3e7de58 100644
--- a/app/Api/V1/Controllers/CurrencyController.php
+++ b/app/Api/V1/Controllers/CurrencyController.php
@@ -195,8 +195,7 @@ class CurrencyController extends Controller
$paginator->setPath(route('api.v1.currencies.transactions', [$currency->code]) . $this->buildParams());
$transactions = $paginator->getCollection();
- $journalRepository = app(JournalRepositoryInterface::class);
- $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters, $journalRepository), 'transactions');
+ $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters), 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
diff --git a/app/Api/V1/Controllers/ImportController.php b/app/Api/V1/Controllers/ImportController.php
index 4f48bdcc59..aa2c4423f2 100644
--- a/app/Api/V1/Controllers/ImportController.php
+++ b/app/Api/V1/Controllers/ImportController.php
@@ -163,8 +163,7 @@ class ImportController extends Controller
}
- $repository = app(JournalRepositoryInterface::class);
- $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters, $repository), 'transactions');
+ $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters), 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
diff --git a/app/Api/V1/Controllers/LinkTypeController.php b/app/Api/V1/Controllers/LinkTypeController.php
index 0255221416..0bd9e09a16 100644
--- a/app/Api/V1/Controllers/LinkTypeController.php
+++ b/app/Api/V1/Controllers/LinkTypeController.php
@@ -218,9 +218,7 @@ class LinkTypeController extends Controller
$paginator = $collector->getPaginatedTransactions();
$paginator->setPath(route('api.v1.transactions.index') . $this->buildParams());
$transactions = $paginator->getCollection();
- $repository = app(JournalRepositoryInterface::class);
-
- $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters, $repository), 'transactions');
+ $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters), 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
diff --git a/app/Api/V1/Controllers/RecurrenceController.php b/app/Api/V1/Controllers/RecurrenceController.php
index b4e4b15dbf..8a4184d187 100644
--- a/app/Api/V1/Controllers/RecurrenceController.php
+++ b/app/Api/V1/Controllers/RecurrenceController.php
@@ -205,9 +205,7 @@ class RecurrenceController extends Controller
$paginator = $collector->getPaginatedTransactions();
$paginator->setPath(route('api.v1.transactions.index') . $this->buildParams());
$transactions = $paginator->getCollection();
- $repository = app(JournalRepositoryInterface::class);
-
- $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters, $repository), 'transactions');
+ $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters), 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
diff --git a/app/Api/V1/Controllers/RuleController.php b/app/Api/V1/Controllers/RuleController.php
index 445b44133f..f15ed0de92 100644
--- a/app/Api/V1/Controllers/RuleController.php
+++ b/app/Api/V1/Controllers/RuleController.php
@@ -222,9 +222,7 @@ class RuleController extends Controller
$manager = new Manager();
$baseUrl = $request->getSchemeAndHttpHost() . '/api/v1';
$manager->setSerializer(new JsonApiSerializer($baseUrl));
- $repository = app(JournalRepositoryInterface::class);
-
- $resource = new FractalCollection($matchingTransactions, new TransactionTransformer($this->parameters, $repository), 'transactions');
+ $resource = new FractalCollection($matchingTransactions, new TransactionTransformer($this->parameters), 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
diff --git a/app/Api/V1/Controllers/RuleGroupController.php b/app/Api/V1/Controllers/RuleGroupController.php
index 6552e97b90..6000a29cd6 100644
--- a/app/Api/V1/Controllers/RuleGroupController.php
+++ b/app/Api/V1/Controllers/RuleGroupController.php
@@ -269,10 +269,7 @@ class RuleGroupController extends Controller
$manager = new Manager();
$baseUrl = $request->getSchemeAndHttpHost() . '/api/v1';
$manager->setSerializer(new JsonApiSerializer($baseUrl));
- $repository = app(JournalRepositoryInterface::class);
-
-
- $resource = new FractalCollection($matchingTransactions, new TransactionTransformer($this->parameters, $repository), 'transactions');
+ $resource = new FractalCollection($matchingTransactions, new TransactionTransformer($this->parameters), 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
diff --git a/app/Api/V1/Controllers/TagController.php b/app/Api/V1/Controllers/TagController.php
index 9d7f7828f2..268a4316ab 100644
--- a/app/Api/V1/Controllers/TagController.php
+++ b/app/Api/V1/Controllers/TagController.php
@@ -182,9 +182,7 @@ class TagController extends Controller
$paginator->setPath(route('api.v1.transactions.index') . $this->buildParams());
$transactions = $paginator->getCollection();
- $repository = app(JournalRepositoryInterface::class);
-
- $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters, $repository), 'transactions');
+ $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters), 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
diff --git a/app/Api/V1/Controllers/TransactionController.php b/app/Api/V1/Controllers/TransactionController.php
index 0fdd10a8e9..4fca237302 100644
--- a/app/Api/V1/Controllers/TransactionController.php
+++ b/app/Api/V1/Controllers/TransactionController.php
@@ -171,7 +171,7 @@ class TransactionController extends Controller
$paginator->setPath(route('api.v1.transactions.index') . $this->buildParams());
$transactions = $paginator->getCollection();
- $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters, $this->repository), 'transactions');
+ $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters), 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
@@ -208,7 +208,7 @@ class TransactionController extends Controller
}
$transactions = $collector->getTransactions();
- $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters, $this->repository), 'transactions');
+ $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters), 'transactions');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
}
@@ -252,7 +252,7 @@ class TransactionController extends Controller
}
$transactions = $collector->getTransactions();
- $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters, $this->repository), 'transactions');
+ $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters), 'transactions');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
}
@@ -296,7 +296,7 @@ class TransactionController extends Controller
}
$transactions = $collector->getTransactions();
- $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters, $this->repository), 'transactions');
+ $resource = new FractalCollection($transactions, new TransactionTransformer($this->parameters), 'transactions');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
diff --git a/app/Api/V1/Requests/CurrencyRequest.php b/app/Api/V1/Requests/CurrencyRequest.php
index 09e51f8935..c145a78142 100644
--- a/app/Api/V1/Requests/CurrencyRequest.php
+++ b/app/Api/V1/Requests/CurrencyRequest.php
@@ -90,7 +90,7 @@ class CurrencyRequest extends Request
break;
case 'PUT':
case 'PATCH':
- $currency = $this->route()->parameter('currency');
+ $currency = $this->route()->parameter('currency_code');
$rules['name'] = 'required|between:1,255|unique:transaction_currencies,name,' . $currency->id;
$rules['code'] = 'required|between:1,255|unique:transaction_currencies,code,' . $currency->id;
$rules['symbol'] = 'required|between:1,255|unique:transaction_currencies,symbol,' . $currency->id;
diff --git a/app/Api/V1/Requests/RuleRequest.php b/app/Api/V1/Requests/RuleRequest.php
index 84430f7397..7eee6982b1 100644
--- a/app/Api/V1/Requests/RuleRequest.php
+++ b/app/Api/V1/Requests/RuleRequest.php
@@ -102,9 +102,9 @@ class RuleRequest extends Request
'trigger' => 'required|in:store-journal,update-journal',
'triggers.*.name' => 'required|in:' . implode(',', $validTriggers),
'triggers.*.stop_processing' => [new IsBoolean],
- 'triggers.*.value' => 'required_if:rule_actions.*.type,' . $contextTriggers . '|min:1|ruleTriggerValue',
+ 'triggers.*.value' => 'required_if:actions.*.type,' . $contextTriggers . '|min:1|ruleTriggerValue',
'actions.*.name' => 'required|in:' . implode(',', $validActions),
- 'actions.*.value' => 'required_if:rule_actions.*.type,' . $contextActions . '|ruleActionValue',
+ 'actions.*.value' => 'required_if:actions.*.type,' . $contextActions . '|ruleActionValue',
'actions.*.stop_processing' => [new IsBoolean],
'strict' => [new IsBoolean],
'stop_processing' => [new IsBoolean],
diff --git a/app/Http/Controllers/Rule/EditController.php b/app/Http/Controllers/Rule/EditController.php
index c4c4623e68..b4f000bb9d 100644
--- a/app/Http/Controllers/Rule/EditController.php
+++ b/app/Http/Controllers/Rule/EditController.php
@@ -158,9 +158,9 @@ class EditController extends Controller
{
$index = 0;
$actions = [];
-
+ $currentActions = $rule->ruleActions()->orderBy('order','ASC')->get();
/** @var RuleAction $entry */
- foreach ($rule->ruleActions as $entry) {
+ foreach ($currentActions as $entry) {
$count = ($index + 1);
try {
$actions[] = view(
@@ -196,9 +196,9 @@ class EditController extends Controller
{
$index = 0;
$triggers = [];
-
+ $currentTriggers = $rule->ruleTriggers()->orderBy('order','ASC')->get();
/** @var RuleTrigger $entry */
- foreach ($rule->ruleTriggers as $entry) {
+ foreach ($currentTriggers as $entry) {
if ('user_action' !== $entry->trigger_type) {
$count = ($index + 1);
try {
diff --git a/app/Http/Controllers/Rule/SelectController.php b/app/Http/Controllers/Rule/SelectController.php
index a9471ea3cf..1f3d54ec14 100644
--- a/app/Http/Controllers/Rule/SelectController.php
+++ b/app/Http/Controllers/Rule/SelectController.php
@@ -155,8 +155,8 @@ class SelectController extends Controller
$strict = '1' === $request->get('strict');
/** @var TransactionMatcher $matcher */
$matcher = app(TransactionMatcher::class);
- $matcher->setLimit($limit);
- $matcher->setRange($range);
+ $matcher->setSearchLimit($range);
+ $matcher->setTriggeredLimit($limit);
$matcher->setTriggers($triggers);
$matcher->setStrict($strict);
try {
@@ -222,8 +222,8 @@ class SelectController extends Controller
/** @var TransactionMatcher $matcher */
$matcher = app(TransactionMatcher::class);
- $matcher->setLimit($limit);
- $matcher->setRange($range);
+ $matcher->setTriggeredLimit($limit);
+ $matcher->setSearchLimit($range);
$matcher->setRule($rule);
try {
$matchingTransactions = $matcher->findTransactionsByRule();
diff --git a/app/Http/Controllers/Transaction/MassController.php b/app/Http/Controllers/Transaction/MassController.php
index 8f3274ee18..f70652c4f8 100644
--- a/app/Http/Controllers/Transaction/MassController.php
+++ b/app/Http/Controllers/Transaction/MassController.php
@@ -142,7 +142,7 @@ class MassController extends Controller
$this->rememberPreviousUri('transactions.mass-edit.uri');
- $transformer = new TransactionTransformer(new ParameterBag, $this->repository);
+ $transformer = new TransactionTransformer(new ParameterBag);
/** @var TransactionCollectorInterface $collector */
$collector = app(TransactionCollectorInterface::class);
$collector->setUser($user);
diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php
index 0a96f29113..2cabef11f7 100644
--- a/app/Http/Controllers/TransactionController.php
+++ b/app/Http/Controllers/TransactionController.php
@@ -253,7 +253,7 @@ class TransactionController extends Controller
$collector->setJournals(new Collection([$journal]));
$set = $collector->getTransactions();
$transactions = [];
- $transformer = new TransactionTransformer(new ParameterBag, $this->repository);
+ $transformer = new TransactionTransformer(new ParameterBag);
/** @var Transaction $transaction */
foreach ($set as $transaction) {
$transactions[] = $transformer->transform($transaction);
diff --git a/app/Http/Requests/RuleFormRequest.php b/app/Http/Requests/RuleFormRequest.php
index acca6dba81..d6d01409c0 100644
--- a/app/Http/Requests/RuleFormRequest.php
+++ b/app/Http/Requests/RuleFormRequest.php
@@ -58,8 +58,8 @@ class RuleFormRequest extends Request
'description' => $this->string('description'),
'stop_processing' => $this->boolean('stop_processing'),
'strict' => $this->boolean('strict'),
- 'rule_triggers' => $this->getRuleTriggerData(),
- 'rule_actions' => $this->getRuleActionData(),
+ 'triggers' => $this->getRuleTriggerData(),
+ 'actions' => $this->getRuleActionData(),
];
return $data;
@@ -83,16 +83,16 @@ class RuleFormRequest extends Request
// initial set of rules:
$rules = [
- 'title' => 'required|between:1,100|uniqueObjectForUser:rules,title',
- 'description' => 'between:1,5000|nullable',
- 'stop_processing' => 'boolean',
- 'rule_group_id' => 'required|belongsToUser:rule_groups',
- 'trigger' => 'required|in:store-journal,update-journal',
- 'rule_triggers.*.name' => 'required|in:' . implode(',', $validTriggers),
- 'rule_triggers.*.value' => sprintf('required_if:rule_triggers.*.name,%s|min:1|ruleTriggerValue', $contextTriggers),
- 'rule-actions.*.name' => 'required|in:' . implode(',', $validActions),
- 'rule_actions.*.value' => sprintf('required_if:rule_actions.*.name,%s|min:1|ruleActionValue', $contextActions),
- 'strict' => 'in:0,1',
+ 'title' => 'required|between:1,100|uniqueObjectForUser:rules,title',
+ 'description' => 'between:1,5000|nullable',
+ 'stop_processing' => 'boolean',
+ 'rule_group_id' => 'required|belongsToUser:rule_groups',
+ 'trigger' => 'required|in:store-journal,update-journal',
+ 'triggers.*.name' => 'required|in:' . implode(',', $validTriggers),
+ 'triggers.*.value' => sprintf('required_if:triggers.*.name,%s|min:1|ruleTriggerValue', $contextTriggers),
+ 'actions.*.name' => 'required|in:' . implode(',', $validActions),
+ 'actions.*.value' => sprintf('required_if:actions.*.name,%s|min:1|ruleActionValue', $contextActions),
+ 'strict' => 'in:0,1',
];
/** @var Rule $rule */
@@ -111,7 +111,7 @@ class RuleFormRequest extends Request
private function getRuleActionData(): array
{
$return = [];
- $actionData = $this->get('rule_actions');
+ $actionData = $this->get('actions');
if (\is_array($actionData)) {
foreach ($actionData as $action) {
$stopProcessing = $action['stop_processing'] ?? '0';
@@ -132,7 +132,7 @@ class RuleFormRequest extends Request
private function getRuleTriggerData(): array
{
$return = [];
- $triggerData = $this->get('rule_triggers');
+ $triggerData = $this->get('triggers');
if (\is_array($triggerData)) {
foreach ($triggerData as $trigger) {
$stopProcessing = $trigger['stop_processing'] ?? '0';
diff --git a/app/Http/Requests/TestRuleFormRequest.php b/app/Http/Requests/TestRuleFormRequest.php
index 41f2614d60..61e0d7f34d 100644
--- a/app/Http/Requests/TestRuleFormRequest.php
+++ b/app/Http/Requests/TestRuleFormRequest.php
@@ -42,6 +42,7 @@ class TestRuleFormRequest extends Request
/**
* Rules for this request.
+ * TODO these rules are not valid anymore.
*
* @return array
*/
diff --git a/app/Support/Http/Controllers/RequestInformation.php b/app/Support/Http/Controllers/RequestInformation.php
index 900fbad168..d44fcd1630 100644
--- a/app/Support/Http/Controllers/RequestInformation.php
+++ b/app/Support/Http/Controllers/RequestInformation.php
@@ -222,7 +222,6 @@ trait RequestInformation
*/
protected function getTransactionDataFromJournal(TransactionJournal $journal): array // convert object
{
- $repository = app(JournalRepositoryInterface::class);
// use collector to collect transactions.
$collector = app(TransactionCollectorInterface::class);
$collector->setUser(auth()->user());
@@ -231,7 +230,7 @@ trait RequestInformation
$collector->setJournals(new Collection([$journal]));
$set = $collector->getTransactions();
$transactions = [];
- $transformer = new TransactionTransformer(new ParameterBag, $repository);
+ $transformer = new TransactionTransformer(new ParameterBag);
/** @var Transaction $transaction */
foreach ($set as $transaction) {
$res = [];
@@ -262,7 +261,7 @@ trait RequestInformation
protected function getValidTriggerList(TestRuleFormRequest $request): array // process input
{
$triggers = [];
- $data = $request->get('rule_triggers');
+ $data = $request->get('triggers');
if (\is_array($data)) {
foreach ($data as $index => $triggerInfo) {
$triggers[] = [
diff --git a/app/Support/Http/Controllers/RuleManagement.php b/app/Support/Http/Controllers/RuleManagement.php
index ee55a39d7d..66d832dd46 100644
--- a/app/Support/Http/Controllers/RuleManagement.php
+++ b/app/Support/Http/Controllers/RuleManagement.php
@@ -51,7 +51,8 @@ trait RuleManagement
'description' => (string)trans('firefly.default_rule_description'),
'trigger' => 'store-journal',
'strict' => true,
- 'rule_triggers' => [
+ 'active' => true,
+ 'triggers' => [
[
'name' => 'description_is',
'value' => (string)trans('firefly.default_rule_trigger_description'),
@@ -66,7 +67,7 @@ trait RuleManagement
],
],
- 'rule_actions' => [
+ 'actions' => [
[
'name' => 'prepend_description',
'value' => (string)trans('firefly.default_rule_action_prepend'),
@@ -94,7 +95,7 @@ trait RuleManagement
{
$index = 0;
$triggers = [];
- $oldInput = $request->old('rule_actions');
+ $oldInput = $request->old('actions');
if (\is_array($oldInput)) {
foreach ($oldInput as $oldAction) {
try {
@@ -127,7 +128,7 @@ trait RuleManagement
{
$index = 0;
$triggers = [];
- $oldInput = $request->old('rule_triggers');
+ $oldInput = $request->old('triggers');
if (\is_array($oldInput)) {
foreach ($oldInput as $oldTrigger) {
try {
@@ -162,6 +163,7 @@ trait RuleManagement
$data = [
'title' => (string)trans('firefly.default_rule_group_name'),
'description' => (string)trans('firefly.default_rule_group_description'),
+ 'active' => true,
];
$repository->store($data);
diff --git a/app/Transformers/AccountTransformer.php b/app/Transformers/AccountTransformer.php
index 48fc2eccd1..e9a411cac9 100644
--- a/app/Transformers/AccountTransformer.php
+++ b/app/Transformers/AccountTransformer.php
@@ -120,8 +120,8 @@ class AccountTransformer extends TransformerAbstract
'id' => (int)$account->id,
'updated_at' => $account->updated_at->toAtomString(),
'created_at' => $account->created_at->toAtomString(),
- 'name' => $account->name,
'active' => 1 === (int)$account->active,
+ 'name' => $account->name,
'type' => $type,
'account_role' => $role,
'currency_id' => $currencyId,
diff --git a/app/Transformers/TransactionTransformer.php b/app/Transformers/TransactionTransformer.php
index 24e8148457..ff28be211e 100644
--- a/app/Transformers/TransactionTransformer.php
+++ b/app/Transformers/TransactionTransformer.php
@@ -51,10 +51,10 @@ class TransactionTransformer extends TransformerAbstract
* @param ParameterBag $parameters
* @param JournalRepositoryInterface $repository
*/
- public function __construct(ParameterBag $parameters, JournalRepositoryInterface $repository)
+ public function __construct(ParameterBag $parameters)
{
$this->parameters = $parameters;
- $this->repository = $repository;
+ $this->repository = app(JournalRepositoryInterface::class);
}
/**
diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php
index 9841ba6d4f..902987585b 100644
--- a/app/Validation/FireflyValidator.php
+++ b/app/Validation/FireflyValidator.php
@@ -306,7 +306,7 @@ class FireflyValidator extends Validator
}
/**
- * $attribute has the format rule_triggers.%d.value.
+ * $attribute has the format triggers.%d.value.
*
* @param string $attribute
* @param string $value
diff --git a/public/v1/js/ff/rules/create-edit.js b/public/v1/js/ff/rules/create-edit.js
index 420a04aace..e3cc1308ad 100644
--- a/public/v1/js/ff/rules/create-edit.js
+++ b/public/v1/js/ff/rules/create-edit.js
@@ -162,7 +162,7 @@ function onAddNewAction() {
"use strict";
console.log('Now in onAddNewAction()');
- var selectQuery = 'select[name^="rule_actions["][name$="][name]"]';
+ var selectQuery = 'select[name^="actions["][name$="][name]"]';
var selectResult = $(selectQuery);
console.log('Select query is "' + selectQuery + '" and the result length is ' + selectResult.length);
@@ -190,7 +190,7 @@ function onAddNewTrigger() {
"use strict";
console.log('Now in onAddNewTrigger()');
- var selectQuery = 'select[name^="rule_triggers["][name$="][name]"]';
+ var selectQuery = 'select[name^="triggers["][name$="][name]"]';
var selectResult = $(selectQuery);
console.log('Select query is "' + selectQuery + '" and the result length is ' + selectResult.length);
@@ -219,7 +219,7 @@ function updateActionInput(selectList) {
// the actual row this select list is in:
var parent = selectList.parent().parent();
// the text input we're looking for:
- var inputQuery = 'input[name^="rule_actions["][name$="][value]"]';
+ var inputQuery = 'input[name^="actions["][name$="][value]"]';
var inputResult = parent.find(inputQuery);
console.log('Searching for children in this row with query "' + inputQuery + '" resulted in ' + inputResult.length + ' results.');
@@ -291,7 +291,7 @@ function updateTriggerInput(selectList) {
// the actual row this select list is in:
var parent = selectList.parent().parent();
// the text input we're looking for:
- var inputQuery = 'input[name^="rule_triggers["][name$="][value]"]';
+ var inputQuery = 'input[name^="triggers["][name$="][value]"]';
var inputResult = parent.find(inputQuery);
console.log('Searching for children in this row with query "' + inputQuery + '" resulted in ' + inputResult.length + ' results.');
diff --git a/resources/views/v1/rules/partials/action.twig b/resources/views/v1/rules/partials/action.twig
index fda2bc6863..78864f7c8c 100644
--- a/resources/views/v1/rules/partials/action.twig
+++ b/resources/views/v1/rules/partials/action.twig
@@ -4,7 +4,7 @@
</td>
<td style="width:30%;">
{# todo error when invalid name. #}
- <select name="rule_actions[{{ count }}][name]" class="form-control">
+ <select name="actions[{{ count }}][name]" class="form-control">
{% for key,name in allRuleActions() %}
<option value="{{ key }}" label="{{ name }}" {% if key == oldAction %} selected{% endif %}>{{ name }}</option>
{% endfor %}
@@ -12,18 +12,18 @@
</td>
<td style="position: relative;">
- <input autocomplete="off" type="text" value="{{ oldValue }}" name="rule_actions[{{ count }}][value]"
+ <input autocomplete="off" type="text" value="{{ oldValue }}" name="actions[{{ count }}][value]"
class="form-control">
- {% if errors.has('rule_actions.'~count~'.value') %}
+ {% if errors.has('actions.'~count~'.value') %}
<p class="text-danger">
- {{ errors.first('rule_actions.'~count~'.value') }}
+ {{ errors.first('actions.'~count~'.value') }}
</p>
{% endif %}
</td>
<td style="width:20%;">
<div class="checkbox">
<label>
- <input type="checkbox" name="rule_actions[{{ count }}][stop_processing]" value="1"
+ <input type="checkbox" name="actions[{{ count }}][stop_processing]" value="1"
{% if oldChecked %}checked{% endif %}
/>
</label>
diff --git a/resources/views/v1/rules/partials/trigger.twig b/resources/views/v1/rules/partials/trigger.twig
index c5aade93c8..ce86d398ef 100644
--- a/resources/views/v1/rules/partials/trigger.twig
+++ b/resources/views/v1/rules/partials/trigger.twig
@@ -3,14 +3,7 @@
<a href="#" class="btn btn-danger btn-sm remove-trigger"><i class="fa fa-trash"></i></a>
</td>
<td style="width:30%;">
- {#
- {% if errors.has('rule-trigger.'~count) %}
- <span class="form-control-feedback"><i class="fa fa-fw fa-remove"></i></span>
- <p class="text-danger">{{ errors.first('rule-trigger.'~count) }}</p>
- {% endif %}
- #}
-
- <select name="rule_triggers[{{ count }}][name]" class="form-control">
+ <select name="triggers[{{ count }}][name]" class="form-control">
{% for key,name in allRuleTriggers() %}
<option value="{{ key }}" label="{{ name }}"
{% if key == oldTrigger %}
@@ -22,17 +15,17 @@
</td>
<td style="position: relative;">
- <input autocomplete="off" type="text" value="{{ oldValue }}" name="rule_triggers[{{ count }}][value]" class="form-control">
- {% if errors.has('rule_triggers.'~count~'.value') %}
+ <input autocomplete="off" type="text" value="{{ oldValue }}" name="triggers[{{ count }}][value]" class="form-control">
+ {% if errors.has('triggers.'~count~'.value') %}
<p class="text-danger">
- {{ errors.first('rule_triggers.'~count~'.value') }}
+ {{ errors.first('triggers.'~count~'.value') }}
</p>
{% endif %}
</td>
<td style="width:20%;">
<div class="checkbox">
<label>
- <input type="checkbox" name="rule_triggers[{{ count }}][stop_processing]" value="1"
+ <input type="checkbox" name="triggers[{{ count }}][stop_processing]" value="1"
{% if oldChecked %}checked{% endif %}
/>
</label>
diff --git a/tests/Api/V1/Controllers/AccountControllerTest.php b/tests/Api/V1/Controllers/AccountControllerTest.php
index 3ed279af69..9fd573ee99 100644
--- a/tests/Api/V1/Controllers/AccountControllerTest.php
+++ b/tests/Api/V1/Controllers/AccountControllerTest.php
@@ -184,8 +184,9 @@ class AccountControllerTest extends TestCase
[
'message' => 'The given data was invalid.',
'errors' => [
- 'cc_monthly_payment_date' => ['The cc monthly payment date field is required when account role is ccAsset.'],
- 'cc_type' => ['The cc type field is required when account role is ccAsset.'],
+ 'credit_card_type' => ['The credit card type field is required when account role is ccAsset.'],
+ 'monthly_payment_date' => ['The monthly payment date field is required when account role is ccAsset.'],
+
],
]
);
diff --git a/tests/Api/V1/Controllers/BudgetLimitControllerTest.php b/tests/Api/V1/Controllers/BudgetLimitControllerTest.php
index 4f20362d67..17bf4ed966 100644
--- a/tests/Api/V1/Controllers/BudgetLimitControllerTest.php
+++ b/tests/Api/V1/Controllers/BudgetLimitControllerTest.php
@@ -72,7 +72,7 @@ class BudgetLimitControllerTest extends TestCase
);
// call API
- $response = $this->delete('/api/v1/budget_limits/' . $budgetLimit->id);
+ $response = $this->delete('/api/v1/budgets/limits/' . $budgetLimit->id);
$response->assertStatus(204);
}
@@ -97,7 +97,7 @@ class BudgetLimitControllerTest extends TestCase
$params = [
'budget_id' => $budget->id,
];
- $response = $this->get('/api/v1/budget_limits?' . http_build_query($params));
+ $response = $this->get('/api/v1/budgets/limits?' . http_build_query($params));
$response->assertStatus(200);
$response->assertHeader('Content-Type', 'application/vnd.api+json');
}
@@ -124,7 +124,7 @@ class BudgetLimitControllerTest extends TestCase
'start' => '2018-01-01',
'end' => '2018-01-31',
];
- $uri = '/api/v1/budget_limits?' . http_build_query($params);
+ $uri = '/api/v1/budgets/limits?' . http_build_query($params);
$response = $this->get($uri);
$response->assertStatus(200);
$response->assertHeader('Content-Type', 'application/vnd.api+json');
@@ -153,7 +153,7 @@ class BudgetLimitControllerTest extends TestCase
'start' => '2018-01-01',
'end' => '2018-01-31',
];
- $response = $this->get('/api/v1/budget_limits?' . http_build_query($params));
+ $response = $this->get('/api/v1/budgets/limits?' . http_build_query($params));
$response->assertStatus(200);
$response->assertHeader('Content-Type', 'application/vnd.api+json');
}
@@ -174,15 +174,15 @@ class BudgetLimitControllerTest extends TestCase
$budget = $this->user()->budgets()->first();
$budgetLimit = BudgetLimit::create(
[
- 'budget_id' => $budget->id,
- 'start_date' => '2018-01-01',
- 'end_date' => '2018-01-31',
- 'amount' => 1,
+ 'budget_id' => $budget->id,
+ 'start_date' => '2018-01-01',
+ 'end_date' => '2018-01-31',
+ 'amount' => 1,
]
);
- $response = $this->get('/api/v1/budget_limits/' . $budgetLimit->id);
+ $response = $this->get('/api/v1/budgets/limits/' . $budgetLimit->id);
$response->assertStatus(200);
$response->assertHeader('Content-Type', 'application/vnd.api+json');
}
@@ -198,18 +198,18 @@ class BudgetLimitControllerTest extends TestCase
$budget = $this->user()->budgets()->first();
$budgetLimit = BudgetLimit::create(
[
- 'budget_id' => $budget->id,
- 'start_date' => '2018-01-01',
- 'end_date' => '2018-01-31',
- 'amount' => 1,
+ 'budget_id' => $budget->id,
+ 'start_date' => '2018-01-01',
+ 'end_date' => '2018-01-31',
+ 'amount' => 1,
]
);
$data
= [
- 'budget_id' => $budget->id,
- 'start_date' => '2018-01-01',
- 'end_date' => '2018-01-31',
- 'amount' => 1,
+ 'budget_id' => $budget->id,
+ 'start' => '2018-01-01',
+ 'end' => '2018-01-31',
+ 'amount' => 1,
];
// mock stuff:
$repository = $this->mock(BudgetRepositoryInterface::class);
@@ -221,7 +221,7 @@ class BudgetLimitControllerTest extends TestCase
$repository->shouldReceive('setUser')->once();
// call API
- $response = $this->post('/api/v1/budget_limits', $data);
+ $response = $this->post('/api/v1/budgets/limits', $data, ['Accept' => 'application/json']);
$response->assertStatus(200);
$response->assertHeader('Content-Type', 'application/vnd.api+json');
}
@@ -236,10 +236,10 @@ class BudgetLimitControllerTest extends TestCase
{
$data
= [
- 'budget_id' => '1',
- 'start_date' => '2018-01-01',
- 'end_date' => '2018-01-31',
- 'amount' => 1,
+ 'budget_id' => '1',
+ 'start' => '2018-01-01',
+ 'end' => '2018-01-31',
+ 'amount' => 1,
];
// mock stuff:
$repository = $this->mock(BudgetRepositoryInterface::class);
@@ -250,7 +250,7 @@ class BudgetLimitControllerTest extends TestCase
$repository->shouldReceive('setUser')->once();
// call API
- $response = $this->post('/api/v1/budget_limits', $data);
+ $response = $this->post('/api/v1/budgets/limits', $data);
$response->assertStatus(500);
$response->assertSee('Unknown budget.');
}
@@ -266,18 +266,18 @@ class BudgetLimitControllerTest extends TestCase
$budget = $this->user()->budgets()->first();
$budgetLimit = BudgetLimit::create(
[
- 'budget_id' => $budget->id,
- 'start_date' => '2018-01-01',
- 'end_date' => '2018-01-31',
- 'amount' => 1,
+ 'budget_id' => $budget->id,
+ 'start_date' => '2018-01-01',
+ 'end_date' => '2018-01-31',
+ 'amount' => 1,
]
);
$data
= [
- 'budget_id' => $budget->id,
- 'start_date' => '2018-01-01',
- 'end_date' => '2018-01-31',
- 'amount' => 2,
+ 'budget_id' => $budget->id,
+ 'start' => '2018-01-01',
+ 'end' => '2018-01-31',
+ 'amount' => 2,
];
// mock stuff:
$repository = $this->mock(BudgetRepositoryInterface::class);
@@ -289,7 +289,7 @@ class BudgetLimitControllerTest extends TestCase
$repository->shouldReceive('setUser')->once();
// call API
- $response = $this->put('/api/v1/budget_limits/' . $budgetLimit->id, $data);
+ $response = $this->put('/api/v1/budgets/limits/' . $budgetLimit->id, $data);
$response->assertStatus(200);
$response->assertHeader('Content-Type', 'application/vnd.api+json');
@@ -314,10 +314,10 @@ class BudgetLimitControllerTest extends TestCase
);
$data
= [
- 'budget_id' => $budget->id,
- 'start_date' => '2018-01-01',
- 'end_date' => '2018-01-31',
- 'amount' => 2,
+ 'budget_id' => $budget->id,
+ 'start' => '2018-01-01',
+ 'end' => '2018-01-31',
+ 'amount' => 2,
];
// mock stuff:
$repository = $this->mock(BudgetRepositoryInterface::class);
@@ -328,7 +328,7 @@ class BudgetLimitControllerTest extends TestCase
$repository->shouldReceive('setUser')->once();
// call API
- $response = $this->put('/api/v1/budget_limits/' . $budgetLimit->id, $data);
+ $response = $this->put('/api/v1/budgets/limits/' . $budgetLimit->id, $data);
$response->assertStatus(500);
$response->assertSee('Unknown budget.');
}
diff --git a/tests/Api/V1/Controllers/ConfigurationControllerTest.php b/tests/Api/V1/Controllers/ConfigurationControllerTest.php
index 71c5c0bcc0..60856b8fa8 100644
--- a/tests/Api/V1/Controllers/ConfigurationControllerTest.php
+++ b/tests/Api/V1/Controllers/ConfigurationControllerTest.php
@@ -120,7 +120,6 @@ class ConfigurationControllerTest extends TestCase
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$data = [
- 'name' => 'permission_update_check',
'value' => 1,
];
@@ -157,7 +156,7 @@ class ConfigurationControllerTest extends TestCase
],
];
- $response = $this->post('/api/v1/configuration', $data);
+ $response = $this->post('/api/v1/configuration/permission_update_check', $data);
$response->assertStatus(200);
$response->assertExactJson($expected);
}
@@ -173,7 +172,6 @@ class ConfigurationControllerTest extends TestCase
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$data = [
- 'name' => 'single_user_mode',
'value' => 'true',
];
@@ -210,7 +208,7 @@ class ConfigurationControllerTest extends TestCase
],
];
- $response = $this->post('/api/v1/configuration', $data);
+ $response = $this->post('/api/v1/configuration/single_user_mode', $data);
$response->assertStatus(200);
$response->assertExactJson($expected);
}
@@ -223,14 +221,11 @@ class ConfigurationControllerTest extends TestCase
public function testUpdateInvalid(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
- $userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$data = [
- 'name' => 'last_update_check',
'value' => 'true',
];
- $response = $this->post('/api/v1/configuration', $data);
- $response->assertStatus(500);
- $response->assertSee('You cannot edit this configuration value.');
+ $response = $this->post('/api/v1/configuration/last_update_check', $data);
+ $response->assertStatus(404);
}
/**
@@ -244,7 +239,7 @@ class ConfigurationControllerTest extends TestCase
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(false);
Passport::actingAs($this->emptyUser());
- $response = $this->post('/api/v1/configuration');
+ $response = $this->post('/api/v1/configuration/single_user_mode');
$response->assertStatus(500);
$response->assertSee('No access to method.');
}
diff --git a/tests/Api/V1/Controllers/CurrencyControllerTest.php b/tests/Api/V1/Controllers/CurrencyControllerTest.php
index ed3196a066..d472187f76 100644
--- a/tests/Api/V1/Controllers/CurrencyControllerTest.php
+++ b/tests/Api/V1/Controllers/CurrencyControllerTest.php
@@ -73,7 +73,7 @@ class CurrencyControllerTest extends TestCase
$currency = TransactionCurrency::first();
// call API
- $response = $this->delete('/api/v1/currencies/' . $currency->id);
+ $response = $this->delete('/api/v1/currencies/' . $currency->code);
$response->assertStatus(204);
}
@@ -132,7 +132,7 @@ class CurrencyControllerTest extends TestCase
$repository->shouldReceive('setUser')->once();
// test API
- $response = $this->get('/api/v1/currencies/' . $currency->id);
+ $response = $this->get('/api/v1/currencies/' . $currency->code);
$response->assertStatus(200);
$response->assertJson(
['data' => [
@@ -245,7 +245,7 @@ class CurrencyControllerTest extends TestCase
];
// test API
- $response = $this->put('/api/v1/currencies/' . $currency->id, $data, ['Accept' => 'application/json']);
+ $response = $this->put('/api/v1/currencies/' . $currency->code, $data, ['Accept' => 'application/json']);
$response->assertStatus(200);
$response->assertJson(['data' => ['type' => 'currencies', 'links' => true],]);
$response->assertHeader('Content-Type', 'application/vnd.api+json');
@@ -285,7 +285,7 @@ class CurrencyControllerTest extends TestCase
];
// test API
- $response = $this->put('/api/v1/currencies/' . $currency->id, $data, ['Accept' => 'application/json']);
+ $response = $this->put('/api/v1/currencies/' . $currency->code, $data, ['Accept' => 'application/json']);
$response->assertStatus(200);
$response->assertJson(['data' => ['type' => 'currencies', 'links' => true],]);
$response->assertHeader('Content-Type', 'application/vnd.api+json');
diff --git a/tests/Api/V1/Controllers/PreferencesControllerTest.php b/tests/Api/V1/Controllers/PreferencesControllerTest.php
index 4ab718634e..be03426e87 100644
--- a/tests/Api/V1/Controllers/PreferencesControllerTest.php
+++ b/tests/Api/V1/Controllers/PreferencesControllerTest.php
@@ -66,16 +66,6 @@ class PreferencesControllerTest extends TestCase
$response->assertStatus(200);
}
- public function testShow(): void
- {
- /** @var Preference $preference */
- $preference = $this->user()->preferences()->first();
-
- $response = $this->get('/api/v1/preferences/' . $preference->id);
- $response->assertStatus(200);
- $response->assertSee($preference->name);
- }
-
/**
* @covers \FireflyIII\Api\V1\Controllers\PreferenceController
* @covers \FireflyIII\Api\V1\Requests\PreferenceRequest
@@ -85,7 +75,7 @@ class PreferencesControllerTest extends TestCase
/** @var Preference $preference */
$preference = Preferences::setForUser($this->user(), 'frontPageAccounts', [1, 2, 3]);
$data = ['data' => '4,5,6'];
- $response = $this->put('/api/v1/preferences/' . $preference->id, $data, ['Accept' => 'application/json']);
+ $response = $this->put('/api/v1/preferences/' . $preference->name, $data, ['Accept' => 'application/json']);
$response->assertSee($preference->name);
$response->assertStatus(200);
@@ -100,7 +90,7 @@ class PreferencesControllerTest extends TestCase
/** @var Preference $preference */
$preference = Preferences::setForUser($this->user(), 'twoFactorAuthEnabled', false);
$data = ['data' => '1'];
- $response = $this->put('/api/v1/preferences/' . $preference->id, $data, ['Accept' => 'application/json']);
+ $response = $this->put('/api/v1/preferences/' . $preference->name, $data, ['Accept' => 'application/json']);
$response->assertSee($preference->name);
$response->assertStatus(200);
@@ -115,7 +105,7 @@ class PreferencesControllerTest extends TestCase
/** @var Preference $preference */
$preference = Preferences::setForUser($this->user(), 'currencyPreference', false);
$data = ['data' => 'EUR'];
- $response = $this->put('/api/v1/preferences/' . $preference->id, $data, ['Accept' => 'application/json']);
+ $response = $this->put('/api/v1/preferences/' . $preference->name, $data, ['Accept' => 'application/json']);
$response->assertSee($preference->name);
$response->assertStatus(200);
@@ -130,7 +120,7 @@ class PreferencesControllerTest extends TestCase
/** @var Preference $preference */
$preference = Preferences::setForUser($this->user(), 'listPageSize', 13);
$data = ['data' => '434'];
- $response = $this->put('/api/v1/preferences/' . $preference->id, $data, ['Accept' => 'application/json']);
+ $response = $this->put('/api/v1/preferences/' . $preference->name, $data, ['Accept' => 'application/json']);
$response->assertSee($preference->name);
$response->assertStatus(200);
diff --git a/tests/Api/V1/Controllers/RuleControllerTest.php b/tests/Api/V1/Controllers/RuleControllerTest.php
index dfe8356d66..69112301ca 100644
--- a/tests/Api/V1/Controllers/RuleControllerTest.php
+++ b/tests/Api/V1/Controllers/RuleControllerTest.php
@@ -118,14 +118,14 @@ class RuleControllerTest extends TestCase
'strict' => 1,
'stop_processing' => 1,
'active' => 1,
- 'rule_triggers' => [
+ 'triggers' => [
[
'name' => 'description_is',
'value' => 'Hello',
'stop_processing' => 1,
],
],
- 'rule_actions' => [
+ 'actions' => [
[
'name' => 'add_tag',
'value' => 'A',
@@ -158,14 +158,14 @@ class RuleControllerTest extends TestCase
'strict' => 1,
'stop_processing' => 1,
'active' => 1,
- 'rule_triggers' => [
+ 'triggers' => [
[
'name' => 'description_is',
'value' => 'Hello',
'stop_processing' => 1,
],
],
- 'rule_actions' => [
+ 'actions' => [
],
];
@@ -190,9 +190,9 @@ class RuleControllerTest extends TestCase
'strict' => 1,
'stop_processing' => 1,
'active' => 1,
- 'rule_triggers' => [
+ 'triggers' => [
],
- 'rule_actions' => [
+ 'actions' => [
[
'name' => 'add_tag',
'value' => 'A',
@@ -225,14 +225,14 @@ class RuleControllerTest extends TestCase
'strict' => 1,
'stop_processing' => 1,
'active' => 1,
- 'rule_triggers' => [
+ 'triggers' => [
[
'name' => 'description_is',
'value' => 'Hello',
'stop_processing' => 1,
],
],
- 'rule_actions' => [
+ 'actions' => [
[
'name' => 'add_tag',
'value' => 'A',
diff --git a/tests/Api/V1/Controllers/TransactionControllerTest.php b/tests/Api/V1/Controllers/TransactionControllerTest.php
index 8d3f3f9312..0d4911d131 100644
--- a/tests/Api/V1/Controllers/TransactionControllerTest.php
+++ b/tests/Api/V1/Controllers/TransactionControllerTest.php
@@ -1231,7 +1231,9 @@ class TransactionControllerTest extends TestCase
$repository = $this->mock(JournalRepositoryInterface::class);
$collector = $this->mock(TransactionCollectorInterface::class);
$repository->shouldReceive('setUser');
-
+ $repository->shouldReceive('getNoteText')->atLeast()->once()->andReturn('Note');
+ $repository->shouldReceive('getMetaField')->atLeast()->once()->andReturn(null);
+ $repository->shouldReceive('getMetaDateString')->atLeast()->once()->andReturn('2018-01-01');
$collector->shouldReceive('setUser')->andReturnSelf();
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
@@ -1242,6 +1244,8 @@ class TransactionControllerTest extends TestCase
$collector->shouldReceive('setLimit')->andReturnSelf();
$collector->shouldReceive('setPage')->andReturnSelf();
$collector->shouldReceive('setTypes')->andReturnSelf();
+
+
$collector->shouldReceive('getPaginatedTransactions')->andReturn($paginator);
@@ -1284,6 +1288,9 @@ class TransactionControllerTest extends TestCase
$repository = $this->mock(JournalRepositoryInterface::class);
$collector = $this->mock(TransactionCollectorInterface::class);
$repository->shouldReceive('setUser');
+ $repository->shouldReceive('getNoteText')->atLeast()->once()->andReturn('Note');
+ $repository->shouldReceive('getMetaField')->atLeast()->once()->andReturn(null);
+ $repository->shouldReceive('getMetaDateString')->atLeast()->once()->andReturn('2018-01-01');
$collector->shouldReceive('setUser')->andReturnSelf();
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
@@ -1351,6 +1358,9 @@ class TransactionControllerTest extends TestCase
$repository = $this->mock(JournalRepositoryInterface::class);
$collector = $this->mock(TransactionCollectorInterface::class);
$repository->shouldReceive('setUser');
+ $repository->shouldReceive('getNoteText')->atLeast()->once()->andReturn('Note');
+ $repository->shouldReceive('getMetaField')->atLeast()->once()->andReturn(null);
+ $repository->shouldReceive('getMetaDateString')->atLeast()->once()->andReturn('2018-01-01');
$collector->shouldReceive('setUser')->andReturnSelf();
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
@@ -1410,6 +1420,9 @@ class TransactionControllerTest extends TestCase
$repository = $this->mock(JournalRepositoryInterface::class);
$collector = $this->mock(TransactionCollectorInterface::class);
$repository->shouldReceive('setUser');
+ $repository->shouldReceive('getNoteText')->atLeast()->once()->andReturn('Note');
+ $repository->shouldReceive('getMetaField')->atLeast()->once()->andReturn(null);
+ $repository->shouldReceive('getMetaDateString')->atLeast()->once()->andReturn('2018-01-01');
$collector->shouldReceive('setUser')->andReturnSelf();
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
@@ -1461,6 +1474,9 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
+ $journalRepos->shouldReceive('getNoteText')->atLeast()->once()->andReturn('Note');
+ $journalRepos->shouldReceive('getMetaField')->atLeast()->once()->andReturn(null);
+ $journalRepos->shouldReceive('getMetaDateString')->atLeast()->once()->andReturn('2018-01-01');
try {
$this->expectsEvents(StoredTransactionJournal::class);
@@ -1508,6 +1524,9 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
+ $journalRepos->shouldReceive('getNoteText')->atLeast()->once()->andReturn('Note');
+ $journalRepos->shouldReceive('getMetaField')->atLeast()->once()->andReturn(null);
+ $journalRepos->shouldReceive('getMetaDateString')->atLeast()->once()->andReturn('2018-01-01');
try {
$this->expectsEvents(StoredTransactionJournal::class);
@@ -1554,6 +1573,9 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
+ $journalRepos->shouldReceive('getNoteText')->atLeast()->once()->andReturn('Note');
+ $journalRepos->shouldReceive('getMetaField')->atLeast()->once()->andReturn(null);
+ $journalRepos->shouldReceive('getMetaDateString')->atLeast()->once()->andReturn('2018-01-01');
try {
$this->expectsEvents(StoredTransactionJournal::class);
@@ -1601,6 +1623,9 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
+ $journalRepos->shouldReceive('getNoteText')->atLeast()->once()->andReturn('Note');
+ $journalRepos->shouldReceive('getMetaField')->atLeast()->once()->andReturn(null);
+ $journalRepos->shouldReceive('getMetaDateString')->atLeast()->once()->andReturn('2018-01-01');
try {
$this->expectsEvents(StoredTransactionJournal::class);
@@ -1646,6 +1671,9 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
+ $journalRepos->shouldReceive('getNoteText')->atLeast()->once()->andReturn('Note');
+ $journalRepos->shouldReceive('getMetaField')->atLeast()->once()->andReturn(null);
+ $journalRepos->shouldReceive('getMetaDateString')->atLeast()->once()->andReturn('2018-01-01');
try {
$this->expectsEvents(StoredTransactionJournal::class);
@@ -1692,6 +1720,9 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection);
$accountRepos->shouldReceive('findByName')->andReturn($account);
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
+ $journalRepos->shouldReceive('getNoteText')->atLeast()->once()->andReturn('Note');
+ $journalRepos->shouldReceive('getMetaField')->atLeast()->once()->andReturn(null);
+ $journalRepos->shouldReceive('getMetaDateString')->atLeast()->once()->andReturn('2018-01-01');
try {
$this->expectsEvents(StoredTransactionJournal::class);
@@ -1738,6 +1769,9 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
+ $journalRepos->shouldReceive('getNoteText')->andReturn('Note');
+ $journalRepos->shouldReceive('getMetaField')->andReturn(null);
+ $journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01');
try {
$this->expectsEvents(StoredTransactionJournal::class);
@@ -1783,6 +1817,9 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
+ $journalRepos->shouldReceive('getNoteText')->andReturn('Note');
+ $journalRepos->shouldReceive('getMetaField')->andReturn(null);
+ $journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01');
try {
$this->expectsEvents(StoredTransactionJournal::class);
@@ -1829,6 +1866,9 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
+ $journalRepos->shouldReceive('getNoteText')->andReturn('Note');
+ $journalRepos->shouldReceive('getMetaField')->andReturn(null);
+ $journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01');
try {
$this->expectsEvents(StoredTransactionJournal::class);
@@ -1876,6 +1916,9 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
+ $journalRepos->shouldReceive('getNoteText')->andReturn('Note');
+ $journalRepos->shouldReceive('getMetaField')->andReturn(null);
+ $journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01');
try {
$this->expectsEvents(StoredTransactionJournal::class);
@@ -1922,6 +1965,9 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
+ $journalRepos->shouldReceive('getNoteText')->andReturn('Note');
+ $journalRepos->shouldReceive('getMetaField')->andReturn(null);
+ $journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01');
try {
$this->expectsEvents(StoredTransactionJournal::class);
@@ -1975,6 +2021,10 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
+ $journalRepos->shouldReceive('getNoteText')->andReturn('Note');
+ $journalRepos->shouldReceive('getMetaField')->andReturn(null);
+ $journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01');
+
$data = [
'description' => 'Some transaction #' . random_int(1, 10000),
'date' => '2018-01-01',
@@ -2014,6 +2064,10 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
+ $journalRepos->shouldReceive('getNoteText')->andReturn('Note');
+ $journalRepos->shouldReceive('getMetaField')->andReturn(null);
+ $journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01');
+
try {
$this->expectsEvents(StoredTransactionJournal::class);
@@ -2066,6 +2120,9 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
+ $journalRepos->shouldReceive('getNoteText')->andReturn('Note');
+ $journalRepos->shouldReceive('getMetaField')->andReturn(null);
+ $journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01');
try {
$this->expectsEvents(StoredTransactionJournal::class);
@@ -2113,6 +2170,9 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]), new Collection([$opposing]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
+ $journalRepos->shouldReceive('getNoteText')->andReturn('Note');
+ $journalRepos->shouldReceive('getMetaField')->andReturn(null);
+ $journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01');
try {
$this->expectsEvents(StoredTransactionJournal::class);
@@ -2160,6 +2220,9 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
+ $journalRepos->shouldReceive('getNoteText')->andReturn('Note');
+ $journalRepos->shouldReceive('getMetaField')->andReturn(null);
+ $journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01');
try {
$this->expectsEvents(StoredTransactionJournal::class);
@@ -2206,6 +2269,9 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]), new Collection([$opposing]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
+ $journalRepos->shouldReceive('getNoteText')->andReturn('Note');
+ $journalRepos->shouldReceive('getMetaField')->andReturn(null);
+ $journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01');
try {
$this->expectsEvents(StoredTransactionJournal::class);
@@ -2252,6 +2318,9 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]), new Collection([$opposing]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
+ $journalRepos->shouldReceive('getNoteText')->andReturn('Note');
+ $journalRepos->shouldReceive('getMetaField')->andReturn(null);
+ $journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01');
try {
$this->expectsEvents(StoredTransactionJournal::class);
@@ -2298,6 +2367,9 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
+ $journalRepos->shouldReceive('getNoteText')->andReturn('Note');
+ $journalRepos->shouldReceive('getMetaField')->andReturn(null);
+ $journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01');
try {
$this->expectsEvents(StoredTransactionJournal::class);
@@ -2345,6 +2417,9 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$source]), new Collection([$dest]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
+ $journalRepos->shouldReceive('getNoteText')->andReturn('Note');
+ $journalRepos->shouldReceive('getMetaField')->andReturn(null);
+ $journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01');
try {
$this->expectsEvents(StoredTransactionJournal::class);
@@ -2391,6 +2466,9 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$source]), new Collection([$dest]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
+ $journalRepos->shouldReceive('getNoteText')->andReturn('Note');
+ $journalRepos->shouldReceive('getMetaField')->andReturn(null);
+ $journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01');
try {
$this->expectsEvents(StoredTransactionJournal::class);
@@ -2435,6 +2513,9 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
+ $journalRepos->shouldReceive('getNoteText')->andReturn('Note');
+ $journalRepos->shouldReceive('getMetaField')->andReturn(null);
+ $journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01');
try {
$this->expectsEvents(StoredTransactionJournal::class);
@@ -2480,6 +2561,9 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
+ $journalRepos->shouldReceive('getNoteText')->andReturn('Note');
+ $journalRepos->shouldReceive('getMetaField')->andReturn(null);
+ $journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01');
try {
$this->expectsEvents(StoredTransactionJournal::class);
@@ -2539,6 +2623,9 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
+ $journalRepos->shouldReceive('getNoteText')->andReturn('Note');
+ $journalRepos->shouldReceive('getMetaField')->andReturn(null);
+ $journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01');
try {
$this->expectsEvents(StoredTransactionJournal::class);
@@ -2604,6 +2691,9 @@ class TransactionControllerTest extends TestCase
$transaction = $deposit->transactions()->first();
$repository->shouldReceive('setUser');
$repository->shouldReceive('update')->andReturn($deposit)->once();
+ $repository->shouldReceive('getNoteText')->andReturn('Note');
+ $repository->shouldReceive('getMetaField')->andReturn(null);
+ $repository->shouldReceive('getMetaDateString')->andReturn('2018-01-01');
// call API
$response = $this->put('/api/v1/transactions/' . $transaction->id, $data);
@@ -2648,6 +2738,9 @@ class TransactionControllerTest extends TestCase
$transaction = $withdrawal->transactions()->first();
$repository->shouldReceive('setUser');
$repository->shouldReceive('update')->andReturn($withdrawal)->once();
+ $repository->shouldReceive('getNoteText')->andReturn('Note');
+ $repository->shouldReceive('getMetaField')->andReturn(null);
+ $repository->shouldReceive('getMetaDateString')->andReturn('2018-01-01');
// call API
$response = $this->put('/api/v1/transactions/' . $transaction->id, $data);
diff --git a/tests/Api/V1/Controllers/JournalLinkControllerTest.php b/tests/Api/V1/Controllers/TransactionLinkControllerTest.php
similarity index 91%
rename from tests/Api/V1/Controllers/JournalLinkControllerTest.php
rename to tests/Api/V1/Controllers/TransactionLinkControllerTest.php
index 79885131a1..46271da8fd 100644
--- a/tests/Api/V1/Controllers/JournalLinkControllerTest.php
+++ b/tests/Api/V1/Controllers/TransactionLinkControllerTest.php
@@ -1,6 +1,6 @@
<?php
/**
- * JournalLinkControllerTest.php
+ * TransactionLinkControllerTest.php
* Copyright (c) 2018 [email protected]
*
* This file is part of Firefly III.
@@ -37,9 +37,9 @@ use Tests\TestCase;
/**
*
- * Class JournalLinkControllerTest
+ * Class TransactionLinkControllerTest
*/
-class JournalLinkControllerTest extends TestCase
+class TransactionLinkControllerTest extends TestCase
{
/**
*
@@ -53,7 +53,7 @@ class JournalLinkControllerTest extends TestCase
}
/**
- * @covers \FireflyIII\Api\V1\Controllers\JournalLinkController
+ * @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController
*/
public function testDelete(): void
{
@@ -71,12 +71,12 @@ class JournalLinkControllerTest extends TestCase
$journalLink = TransactionJournalLink::first();
// call API
- $response = $this->delete('/api/v1/journal_links/' . $journalLink->id);
+ $response = $this->delete('/api/v1/transaction_links/' . $journalLink->id);
$response->assertStatus(204);
}
/**
- * @covers \FireflyIII\Api\V1\Controllers\JournalLinkController
+ * @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController
*/
public function testIndex(): void
{
@@ -104,13 +104,13 @@ class JournalLinkControllerTest extends TestCase
$collector->shouldReceive('getTransactions')->andReturn(new Collection([$transaction]));
// call API
- $response = $this->get('/api/v1/journal_links');
+ $response = $this->get('/api/v1/transaction_links');
$response->assertStatus(200);
$response->assertSee($journalLinks->first()->id);
}
/**
- * @covers \FireflyIII\Api\V1\Controllers\JournalLinkController
+ * @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController
*/
public function testShow(): void
{
@@ -135,13 +135,13 @@ class JournalLinkControllerTest extends TestCase
$collector->shouldReceive('getTransactions')->andReturn(new Collection([$transaction]));
// call API
- $response = $this->get('/api/v1/journal_links/' . $journalLink->id);
+ $response = $this->get('/api/v1/transaction_links/' . $journalLink->id);
$response->assertStatus(200);
$response->assertSee($journalLink->id);
}
/**
- * @covers \FireflyIII\Api\V1\Controllers\JournalLinkController
+ * @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController
* @covers \FireflyIII\Api\V1\Requests\JournalLinkRequest
*/
public function testStore(): void
@@ -183,7 +183,7 @@ class JournalLinkControllerTest extends TestCase
];
// test API
- $response = $this->post('/api/v1/journal_links', $data);
+ $response = $this->post('/api/v1/transaction_links', $data);
$response->assertStatus(200);
$response->assertSee($journalLink->created_at->toAtomString()); // the creation moment.
$response->assertHeader('Content-Type', 'application/vnd.api+json');
@@ -192,7 +192,7 @@ class JournalLinkControllerTest extends TestCase
/**
* In this particular test the journal link request will fail.
*
- * @covers \FireflyIII\Api\V1\Controllers\JournalLinkController
+ * @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController
* @covers \FireflyIII\Api\V1\Requests\JournalLinkRequest
*/
public function testStoreExistingLink(): void
@@ -233,7 +233,7 @@ class JournalLinkControllerTest extends TestCase
];
// test API
- $response = $this->post('/api/v1/journal_links', $data, ['Accept' => 'application/json']);
+ $response = $this->post('/api/v1/transaction_links', $data, ['Accept' => 'application/json']);
$response->assertStatus(422);
$response->assertSee('Already have a link between inward and outward.');
@@ -244,7 +244,7 @@ class JournalLinkControllerTest extends TestCase
/**
* In this particular test the JournalLinkRequest will report the failure.
*
- * @covers \FireflyIII\Api\V1\Controllers\JournalLinkController
+ * @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController
* @covers \FireflyIII\Api\V1\Requests\JournalLinkRequest
*/
public function testStoreInvalidInward(): void
@@ -285,7 +285,7 @@ class JournalLinkControllerTest extends TestCase
];
// test API
- $response = $this->post('/api/v1/journal_links', $data, ['Accept' => 'application/json']);
+ $response = $this->post('/api/v1/transaction_links', $data, ['Accept' => 'application/json']);
$response->assertSee('Invalid inward ID.'); // the creation moment.
$response->assertStatus(422);
$response->assertHeader('Content-Type', 'application/json');
@@ -294,7 +294,7 @@ class JournalLinkControllerTest extends TestCase
/**
* In this particular test the JournalLinkRequest will report the failure.
*
- * @covers \FireflyIII\Api\V1\Controllers\JournalLinkController
+ * @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController
* @covers \FireflyIII\Api\V1\Requests\JournalLinkRequest
*/
public function testStoreInvalidOutward(): void
@@ -335,14 +335,14 @@ class JournalLinkControllerTest extends TestCase
];
// test API
- $response = $this->post('/api/v1/journal_links', $data, ['Accept' => 'application/json']);
+ $response = $this->post('/api/v1/transaction_links', $data, ['Accept' => 'application/json']);
$response->assertSee('Invalid outward ID.');
$response->assertStatus(422);
$response->assertHeader('Content-Type', 'application/json');
}
/**
- * @covers \FireflyIII\Api\V1\Controllers\JournalLinkController
+ * @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController
* @covers \FireflyIII\Api\V1\Requests\JournalLinkRequest
*/
public function testStoreNoJournal(): void
@@ -384,14 +384,14 @@ class JournalLinkControllerTest extends TestCase
];
// test API
- $response = $this->post('/api/v1/journal_links', $data, ['Accept' => 'application/json']);
+ $response = $this->post('/api/v1/transaction_links', $data, ['Accept' => 'application/json']);
$response->assertStatus(500);
$response->assertSee('Source or destination is NULL.'); // the creation moment.
$response->assertHeader('Content-Type', 'application/json');
}
/**
- * @covers \FireflyIII\Api\V1\Controllers\JournalLinkController
+ * @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController
* @covers \FireflyIII\Api\V1\Requests\JournalLinkRequest
*/
public function testStoreWithNull(): void
@@ -431,14 +431,14 @@ class JournalLinkControllerTest extends TestCase
];
// test API
- $response = $this->post('/api/v1/journal_links', $data, ['Accept' => 'application/json']);
+ $response = $this->post('/api/v1/transaction_links', $data, ['Accept' => 'application/json']);
$response->assertStatus(422);
$response->assertSee('Invalid inward ID.'); // error message
$response->assertHeader('Content-Type', 'application/json');
}
/**
- * @covers \FireflyIII\Api\V1\Controllers\JournalLinkController
+ * @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController
* @covers \FireflyIII\Api\V1\Requests\JournalLinkRequest
*/
public function testUpdate(): void
@@ -481,14 +481,14 @@ class JournalLinkControllerTest extends TestCase
];
// test API
- $response = $this->put('/api/v1/journal_links/' . $journalLink->id, $data, ['Accept' => 'application/json']);
+ $response = $this->put('/api/v1/transaction_links/' . $journalLink->id, $data, ['Accept' => 'application/json']);
$response->assertStatus(200);
$response->assertSee($journalLink->created_at->toAtomString()); // the creation moment.
$response->assertHeader('Content-Type', 'application/vnd.api+json');
}
/**
- * @covers \FireflyIII\Api\V1\Controllers\JournalLinkController
+ * @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController
* @covers \FireflyIII\Api\V1\Requests\JournalLinkRequest
*/
public function testUpdateNoJournal(): void
@@ -531,14 +531,14 @@ class JournalLinkControllerTest extends TestCase
];
// test API
- $response = $this->put('/api/v1/journal_links/' . $journalLink->id, $data, ['Accept' => 'application/json']);
+ $response = $this->put('/api/v1/transaction_links/' . $journalLink->id, $data, ['Accept' => 'application/json']);
$response->assertStatus(500);
$response->assertSee('Source or destination is NULL.'); // the creation moment.
$response->assertHeader('Content-Type', 'application/json');
}
/**
- * @covers \FireflyIII\Api\V1\Controllers\JournalLinkController
+ * @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController
* @covers \FireflyIII\Api\V1\Requests\JournalLinkRequest
*/
public function testUpdateWithNull(): void
@@ -579,7 +579,7 @@ class JournalLinkControllerTest extends TestCase
];
// test API
- $response = $this->put('/api/v1/journal_links/' . $journalLink->id, $data, ['Accept' => 'application/json']);
+ $response = $this->put('/api/v1/transaction_links/' . $journalLink->id, $data, ['Accept' => 'application/json']);
$response->assertStatus(422);
$response->assertSee('Invalid inward ID.'); // the creation moment.
$response->assertHeader('Content-Type', 'application/json');
diff --git a/tests/Feature/Controllers/Rule/SelectControllerTest.php b/tests/Feature/Controllers/Rule/SelectControllerTest.php
index 69eee37d30..c9a13ab965 100644
--- a/tests/Feature/Controllers/Rule/SelectControllerTest.php
+++ b/tests/Feature/Controllers/Rule/SelectControllerTest.php
@@ -110,7 +110,7 @@ class SelectControllerTest extends TestCase
public function testTestTriggers(): void
{
$data = [
- 'rule_triggers' => [
+ 'triggers' => [
'name' => 'description',
'value' => 'Bla bla',
'stop_processing' => 1,
@@ -125,9 +125,9 @@ class SelectControllerTest extends TestCase
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
- $matcher->shouldReceive('setStrict')->once()->withArgs([false]);
- $matcher->shouldReceive('setLimit')->withArgs([10])->andReturnSelf()->once();
- $matcher->shouldReceive('setRange')->withArgs([200])->andReturnSelf()->once();
+ $matcher->shouldReceive('setStrict')->once()->withArgs([false])->andReturnSelf();
+ $matcher->shouldReceive('setTriggeredLimit')->withArgs([10])->andReturnSelf()->once();
+ $matcher->shouldReceive('setSearchLimit')->withArgs([200])->andReturnSelf()->once();
$matcher->shouldReceive('setTriggers')->andReturnSelf()->once();
$matcher->shouldReceive('findTransactionsByTriggers')->andReturn(new Collection);
@@ -145,8 +145,8 @@ class SelectControllerTest extends TestCase
$matcher = $this->mock(TransactionMatcher::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
- $matcher->shouldReceive('setLimit')->withArgs([10])->andReturnSelf()->once();
- $matcher->shouldReceive('setRange')->withArgs([200])->andReturnSelf()->once();
+ $matcher->shouldReceive('setTriggeredLimit')->withArgs([10])->andReturnSelf()->once();
+ $matcher->shouldReceive('setSearchLimit')->withArgs([200])->andReturnSelf()->once();
$matcher->shouldReceive('setRule')->andReturnSelf()->once();
$matcher->shouldReceive('findTransactionsByRule')->andReturn(new Collection);
@@ -181,7 +181,7 @@ class SelectControllerTest extends TestCase
public function testTestTriggersMax(): void
{
$data = [
- 'rule_triggers' => [
+ 'triggers' => [
'name' => 'description',
'value' => 'Bla bla',
'stop_processing' => 1,
@@ -199,8 +199,8 @@ class SelectControllerTest extends TestCase
$matcher->shouldReceive('setStrict')->once()->withArgs([false]);
- $matcher->shouldReceive('setLimit')->withArgs([10])->andReturnSelf()->once();
- $matcher->shouldReceive('setRange')->withArgs([200])->andReturnSelf()->once();
+ $matcher->shouldReceive('setTriggeredLimit')->withArgs([10])->andReturnSelf()->once();
+ $matcher->shouldReceive('setSearchLimit')->withArgs([200])->andReturnSelf()->once();
$matcher->shouldReceive('setTriggers')->andReturnSelf()->once();
$matcher->shouldReceive('findTransactionsByTriggers')->andReturn($set);
diff --git a/tests/Feature/Controllers/Transaction/MassControllerTest.php b/tests/Feature/Controllers/Transaction/MassControllerTest.php
index 28cbe57b9b..2e06bc0634 100644
--- a/tests/Feature/Controllers/Transaction/MassControllerTest.php
+++ b/tests/Feature/Controllers/Transaction/MassControllerTest.php
@@ -122,9 +122,16 @@ class MassControllerTest extends TestCase
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([$source]));
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([$source]));
$journalRepos->shouldReceive('getTransactionType')->andReturn('Transfer');
+
$journalRepos->shouldReceive('isJournalReconciled')->andReturn(false);
$journalRepos->shouldReceive('getFirstPosTransaction')->andReturn($transfers->first()->transactions()->first());
+ // get all kinds of meta fields (the transformer needs this)
+ $journalRepos->shouldReceive('getNoteText')->andReturn('Hello');
+ $journalRepos->shouldReceive('getMetaField')->withAnyArgs()->andReturnNull();
+ $journalRepos->shouldReceive('getMetaDateString')->withAnyArgs()->andReturnNull();
+
+
// mock stuff:
$repository = $this->mock(AccountRepositoryInterface::class);
@@ -172,6 +179,11 @@ class MassControllerTest extends TestCase
$journalRepos->shouldReceive('isJournalReconciled')
->andReturn(true, false, false, false, false);
+ // get all kinds of meta fields (the transformer needs this)
+ $journalRepos->shouldReceive('getNoteText')->andReturn('Hello');
+ $journalRepos->shouldReceive('getMetaField')->withAnyArgs()->andReturnNull();
+ $journalRepos->shouldReceive('getMetaDateString')->withAnyArgs()->andReturnNull();
+
// default transactions
$collection = $this->user()->transactionJournals()->take(5)->get();
diff --git a/tests/Feature/Controllers/Transaction/SingleControllerTest.php b/tests/Feature/Controllers/Transaction/SingleControllerTest.php
index e5ebd40c4a..0ddabd32c6 100644
--- a/tests/Feature/Controllers/Transaction/SingleControllerTest.php
+++ b/tests/Feature/Controllers/Transaction/SingleControllerTest.php
@@ -1012,6 +1012,10 @@ class SingleControllerTest extends TestCase
$journalRepos->shouldReceive('getMetaField')->andReturn('');
$journalRepos->shouldReceive('getAttachments')->andReturn(new Collection);
+ $journalRepos->shouldReceive('getNoteText')->andReturn('');
+ $journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01');
+
+
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection);
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection);
diff --git a/tests/Feature/Controllers/Transaction/SplitControllerTest.php b/tests/Feature/Controllers/Transaction/SplitControllerTest.php
index 42d1b9f2af..042a19835d 100644
--- a/tests/Feature/Controllers/Transaction/SplitControllerTest.php
+++ b/tests/Feature/Controllers/Transaction/SplitControllerTest.php
@@ -67,7 +67,7 @@ class SplitControllerTest extends TestCase
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$attHelper = $this->mock(AttachmentHelperInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
@@ -89,11 +89,12 @@ class SplitControllerTest extends TestCase
$journalRepos->shouldReceive('getTransactionType')->once()->andReturn('Deposit');
$journalRepos->shouldReceive('getJournalDate')->andReturn('2018-01-01')->once();
$journalRepos->shouldReceive('getMetaField')->andReturn('');
- $journalRepos->shouldReceive('getNoteText')->andReturn('Some note')->once();
+ $journalRepos->shouldReceive('getNoteText')->andReturn('Some note')->atLeast()->once();
$journalRepos->shouldReceive('getJournalBudgetId')->andReturn(0);
$journalRepos->shouldReceive('getCategoryName')->andReturn('');
$journalRepos->shouldReceive('getJournalTotal')->andReturn('0');
$journalRepos->shouldReceive('getJournalCategoryName')->andReturn('Some');
+ $journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01')->atLeast()->once();
$currencyRepository->shouldReceive('get')->once()->andReturn(new Collection);
@@ -116,14 +117,14 @@ class SplitControllerTest extends TestCase
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$attHelper = $this->mock(AttachmentHelperInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
- $deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
- $destination = $deposit->transactions()->where('amount', '>', 0)->first();
- $account = $destination->account;
- $transactions = factory(Transaction::class, 3)->make();
+ $deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
+ $destination = $deposit->transactions()->where('amount', '>', 0)->first();
+ $account = $destination->account;
+ $transactions = factory(Transaction::class, 3)->make();
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
$currencyRepository->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1));
@@ -139,10 +140,11 @@ class SplitControllerTest extends TestCase
$journalRepos->shouldReceive('getTransactionType')->once()->andReturn('Deposit');
$journalRepos->shouldReceive('getJournalDate')->andReturn('2018-01-01')->once();
$journalRepos->shouldReceive('getMetaField')->andReturn('');
- $journalRepos->shouldReceive('getNoteText')->andReturn('Some note')->once();
$journalRepos->shouldReceive('getJournalBudgetId')->andReturn(0);
$journalRepos->shouldReceive('getCategoryName')->andReturn('');
$journalRepos->shouldReceive('getJournalTotal')->andReturn('0');
+ $journalRepos->shouldReceive('getNoteText')->andReturn('Some note')->atLeast()->once();
+ $journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01')->atLeast()->once();
$old = [
@@ -215,7 +217,7 @@ class SplitControllerTest extends TestCase
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$attHelper = $this->mock(AttachmentHelperInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$opening = TransactionJournal::where('transaction_type_id', 4)->where('user_id', $this->user()->id)->first();
@@ -235,7 +237,7 @@ class SplitControllerTest extends TestCase
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$attHelper = $this->mock(AttachmentHelperInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
@@ -254,10 +256,11 @@ class SplitControllerTest extends TestCase
$journalRepos->shouldReceive('getTransactionType')->once()->andReturn('Deposit');
$journalRepos->shouldReceive('getJournalDate')->once()->andReturn('2018-01-01');
$journalRepos->shouldReceive('getMetaField')->andReturn('');
- $journalRepos->shouldReceive('getNoteText')->andReturn('Some note')->once();
$journalRepos->shouldReceive('getJournalBudgetId')->andReturn(0);
$journalRepos->shouldReceive('getCategoryName')->andReturn('');
$journalRepos->shouldReceive('getJournalTotal')->andReturn('1');
+ $journalRepos->shouldReceive('getNoteText')->andReturn('Some note')->atLeast()->once();
+ $journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01')->atLeast()->once();
$currencyRepository->shouldReceive('get')->once()->andReturn(new Collection);
$budgetRepository->shouldReceive('getActiveBudgets')->andReturn(new Collection);
@@ -282,7 +285,7 @@ class SplitControllerTest extends TestCase
$attHelper = $this->mock(AttachmentHelperInterface::class);
$ruleRepos = $this->mock(RuleGroupRepositoryInterface::class);
$billRepos = $this->mock(BillRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$billRepos->shouldReceive('scan');
@@ -338,7 +341,7 @@ class SplitControllerTest extends TestCase
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$attHelper = $this->mock(AttachmentHelperInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$this->session(['transactions.edit-split.uri' => 'http://localhost']);
@@ -384,7 +387,7 @@ class SplitControllerTest extends TestCase
$attHelper = $this->mock(AttachmentHelperInterface::class);
$ruleRepos = $this->mock(RuleGroupRepositoryInterface::class);
$billRepos = $this->mock(BillRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$billRepos->shouldReceive('scan');
$ruleRepos->shouldReceive('setUser')->once();
@@ -442,7 +445,7 @@ class SplitControllerTest extends TestCase
$attHelper = $this->mock(AttachmentHelperInterface::class);
$ruleRepos = $this->mock(RuleGroupRepositoryInterface::class);
$billRepos = $this->mock(BillRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$billRepos->shouldReceive('scan');
diff --git a/tests/Feature/Controllers/TransactionControllerTest.php b/tests/Feature/Controllers/TransactionControllerTest.php
index 3f4ef43b1c..be565599c5 100644
--- a/tests/Feature/Controllers/TransactionControllerTest.php
+++ b/tests/Feature/Controllers/TransactionControllerTest.php
@@ -374,7 +374,8 @@ class TransactionControllerTest extends TestCase
$journalRepos->shouldReceive('getMetaField')->andReturn('');
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection);
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection);
-
+ $journalRepos->shouldReceive('getNoteText')->andReturn('Some note')->atLeast()->once();
+ $journalRepos->shouldReceive('getMetaDateString')->andReturn('2018-01-01')->atLeast()->once();
$this->be($this->user());
$response = $this->get(route('transactions.show', [1]));
diff --git a/tests/Unit/Factory/TransactionFactoryTest.php b/tests/Unit/Factory/TransactionFactoryTest.php
index 00e098cdb3..b1b83ce22a 100644
--- a/tests/Unit/Factory/TransactionFactoryTest.php
+++ b/tests/Unit/Factory/TransactionFactoryTest.php
@@ -878,6 +878,12 @@ class TransactionFactoryTest extends TestCase
// first search action is for the asset account, second is for expense account.
$accountRepos->shouldReceive('findNull')->andReturn($asset, $expense)->atLeast()->once();
+ // Find budget, but based on null it returns null.
+ $budgetFactory->shouldReceive('find')->withArgs([null, null])->andReturnNull()->atLeast()->once();
+
+ // find category, but none are present so return null.
+ $categoryFactory->shouldReceive('findOrCreate')->withArgs([null, null])->andReturnNull()->atLeast()->once();
+
// factories return various stuff:
$currencyFactory->shouldReceive('find')->andReturn(null, null)->atLeast()->once();
@@ -896,7 +902,7 @@ class TransactionFactoryTest extends TestCase
$newCount = $withdrawal->transactions()->count();
- $this->assertEquals($count, $newCount);
+ $this->assertEquals($count, $newCount - 2);
}
/**
diff --git a/tests/Unit/Transformers/AccountTransformerTest.php b/tests/Unit/Transformers/AccountTransformerTest.php
index f5f258c969..1fc689ab59 100644
--- a/tests/Unit/Transformers/AccountTransformerTest.php
+++ b/tests/Unit/Transformers/AccountTransformerTest.php
@@ -207,7 +207,7 @@ class AccountTransformerTest extends TestCase
$this->assertEquals($note->text, $result['notes']);
$this->assertEquals('2018-02-01', $result['monthly_payment_date']);
$this->assertEquals('monthlyFull', $result['credit_card_type']);
- $this->assertEquals('ccAsset', $result['role']);
+ $this->assertEquals('ccAsset', $result['account_role']);
}
/**
@@ -292,7 +292,7 @@ class AccountTransformerTest extends TestCase
$this->assertEquals($note->text, $result['notes']);
$this->assertNull($result['monthly_payment_date']);
$this->assertNull($result['credit_card_type']);
- $this->assertNull($result['role']);
+ $this->assertNull($result['account_role']);
}
/**
diff --git a/tests/Unit/Transformers/TagTransformerTest.php b/tests/Unit/Transformers/TagTransformerTest.php
index 58e50acad8..4ff7b32431 100644
--- a/tests/Unit/Transformers/TagTransformerTest.php
+++ b/tests/Unit/Transformers/TagTransformerTest.php
@@ -55,7 +55,6 @@ class TagTransformerTest extends TestCase
);
$transformer = new TagTransformer(new ParameterBag);
$result = $transformer->transform($tag);
- $this->assertEquals('nothing', $result['tag_mode']);
$this->assertEquals($tag->tag, $result['tag']);
$this->assertEquals(5.5, $result['latitude']);
$this->assertEquals(6.6, $result['longitude']);
diff --git a/tests/Unit/Transformers/TransactionTransformerTest.php b/tests/Unit/Transformers/TransactionTransformerTest.php
index 6fd9041c7f..1848a0ac85 100644
--- a/tests/Unit/Transformers/TransactionTransformerTest.php
+++ b/tests/Unit/Transformers/TransactionTransformerTest.php
@@ -35,6 +35,7 @@ use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
+use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Transformers\TransactionTransformer;
use Illuminate\Support\Collection;
use Symfony\Component\HttpFoundation\ParameterBag;
@@ -52,6 +53,11 @@ class TransactionTransformerTest extends TestCase
*/
public function testBasic(): void
{
+ $journalRepository = $this->mock(JournalRepositoryInterface::class);
+ $journalRepository->shouldReceive('getNoteText')->andReturn('Some notes')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaField')->andReturn('FieldValue')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaDateString')->andReturn('2018-01-01')->atLeast()->once();
+
// make new asset account:
$asset = Account::create(
[
@@ -130,6 +136,7 @@ class TransactionTransformerTest extends TestCase
$this->assertEquals($expense->iban, $result['destination_iban']);
$this->assertEquals($expense->id, $result['destination_id']);
$this->assertEquals('Expense account', $result['destination_type']);
+
}
/**
@@ -140,6 +147,11 @@ class TransactionTransformerTest extends TestCase
*/
public function testDeposit(): void
{
+ $journalRepository = $this->mock(JournalRepositoryInterface::class);
+ $journalRepository->shouldReceive('getNoteText')->andReturn('Some notes')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaField')->andReturn('FieldValue')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaDateString')->andReturn('2018-01-01')->atLeast()->once();
+
// make new asset account:
$asset = Account::create(
[
@@ -228,6 +240,11 @@ class TransactionTransformerTest extends TestCase
*/
public function testDepositBudget(): void
{
+ $journalRepository = $this->mock(JournalRepositoryInterface::class);
+ $journalRepository->shouldReceive('getNoteText')->andReturn('Some notes')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaField')->andReturn('FieldValue')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaDateString')->andReturn('2018-01-01')->atLeast()->once();
+
// make new asset account:
$asset = Account::create(
[
@@ -325,6 +342,11 @@ class TransactionTransformerTest extends TestCase
*/
public function testForeignAmount(): void
{
+ $journalRepository = $this->mock(JournalRepositoryInterface::class);
+ $journalRepository->shouldReceive('getNoteText')->andReturn('Some notes')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaField')->andReturn('FieldValue')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaDateString')->andReturn('2018-01-01')->atLeast()->once();
+
// make new asset account:
$asset = Account::create(
[
@@ -421,6 +443,11 @@ class TransactionTransformerTest extends TestCase
*/
public function testJournalBudget(): void
{
+ $journalRepository = $this->mock(JournalRepositoryInterface::class);
+ $journalRepository->shouldReceive('getNoteText')->andReturn('Some notes')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaField')->andReturn('FieldValue')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaDateString')->andReturn('2018-01-01')->atLeast()->once();
+
// make new asset account:
$asset = Account::create(
[
@@ -523,6 +550,11 @@ class TransactionTransformerTest extends TestCase
*/
public function testJournalCategory(): void
{
+ $journalRepository = $this->mock(JournalRepositoryInterface::class);
+ $journalRepository->shouldReceive('getNoteText')->andReturn('Some notes')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaField')->andReturn('FieldValue')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaDateString')->andReturn('2018-01-01')->atLeast()->once();
+
// make new asset account:
$asset = Account::create(
[
@@ -625,6 +657,11 @@ class TransactionTransformerTest extends TestCase
*/
public function testOpeningBalanceNeg(): void
{
+ $journalRepository = $this->mock(JournalRepositoryInterface::class);
+ $journalRepository->shouldReceive('getNoteText')->andReturn('Some notes')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaField')->andReturn('FieldValue')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaDateString')->andReturn('2018-01-01')->atLeast()->once();
+
// make new asset account:
$asset = Account::create(
[
@@ -714,6 +751,11 @@ class TransactionTransformerTest extends TestCase
*/
public function testOpeningBalancePos(): void
{
+ $journalRepository = $this->mock(JournalRepositoryInterface::class);
+ $journalRepository->shouldReceive('getNoteText')->andReturn('Some notes')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaField')->andReturn('FieldValue')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaDateString')->andReturn('2018-01-01')->atLeast()->once();
+
// make new asset account:
$asset = Account::create(
[
@@ -803,6 +845,11 @@ class TransactionTransformerTest extends TestCase
*/
public function testReconciliationNeg(): void
{
+ $journalRepository = $this->mock(JournalRepositoryInterface::class);
+ $journalRepository->shouldReceive('getNoteText')->andReturn('Some notes')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaField')->andReturn('FieldValue')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaDateString')->andReturn('2018-01-01')->atLeast()->once();
+
// make new asset account:
$asset = Account::create(
[
@@ -892,6 +939,11 @@ class TransactionTransformerTest extends TestCase
*/
public function testReconciliationPos(): void
{
+ $journalRepository = $this->mock(JournalRepositoryInterface::class);
+ $journalRepository->shouldReceive('getNoteText')->andReturn('Some notes')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaField')->andReturn('FieldValue')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaDateString')->andReturn('2018-01-01')->atLeast()->once();
+
// make new asset account:
$asset = Account::create(
[
@@ -981,6 +1033,11 @@ class TransactionTransformerTest extends TestCase
*/
public function testTransactionBudget(): void
{
+ $journalRepository = $this->mock(JournalRepositoryInterface::class);
+ $journalRepository->shouldReceive('getNoteText')->andReturn('Some notes')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaField')->andReturn('FieldValue')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaDateString')->andReturn('2018-01-01')->atLeast()->once();
+
// make new asset account:
$asset = Account::create(
[
@@ -1085,6 +1142,11 @@ class TransactionTransformerTest extends TestCase
*/
public function testTransactionCategory(): void
{
+ $journalRepository = $this->mock(JournalRepositoryInterface::class);
+ $journalRepository->shouldReceive('getNoteText')->andReturn('Some notes')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaField')->andReturn('FieldValue')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaDateString')->andReturn('2018-01-01')->atLeast()->once();
+
// make new asset account:
$asset = Account::create(
[
@@ -1188,6 +1250,11 @@ class TransactionTransformerTest extends TestCase
*/
public function testTransactionDescription(): void
{
+ $journalRepository = $this->mock(JournalRepositoryInterface::class);
+ $journalRepository->shouldReceive('getNoteText')->andReturn('Some notes')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaField')->andReturn('FieldValue')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaDateString')->andReturn('2018-01-01')->atLeast()->once();
+
// make new asset account:
$asset = Account::create(
[
@@ -1276,6 +1343,11 @@ class TransactionTransformerTest extends TestCase
*/
public function testTransferOne(): void
{
+ $journalRepository = $this->mock(JournalRepositoryInterface::class);
+ $journalRepository->shouldReceive('getNoteText')->andReturn('Some notes')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaField')->andReturn('FieldValue')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaDateString')->andReturn('2018-01-01')->atLeast()->once();
+
// make new asset account:
$left = Account::create(
[
@@ -1364,6 +1436,11 @@ class TransactionTransformerTest extends TestCase
*/
public function testTransferTwo(): void
{
+ $journalRepository = $this->mock(JournalRepositoryInterface::class);
+ $journalRepository->shouldReceive('getNoteText')->andReturn('Some notes')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaField')->andReturn('FieldValue')->atLeast()->once();
+ $journalRepository->shouldReceive('getMetaDateString')->andReturn('2018-01-01')->atLeast()->once();
+
// make new asset account:
$left = Account::create(
[