Skip to content

Firefly III: a personal finances manager

Remove a lot of deprecated code.

James Cole7c950c302296
diff --git a/app/Console/Commands/DecryptAttachment.php b/app/Console/Commands/DecryptAttachment.php
index 056a638872..75cfaf6329 100644
--- a/app/Console/Commands/DecryptAttachment.php
+++ b/app/Console/Commands/DecryptAttachment.php
@@ -65,7 +65,7 @@ class DecryptAttachment extends Command
$attachment = $repository->findWithoutUser($attachmentId);
$attachmentName = trim($this->argument('name'));
$storagePath = realpath(trim($this->argument('directory')));
- if (null === $attachment->id) {
+ if (null === $attachment) {
$this->error(sprintf('No attachment with id #%d', $attachmentId));
Log::error(sprintf('DecryptAttachment: No attachment with id #%d', $attachmentId));
diff --git a/app/Helpers/Attachments/AttachmentHelper.php b/app/Helpers/Attachments/AttachmentHelper.php
index 3b607834fb..e68300bedb 100644
--- a/app/Helpers/Attachments/AttachmentHelper.php
+++ b/app/Helpers/Attachments/AttachmentHelper.php
@@ -262,7 +262,7 @@ class AttachmentHelper implements AttachmentHelperInterface
// store it:
$this->uploadDisk->put($attachment->fileName(), $encrypted);
- $attachment->uploaded = 1; // update attachment
+ $attachment->uploaded = true; // update attachment
$attachment->save();
$this->attachments->push($attachment);
diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php
index 1e19e950f2..3183ee4228 100644
--- a/app/Http/Controllers/TagController.php
+++ b/app/Http/Controllers/TagController.php
@@ -196,7 +196,7 @@ class TagController extends Controller
// prep for "all" view.
if ('all' === $moment) {
$subTitle = (string)trans('firefly.all_journals_for_tag', ['tag' => $tag->tag]);
- $start = $this->repository->firstUseDate($tag);
+ $start = $this->repository->firstUseDate($tag) ?? new Carbon;
$end = new Carbon;
$path = route('tags.show', [$tag->id, 'all']);
}
@@ -311,8 +311,8 @@ class TagController extends Controller
// get first and last tag date from tag:
$range = app('preferences')->get('viewRange', '1M')->data;
/** @var Carbon $end */
- $end = app('navigation')->endOfX($this->repository->lastUseDate($tag), $range, null);
- $start = $this->repository->firstUseDate($tag);
+ $end = app('navigation')->endOfX($this->repository->lastUseDate($tag) ?? new Carbon, $range, null);
+ $start = $this->repository->firstUseDate($tag) ?? new Carbon;
// properties for entries with their amounts.
diff --git a/app/Http/Requests/ReportFormRequest.php b/app/Http/Requests/ReportFormRequest.php
index a5c8dc87e3..b59e8dbec5 100644
--- a/app/Http/Requests/ReportFormRequest.php
+++ b/app/Http/Requests/ReportFormRequest.php
@@ -211,7 +211,7 @@ class ReportFormRequest extends Request
if (\is_array($set)) {
foreach ($set as $tagTag) {
$tag = $repository->findByTag($tagTag);
- if (null !== $tag->id) {
+ if (null !== $tag) {
$collection->push($tag);
}
}
diff --git a/app/Import/Specifics/RabobankDescription.php b/app/Import/Specifics/RabobankDescription.php
index 65ceaf0024..d27392ca80 100644
--- a/app/Import/Specifics/RabobankDescription.php
+++ b/app/Import/Specifics/RabobankDescription.php
@@ -22,8 +22,6 @@ declare(strict_types=1);
namespace FireflyIII\Import\Specifics;
-use Log;
-
/**
* Class RabobankDescription.
*
@@ -66,25 +64,6 @@ class RabobankDescription implements SpecificInterface
public function run(array $row): array
{
$row = array_values($row);
- Log::debug(sprintf('Now in RabobankSpecific::run(). Row has %d columns', \count($row)));
- $oppositeAccount = isset($row[5]) ? trim($row[5]) : '';
- $oppositeName = isset($row[6]) ? trim($row[6]) : '';
- $alternateName = isset($row[10]) ? trim($row[10]) : '';
-
- if ('' === $oppositeAccount && '' === $oppositeName) {
- Log::debug(
- sprintf(
- 'Rabobank specific: Opposite account and opposite name are' .
- ' both empty. Will use "%s" (from description) instead',
- $alternateName
- )
- );
- $row[6] = $alternateName;
- $row[10] = '';
- }
- if (!('' === $oppositeAccount && '' === $oppositeName)) {
- Log::debug('Rabobank specific: either opposite account or name are filled.');
- }
return $row;
}
diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php
index 8f2ba2c186..b06185c07b 100644
--- a/app/Models/TransactionJournal.php
+++ b/app/Models/TransactionJournal.php
@@ -33,6 +33,8 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Collection;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
+use Illuminate\Database\Eloquent\Builder;
+
/**
* Class TransactionJournal.
@@ -62,7 +64,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/
class TransactionJournal extends Model
{
- use SoftDeletes, TransactionJournalTrait;
+ use SoftDeletes;
/**
* The attributes that should be casted to native types.
@@ -264,6 +266,27 @@ class TransactionJournal extends Model
return $query->where('transaction_journals.date', '<=', $date->format('Y-m-d 00:00:00'));
}
+ /**
+ * @param Builder $query
+ * @param string $table
+ *
+ * @return bool
+ */
+ public static function isJoined(Builder $query, string $table): bool
+ {
+ $joins = $query->getQuery()->joins;
+ if (null === $joins) {
+ return false;
+ }
+ foreach ($joins as $join) {
+ if ($join->table === $table) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
/**
* @codeCoverageIgnore
*
diff --git a/app/Repositories/Attachment/AttachmentRepository.php b/app/Repositories/Attachment/AttachmentRepository.php
index 52b77fff68..caad252875 100644
--- a/app/Repositories/Attachment/AttachmentRepository.php
+++ b/app/Repositories/Attachment/AttachmentRepository.php
@@ -81,18 +81,12 @@ class AttachmentRepository implements AttachmentRepositoryInterface
/**
* @param int $attachmentId
- * @deprecated
- * @return Attachment
+ * @return Attachment|null
*/
- public function findWithoutUser(int $attachmentId): Attachment
+ public function findWithoutUser(int $attachmentId): ?Attachment
{
- $attachment = Attachment::find($attachmentId);
- if (null === $attachment) {
- return new Attachment;
- }
-
- return $attachment;
+ return Attachment::find($attachmentId);
}
/**
diff --git a/app/Repositories/Attachment/AttachmentRepositoryInterface.php b/app/Repositories/Attachment/AttachmentRepositoryInterface.php
index 2f25bf81a7..527d00f88e 100644
--- a/app/Repositories/Attachment/AttachmentRepositoryInterface.php
+++ b/app/Repositories/Attachment/AttachmentRepositoryInterface.php
@@ -50,10 +50,9 @@ interface AttachmentRepositoryInterface
/**
* @param int $attachmentId
- * @deprecated
- * @return Attachment
+ * @return Attachment|null
*/
- public function findWithoutUser(int $attachmentId): Attachment;
+ public function findWithoutUser(int $attachmentId): ?Attachment;
/**
* @return Collection
diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php
index f71ec844b3..6556b7a24e 100644
--- a/app/Repositories/Budget/BudgetRepository.php
+++ b/app/Repositories/Budget/BudgetRepository.php
@@ -921,8 +921,8 @@ class BudgetRepository implements BudgetRepositoryInterface
// or create one and return it.
$limit = new BudgetLimit;
$limit->budget()->associate($budget);
- $limit->start_date = $start->format('Y-m-d 00:00:00');
- $limit->end_date = $end->format('Y-m-d 00:00:00');
+ $limit->start_date = $start->startOfDay();
+ $limit->end_date = $end->startOfDay();
$limit->amount = $amount;
$limit->save();
Log::debug(sprintf('Created new budget limit with ID #%d and amount %s', $limit->id, $amount));
diff --git a/app/Repositories/ExportJob/ExportJobRepository.php b/app/Repositories/ExportJob/ExportJobRepository.php
index 70bf949732..ec2e0c61a7 100644
--- a/app/Repositories/ExportJob/ExportJobRepository.php
+++ b/app/Repositories/ExportJob/ExportJobRepository.php
@@ -80,10 +80,9 @@ class ExportJobRepository implements ExportJobRepositoryInterface
}
/**
- * @return ExportJob
- * @deprecated
+ * @return ExportJob|null
*/
- public function create(): ExportJob
+ public function create(): ?ExportJob
{
$count = 0;
while ($count < 30) {
@@ -103,7 +102,7 @@ class ExportJobRepository implements ExportJobRepositoryInterface
++$count;
}
- return new ExportJob;
+ return null;
}
/**
diff --git a/app/Repositories/ExportJob/ExportJobRepositoryInterface.php b/app/Repositories/ExportJob/ExportJobRepositoryInterface.php
index 90473ca3ed..65d51523a4 100644
--- a/app/Repositories/ExportJob/ExportJobRepositoryInterface.php
+++ b/app/Repositories/ExportJob/ExportJobRepositoryInterface.php
@@ -44,10 +44,9 @@ interface ExportJobRepositoryInterface
public function cleanup(): bool;
/**
- * @return ExportJob
- * @deprecated
+ * @return ExportJob|null
*/
- public function create(): ExportJob;
+ public function create(): ?ExportJob;
/**
* @param ExportJob $job
diff --git a/app/Repositories/ImportJob/ImportJobRepository.php b/app/Repositories/ImportJob/ImportJobRepository.php
index b439e7b518..24b74bdb9e 100644
--- a/app/Repositories/ImportJob/ImportJobRepository.php
+++ b/app/Repositories/ImportJob/ImportJobRepository.php
@@ -303,7 +303,7 @@ class ImportJobRepository implements ImportJobRepositoryInterface
// store it:
$this->uploadDisk->put($attachment->fileName(), $encrypted);
- $attachment->uploaded = 1; // update attachment
+ $attachment->uploaded = true; // update attachment
$attachment->save();
// return it.
@@ -357,7 +357,7 @@ class ImportJobRepository implements ImportJobRepositoryInterface
// store it:
$this->uploadDisk->put($attachment->fileName(), $encrypted);
- $attachment->uploaded = 1; // update attachment
+ $attachment->uploaded = true; // update attachment
$attachment->save();
// return it.
diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php
index 57e37d48ea..657b5faf61 100644
--- a/app/Repositories/Journal/JournalRepository.php
+++ b/app/Repositories/Journal/JournalRepository.php
@@ -29,7 +29,6 @@ use FireflyIII\Factory\TransactionJournalFactory;
use FireflyIII\Factory\TransactionJournalMetaFactory;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
-use FireflyIII\Models\Note;
use FireflyIII\Models\PiggyBankEvent;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
@@ -59,6 +58,8 @@ class JournalRepository implements JournalRepositoryInterface
* @param Account $destination
*
* @return MessageBag
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function convert(TransactionJournal $journal, TransactionType $type, Account $source, Account $destination): MessageBag
{
@@ -73,9 +74,9 @@ class JournalRepository implements JournalRepositoryInterface
return $messages;
}
- $sourceTransaction = $journal->transactions()->where('amount', '<', 0)->first();
- $destinationTransaction = $journal->transactions()->where('amount', '>', 0)->first();
- if (null === $sourceTransaction || null === $destinationTransaction) {
+ $srcTransaction = $journal->transactions()->where('amount', '<', 0)->first();
+ $dstTransaction = $journal->transactions()->where('amount', '>', 0)->first();
+ if (null === $srcTransaction || null === $dstTransaction) {
// default message bag that shows errors for everything.
$messages = new MessageBag;
@@ -86,15 +87,18 @@ class JournalRepository implements JournalRepositoryInterface
return $messages;
}
- $sourceTransaction->account_id = $source->id;
- $sourceTransaction->save();
- $destinationTransaction->account_id = $destination->id;
- $destinationTransaction->save();
+ // update transactions, and update journal:
+
+ $srcTransaction->account_id = $source->id;
+ $dstTransaction->account_id = $destination->id;
$journal->transaction_type_id = $type->id;
+ $dstTransaction->save();
+ $srcTransaction->save();
$journal->save();
// if journal is a transfer now, remove budget:
if (TransactionType::TRANSFER === $type->type) {
+
$journal->budgets()->detach();
// also from transactions:
foreach ($journal->transactions as $transaction) {
diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php
index d89ef493ba..377b9d6331 100644
--- a/app/Repositories/PiggyBank/PiggyBankRepository.php
+++ b/app/Repositories/PiggyBank/PiggyBankRepository.php
@@ -340,6 +340,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
* @param PiggyBank $piggyBank
*
* @return string
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function getSuggestedMonthlyAmount(PiggyBank $piggyBank): string
{
diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.php
index 715ca44e13..710e50df95 100644
--- a/app/Repositories/Tag/TagRepository.php
+++ b/app/Repositories/Tag/TagRepository.php
@@ -80,29 +80,12 @@ class TagRepository implements TagRepositoryInterface
return (string)$set->sum('transaction_amount');
}
- /**
- * @param int $tagId
- *
- * @deprecated
- * @return Tag
- */
- public function find(int $tagId): Tag
- {
- $tag = $this->user->tags()->find($tagId);
- if (null === $tag) {
- $tag = new Tag;
- }
-
- return $tag;
- }
-
/**
* @param string $tag
*
- * @return Tag
- * @deprecated
+ * @return Tag|null
*/
- public function findByTag(string $tag): Tag
+ public function findByTag(string $tag): ?Tag
{
$tags = $this->user->tags()->get();
/** @var Tag $databaseTag */
@@ -112,7 +95,7 @@ class TagRepository implements TagRepositoryInterface
}
}
- return new Tag;
+ return null;
}
/**
@@ -128,17 +111,16 @@ class TagRepository implements TagRepositoryInterface
/**
* @param Tag $tag
*
- * @return Carbon
- * @deprecated
+ * @return Carbon|null
*/
- public function firstUseDate(Tag $tag): Carbon
+ public function firstUseDate(Tag $tag): ?Carbon
{
$journal = $tag->transactionJournals()->orderBy('date', 'ASC')->first();
if (null !== $journal) {
return $journal->date;
}
- return new Carbon;
+ return null;
}
/**
@@ -160,17 +142,16 @@ class TagRepository implements TagRepositoryInterface
/**
* @param Tag $tag
*
- * @return Carbon
- * @deprecated
+ * @return Carbon|null
*/
- public function lastUseDate(Tag $tag): Carbon
+ public function lastUseDate(Tag $tag): ?Carbon
{
$journal = $tag->transactionJournals()->orderBy('date', 'DESC')->first();
if (null !== $journal) {
return $journal->date;
}
- return new Carbon;
+ return null;
}
/**
diff --git a/app/Repositories/Tag/TagRepositoryInterface.php b/app/Repositories/Tag/TagRepositoryInterface.php
index 15e30f9517..c85b819de3 100644
--- a/app/Repositories/Tag/TagRepositoryInterface.php
+++ b/app/Repositories/Tag/TagRepositoryInterface.php
@@ -55,21 +55,12 @@ interface TagRepositoryInterface
*/
public function earnedInPeriod(Tag $tag, Carbon $start, Carbon $end): string;
- /**
- * @param int $tagId
- *
- * @deprecated
- * @return Tag
- */
- public function find(int $tagId): Tag;
-
/**
* @param string $tag
*
- * @return Tag
- * @deprecated
+ * @return Tag|null
*/
- public function findByTag(string $tag): Tag;
+ public function findByTag(string $tag):?Tag;
/**
* @param int $tagId
@@ -82,9 +73,8 @@ interface TagRepositoryInterface
* @param Tag $tag
*
* @return Carbon
- * @deprecated
*/
- public function firstUseDate(Tag $tag): Carbon;
+ public function firstUseDate(Tag $tag): ?Carbon;
/**
* This method returns all the user's tags.
@@ -96,10 +86,9 @@ interface TagRepositoryInterface
/**
* @param Tag $tag
*
- * @return Carbon
- * @deprecated
+ * @return Carbon|null
*/
- public function lastUseDate(Tag $tag): Carbon;
+ public function lastUseDate(Tag $tag): ?Carbon;
/**
* Will return the newest tag (if known) or NULL.
diff --git a/app/Repositories/User/UserRepository.php b/app/Repositories/User/UserRepository.php
index f29f8f73eb..39508717cd 100644
--- a/app/Repositories/User/UserRepository.php
+++ b/app/Repositories/User/UserRepository.php
@@ -162,22 +162,6 @@ class UserRepository implements UserRepositoryInterface
return true;
}
- /**
- * @param int $userId
- *
- * @deprecated
- * @return User
- */
- public function find(int $userId): User
- {
- $user = User::find($userId);
- if (null !== $user) {
- return $user;
- }
-
- return new User;
- }
-
/**
* @param string $email
*
diff --git a/app/Repositories/User/UserRepositoryInterface.php b/app/Repositories/User/UserRepositoryInterface.php
index 8839c738d2..c49c54df2d 100644
--- a/app/Repositories/User/UserRepositoryInterface.php
+++ b/app/Repositories/User/UserRepositoryInterface.php
@@ -101,14 +101,6 @@ interface UserRepositoryInterface
*/
public function destroy(User $user): bool;
- /**
- * @param int $userId
- *
- * @deprecated
- * @return User
- */
- public function find(int $userId): User;
-
/**
* @param string $email
*
diff --git a/app/Support/Import/Information/BunqInformation.php b/app/Support/Import/Information/BunqInformation.php
deleted file mode 100644
index fe45cba550..0000000000
--- a/app/Support/Import/Information/BunqInformation.php
+++ /dev/null
@@ -1,213 +0,0 @@
-<?php
-/**
- * BunqInformation.php
- * Copyright (c) 2017 [email protected]
- *
- * This file is part of Firefly III.
- *
- * Firefly III is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Firefly III is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
- */
-declare(strict_types=1);
-
-namespace FireflyIII\Support\Import\Information;
-
-use FireflyIII\Exceptions\FireflyException;
-use FireflyIII\Services\Bunq\Object\Alias;
-use FireflyIII\Services\Bunq\Object\MonetaryAccountBank;
-use FireflyIII\Services\Bunq\Request\DeleteDeviceSessionRequest;
-use FireflyIII\Services\Bunq\Request\DeviceSessionRequest;
-use FireflyIII\Services\Bunq\Request\ListMonetaryAccountRequest;
-use FireflyIII\Services\Bunq\Request\ListUserRequest;
-use FireflyIII\Services\Bunq\Token\SessionToken;
-use FireflyIII\Support\CacheProperties;
-use FireflyIII\User;
-use Illuminate\Support\Collection;
-use Log;
-
-/**
- * @codeCoverageIgnore
- * @deprecated
- * Class BunqInformation.
- */
-class BunqInformation implements InformationInterface
-{
- /** @var User */
- private $user;
-
- /**
- * Returns a collection of accounts. Preferrably, these follow a uniform Firefly III format so they can be managed over banks.
- *
- * The format for these bank accounts is basically this:
- *
- * id: bank specific id
- * name: bank appointed name
- * number: account number (usually IBAN)
- * currency: ISO code of currency
- * balance: current balance
- *
- *
- * any other fields are optional but can be useful:
- * image: logo or account specific thing
- * color: any associated color.
- *
- * @return array
- *
- * @throws FireflyException
- */
- public function getAccounts(): array
- {
- // cache for an hour:
- $cache = new CacheProperties;
- $cache->addProperty('bunq.get-accounts');
- $cache->addProperty(date('dmy h'));
- if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
- }
- Log::debug('Now in getAccounts()');
- $sessionToken = $this->startSession();
- $userId = $this->getUserInformation($sessionToken);
- // get list of Bunq accounts:
- $accounts = $this->getMonetaryAccounts($sessionToken, $userId);
- $return = [];
- /** @var MonetaryAccountBank $account */
- foreach ($accounts as $account) {
- $current = [
- 'id' => $account->getId(),
- 'name' => $account->getDescription(),
- 'currency' => $account->getCurrency(),
- 'balance' => $account->getBalance()->getValue(),
- 'color' => $account->getSetting()->getColor(),
- ];
- /** @var Alias $alias */
- foreach ($account->getAliases() as $alias) {
- if ('IBAN' === $alias->getType()) {
- $current['number'] = $alias->getValue();
- }
- }
- $return[] = $current;
- }
- $cache->store($return);
-
- $this->closeSession($sessionToken);
-
- return $return;
- }
-
- /**
- * Set the user for this Prerequisites-routine. Class is expected to implement and save this.
- *
- * @param User $user
- */
- public function setUser(User $user): void
- {
- $this->user = $user;
- }
-
- /**
- * @param SessionToken $sessionToken
- *
-
- */
- private function closeSession(SessionToken $sessionToken): void
- {
- Log::debug('Going to close session');
- $apiKey = app('preferences')->getForUser($this->user, 'bunq_api_key')->data;
- $serverPublicKey = app('preferences')->getForUser($this->user, 'bunq_server_public_key')->data;
- $privateKey = app('preferences')->getForUser($this->user, 'bunq_private_key')->data;
- $request = new DeleteDeviceSessionRequest();
- $request->setSecret($apiKey);
- $request->setPrivateKey($privateKey);
- $request->setServerPublicKey($serverPublicKey);
- $request->setSessionToken($sessionToken);
- $request->call();
-
- }
-
- /**
- * @param SessionToken $sessionToken
- * @param int $userId
- *
- * @return Collection
- * @throws FireflyException
- */
- private function getMonetaryAccounts(SessionToken $sessionToken, int $userId): Collection
- {
- $apiKey = app('preferences')->getForUser($this->user, 'bunq_api_key')->data;
- $serverPublicKey = app('preferences')->getForUser($this->user, 'bunq_server_public_key')->data;
- $privateKey = app('preferences')->getForUser($this->user, 'bunq_private_key')->data;
- $request = new ListMonetaryAccountRequest;
-
- $request->setSessionToken($sessionToken);
- $request->setSecret($apiKey);
- $request->setServerPublicKey($serverPublicKey);
- $request->setPrivateKey($privateKey);
- $request->setUserId($userId);
- $request->call();
-
- return $request->getMonetaryAccounts();
- }
-
- /**
- * @param SessionToken $sessionToken
- *
- * @return int
- *
- * @throws FireflyException
- */
- private function getUserInformation(SessionToken $sessionToken): int
- {
- $apiKey = app('preferences')->getForUser($this->user, 'bunq_api_key')->data;
- $serverPublicKey = app('preferences')->getForUser($this->user, 'bunq_server_public_key')->data;
- $privateKey = app('preferences')->getForUser($this->user, 'bunq_private_key')->data;
- $request = new ListUserRequest;
- $request->setSessionToken($sessionToken);
- $request->setSecret($apiKey);
- $request->setServerPublicKey($serverPublicKey);
- $request->setPrivateKey($privateKey);
- $request->call();
- // return the first that isn't null?
- $company = $request->getUserCompany();
- if ($company->getId() > 0) {
- return $company->getId();
- }
- $user = $request->getUserPerson();
- if ($user->getId() > 0) {
- return $user->getId();
- }
- throw new FireflyException('Expected user or company from Bunq, but got neither.');
- }
-
- /**
- * @return SessionToken
- * @throws FireflyException
- */
- private function startSession(): SessionToken
- {
- Log::debug('Now in startSession.');
- $apiKey = app('preferences')->getForUser($this->user, 'bunq_api_key')->data;
- $serverPublicKey = app('preferences')->getForUser($this->user, 'bunq_server_public_key')->data;
- $privateKey = app('preferences')->getForUser($this->user, 'bunq_private_key')->data;
- $installationToken = app('preferences')->getForUser($this->user, 'bunq_installation_token')->data;
- $request = new DeviceSessionRequest();
- $request->setSecret($apiKey);
- $request->setServerPublicKey($serverPublicKey);
- $request->setPrivateKey($privateKey);
- $request->setInstallationToken($installationToken);
- $request->call();
- $sessionToken = $request->getSessionToken();
- Log::debug(sprintf('Now have got session token: %s', serialize($sessionToken)));
-
- return $sessionToken;
- }
-}
diff --git a/app/Support/Import/Information/InformationInterface.php b/app/Support/Import/Information/InformationInterface.php
deleted file mode 100644
index 0e23f7df70..0000000000
--- a/app/Support/Import/Information/InformationInterface.php
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-/**
- * InformationInterface.php
- * Copyright (c) 2017 [email protected]
- *
- * This file is part of Firefly III.
- *
- * Firefly III is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Firefly III is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
- */
-declare(strict_types=1);
-
-namespace FireflyIII\Support\Import\Information;
-
-use FireflyIII\User;
-
-/**
- * @deprecated
- * Interface InformationInterface.
- */
-interface InformationInterface
-{
- /**
- * Returns a collection of accounts. Preferrably, these follow a uniform Firefly III format so they can be managed over banks.
- *
- * The format for these bank accounts is basically this:
- *
- * id: bank specific id
- * name: bank appointed name
- * number: account number (usually IBAN)
- * currency: ISO code of currency
- *
- * any other fields are optional but can be useful:
- * image: logo or account specific thing
- *
- * @return array
- */
- public function getAccounts(): array;
-
- /**
- * Set the user for this Prerequisites-routine. Class is expected to implement and save this.
- *
- * @param User $user
- */
- public function setUser(User $user): void;
-}
diff --git a/app/Support/Models/TransactionJournalTrait.php b/app/Support/Models/TransactionJournalTrait.php
deleted file mode 100644
index 943d5d9568..0000000000
--- a/app/Support/Models/TransactionJournalTrait.php
+++ /dev/null
@@ -1,176 +0,0 @@
-<?php
-/**
- * TransactionJournalTrait.php
- * Copyright (c) 2017 [email protected]
- *
- * This file is part of Firefly III.
- *
- * Firefly III is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Firefly III is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
- */
-declare(strict_types=1);
-
-namespace FireflyIII\Support\Models;
-
-use Carbon\Carbon;
-use FireflyIII\Models\Transaction;
-use FireflyIII\Models\TransactionType;
-use FireflyIII\Support\CacheProperties;
-use Illuminate\Database\Eloquent\Builder;
-use Illuminate\Database\Eloquent\Relations\HasMany;
-use Illuminate\Support\Collection;
-
-/**
- * Class TransactionJournalTrait.
- *
- * @property int $id
- * @property Carbon $date
- * @property string $transaction_type_type
- * @property TransactionType $transactionType
- */
-trait TransactionJournalTrait
-{
- /**
- * @param Builder $query
- * @param string $table
- *
- * @return bool
- */
- public static function isJoined(Builder $query, string $table): bool
- {
- $joins = $query->getQuery()->joins;
- if (null === $joins) {
- return false;
- }
- foreach ($joins as $join) {
- if ($join->table === $table) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * @deprecated
- * @return Collection
- */
- public function destinationAccountList(): Collection
- {
- $cache = new CacheProperties;
- $cache->addProperty($this->id);
- $cache->addProperty('transaction-journal');
- $cache->addProperty('destination-account-list');
- if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
- }
- $transactions = $this->transactions()->where('amount', '>', 0)->orderBy('transactions.account_id')->with('account')->get();
- $list = new Collection;
- /** @var Transaction $t */
- foreach ($transactions as $t) {
- $list->push($t->account);
- }
- $list = $list->unique('id');
- $cache->store($list);
-
- return $list;
- }
-
- /**
- * @deprecated
- * @return Collection
- */
- public function destinationTransactionList(): Collection
- {
- $cache = new CacheProperties;
- $cache->addProperty($this->id);
- $cache->addProperty('transaction-journal');
- $cache->addProperty('destination-transaction-list');
- if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
- }
- $list = $this->transactions()->where('amount', '>', 0)->with('account')->get();
- $cache->store($list);
-
- return $list;
- }
-
- /**
- * @deprecated
- * @return Collection
- */
- public function sourceAccountList(): Collection
- {
- $cache = new CacheProperties;
- $cache->addProperty($this->id);
- $cache->addProperty('transaction-journal');
- $cache->addProperty('source-account-list');
- if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
- }
- $transactions = $this->transactions()->where('amount', '<', 0)->orderBy('transactions.account_id')->with('account')->get();
- $list = new Collection;
- /** @var Transaction $t */
- foreach ($transactions as $t) {
- $list->push($t->account);
- }
- $list = $list->unique('id');
- $cache->store($list);
-
- return $list;
- }
-
- /**
- * @deprecated
- * @return Collection
- */
- public function sourceTransactionList(): Collection
- {
- $cache = new CacheProperties;
- $cache->addProperty($this->id);
- $cache->addProperty('transaction-journal');
- $cache->addProperty('source-transaction-list');
- if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
- }
- $list = $this->transactions()->where('amount', '<', 0)->with('account')->get();
- $cache->store($list);
-
- return $list;
- }
-
- /**
- * @deprecated
- * @return string
- */
- public function transactionTypeStr(): string
- {
- $cache = new CacheProperties;
- $cache->addProperty($this->id);
- $cache->addProperty('transaction-journal');
- $cache->addProperty('type-string');
- if ($cache->has()) {
- return $cache->get(); // @codeCoverageIgnore
- }
-
- $typeStr = $this->transaction_type_type ?? $this->transactionType->type;
- $cache->store($typeStr);
-
- return $typeStr;
- }
-
- /**
- * @return HasMany
- */
- abstract public function transactions(): HasMany;
-}
diff --git a/app/Support/Twig/Journal.php b/app/Support/Twig/Journal.php
index c6502a8f72..632c80a2b3 100644
--- a/app/Support/Twig/Journal.php
+++ b/app/Support/Twig/Journal.php
@@ -26,6 +26,7 @@ use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Category;
use FireflyIII\Models\TransactionJournal;
+use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use FireflyIII\Support\Twig\Extension\TransactionJournal as TransactionJournalExtension;
use Twig_Extension;
@@ -53,8 +54,10 @@ class Journal extends Twig_Extension
return $cache->get(); // @codeCoverageIgnore
}
- $list = $journal->destinationAccountList();
- $array = [];
+ /** @var JournalRepositoryInterface $repository */
+ $repository = app(JournalRepositoryInterface::class);
+ $list = $repository->getJournalDestinationAccounts($journal);
+ $array = [];
/** @var Account $entry */
foreach ($list as $entry) {
if (AccountType::CASH === $entry->accountType->type) {
@@ -119,7 +122,10 @@ class Journal extends Twig_Extension
return $cache->get(); // @codeCoverageIgnore
}
- $list = $journal->sourceAccountList();
+ /** @var JournalRepositoryInterface $repository */
+ $repository = app(JournalRepositoryInterface::class);
+
+ $list = $repository->getJournalSourceAccounts($journal);
$array = [];
/** @var Account $entry */
foreach ($list as $entry) {
diff --git a/app/TransactionRules/Triggers/FromAccountContains.php b/app/TransactionRules/Triggers/FromAccountContains.php
index a551afddc2..efde3010eb 100644
--- a/app/TransactionRules/Triggers/FromAccountContains.php
+++ b/app/TransactionRules/Triggers/FromAccountContains.php
@@ -24,6 +24,7 @@ namespace FireflyIII\TransactionRules\Triggers;
use FireflyIII\Models\Account;
use FireflyIII\Models\TransactionJournal;
+use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Log;
/**
@@ -73,8 +74,11 @@ final class FromAccountContains extends AbstractTrigger implements TriggerInterf
{
$fromAccountName = '';
+ /** @var JournalRepositoryInterface $repository */
+ $repository = app(JournalRepositoryInterface::class);
+
/** @var Account $account */
- foreach ($journal->sourceAccountList() as $account) {
+ foreach ($repository->getJournalSourceAccounts($journal) as $account) {
$fromAccountName .= strtolower($account->name);
}
diff --git a/app/TransactionRules/Triggers/FromAccountEnds.php b/app/TransactionRules/Triggers/FromAccountEnds.php
index a64b0ca254..a0d4eed713 100644
--- a/app/TransactionRules/Triggers/FromAccountEnds.php
+++ b/app/TransactionRules/Triggers/FromAccountEnds.php
@@ -24,6 +24,7 @@ namespace FireflyIII\TransactionRules\Triggers;
use FireflyIII\Models\Account;
use FireflyIII\Models\TransactionJournal;
+use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Log;
/**
@@ -73,8 +74,11 @@ final class FromAccountEnds extends AbstractTrigger implements TriggerInterface
{
$name = '';
+ /** @var JournalRepositoryInterface $repository */
+ $repository = app(JournalRepositoryInterface::class);
+
/** @var Account $account */
- foreach ($journal->sourceAccountList() as $account) {
+ foreach ($repository->getJournalSourceAccounts($journal) as $account) {
$name .= strtolower($account->name);
}
diff --git a/app/TransactionRules/Triggers/FromAccountIs.php b/app/TransactionRules/Triggers/FromAccountIs.php
index 9354c832ae..f2926767c5 100644
--- a/app/TransactionRules/Triggers/FromAccountIs.php
+++ b/app/TransactionRules/Triggers/FromAccountIs.php
@@ -24,6 +24,7 @@ namespace FireflyIII\TransactionRules\Triggers;
use FireflyIII\Models\Account;
use FireflyIII\Models\TransactionJournal;
+use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Log;
/**
@@ -73,8 +74,11 @@ final class FromAccountIs extends AbstractTrigger implements TriggerInterface
{
$name = '';
+ /** @var JournalRepositoryInterface $repository */
+ $repository = app(JournalRepositoryInterface::class);
+
/** @var Account $account */
- foreach ($journal->sourceAccountList() as $account) {
+ foreach ($repository->getJournalSourceAccounts($journal) as $account) {
$name .= strtolower($account->name);
}
diff --git a/app/TransactionRules/Triggers/FromAccountStarts.php b/app/TransactionRules/Triggers/FromAccountStarts.php
index 99a8ae1c49..c0283d7f86 100644
--- a/app/TransactionRules/Triggers/FromAccountStarts.php
+++ b/app/TransactionRules/Triggers/FromAccountStarts.php
@@ -24,6 +24,7 @@ namespace FireflyIII\TransactionRules\Triggers;
use FireflyIII\Models\Account;
use FireflyIII\Models\TransactionJournal;
+use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Log;
/**
@@ -73,8 +74,11 @@ final class FromAccountStarts extends AbstractTrigger implements TriggerInterfac
{
$name = '';
+ /** @var JournalRepositoryInterface $repository */
+ $repository = app(JournalRepositoryInterface::class);
+
/** @var Account $account */
- foreach ($journal->sourceAccountList() as $account) {
+ foreach ($repository->getJournalSourceAccounts($journal) as $account) {
$name .= strtolower($account->name);
}
diff --git a/app/TransactionRules/Triggers/ToAccountContains.php b/app/TransactionRules/Triggers/ToAccountContains.php
index a4079522e5..f70c54adca 100644
--- a/app/TransactionRules/Triggers/ToAccountContains.php
+++ b/app/TransactionRules/Triggers/ToAccountContains.php
@@ -24,6 +24,7 @@ namespace FireflyIII\TransactionRules\Triggers;
use FireflyIII\Models\Account;
use FireflyIII\Models\TransactionJournal;
+use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Log;
/**
@@ -73,8 +74,11 @@ final class ToAccountContains extends AbstractTrigger implements TriggerInterfac
{
$toAccountName = '';
+ /** @var JournalRepositoryInterface $repository */
+ $repository = app(JournalRepositoryInterface::class);
+
/** @var Account $account */
- foreach ($journal->destinationAccountList() as $account) {
+ foreach ($repository->getJournalDestinationAccounts($journal) as $account) {
$toAccountName .= strtolower($account->name);
}
diff --git a/app/TransactionRules/Triggers/ToAccountEnds.php b/app/TransactionRules/Triggers/ToAccountEnds.php
index 1ca88c56dc..b058c53117 100644
--- a/app/TransactionRules/Triggers/ToAccountEnds.php
+++ b/app/TransactionRules/Triggers/ToAccountEnds.php
@@ -24,6 +24,7 @@ namespace FireflyIII\TransactionRules\Triggers;
use FireflyIII\Models\Account;
use FireflyIII\Models\TransactionJournal;
+use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Log;
/**
@@ -73,8 +74,11 @@ final class ToAccountEnds extends AbstractTrigger implements TriggerInterface
{
$toAccountName = '';
+ /** @var JournalRepositoryInterface $repository */
+ $repository = app(JournalRepositoryInterface::class);
+
/** @var Account $account */
- foreach ($journal->destinationAccountList() as $account) {
+ foreach ($repository->getJournalDestinationAccounts($journal) as $account) {
$toAccountName .= strtolower($account->name);
}
diff --git a/app/TransactionRules/Triggers/ToAccountIs.php b/app/TransactionRules/Triggers/ToAccountIs.php
index 658b96adf6..1e9a1d8051 100644
--- a/app/TransactionRules/Triggers/ToAccountIs.php
+++ b/app/TransactionRules/Triggers/ToAccountIs.php
@@ -24,6 +24,7 @@ namespace FireflyIII\TransactionRules\Triggers;
use FireflyIII\Models\Account;
use FireflyIII\Models\TransactionJournal;
+use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Log;
/**
@@ -73,8 +74,11 @@ final class ToAccountIs extends AbstractTrigger implements TriggerInterface
{
$toAccountName = '';
+ /** @var JournalRepositoryInterface $repository */
+ $repository = app(JournalRepositoryInterface::class);
+
/** @var Account $account */
- foreach ($journal->destinationAccountList() as $account) {
+ foreach ($repository->getJournalDestinationAccounts($journal) as $account) {
$toAccountName .= strtolower($account->name);
}
diff --git a/app/TransactionRules/Triggers/ToAccountStarts.php b/app/TransactionRules/Triggers/ToAccountStarts.php
index 8583235369..c8486941ea 100644
--- a/app/TransactionRules/Triggers/ToAccountStarts.php
+++ b/app/TransactionRules/Triggers/ToAccountStarts.php
@@ -24,6 +24,7 @@ namespace FireflyIII\TransactionRules\Triggers;
use FireflyIII\Models\Account;
use FireflyIII\Models\TransactionJournal;
+use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Log;
/**
@@ -73,8 +74,11 @@ final class ToAccountStarts extends AbstractTrigger implements TriggerInterface
{
$toAccountName = '';
+ /** @var JournalRepositoryInterface $repository */
+ $repository = app(JournalRepositoryInterface::class);
+
/** @var Account $account */
- foreach ($journal->destinationAccountList() as $account) {
+ foreach ($repository->getJournalDestinationAccounts($journal) as $account) {
$toAccountName .= strtolower($account->name);
}
diff --git a/app/User.php b/app/User.php
index e0f7c618bf..2fbca22b1d 100644
--- a/app/User.php
+++ b/app/User.php
@@ -219,28 +219,6 @@ class User extends Authenticatable
return (string)bin2hex($bytes);
}
- /**
- * @codeCoverageIgnore
- * Checks if the user has a role by its name.
- *
- * Full credit goes to: https://github.com/Zizaco/entrust
- *
- * @param string $name
- *
- * @deprecated
- * @return bool
- */
- public function hasRole(string $name): bool
- {
- foreach ($this->roles as $role) {
- if ($role->name === $name) {
- return true;
- }
- }
-
- return false;
- }
-
/**
* @codeCoverageIgnore
* Link to import jobs.
diff --git a/tests/Unit/TransactionRules/Triggers/FromAccountContainsTest.php b/tests/Unit/TransactionRules/Triggers/FromAccountContainsTest.php
index 39e17cd036..e96de4909b 100644
--- a/tests/Unit/TransactionRules/Triggers/FromAccountContainsTest.php
+++ b/tests/Unit/TransactionRules/Triggers/FromAccountContainsTest.php
@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace Tests\Unit\TransactionRules\Triggers;
use FireflyIII\Models\TransactionJournal;
+use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\TransactionRules\Triggers\FromAccountContains;
use Tests\TestCase;
@@ -36,6 +37,7 @@ class FromAccountContainsTest extends TestCase
*/
public function testTriggered(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$count = 0;
while ($count === 0) {
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
@@ -54,6 +56,7 @@ class FromAccountContainsTest extends TestCase
*/
public function testTriggeredNot(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$trigger = FromAccountContains::makeFromStrings('some name' . random_int(1, 234), false);
@@ -66,6 +69,7 @@ class FromAccountContainsTest extends TestCase
*/
public function testWillMatchEverythingEmpty(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$value = '';
$result = FromAccountContains::willMatchEverything($value);
$this->assertTrue($result);
@@ -76,6 +80,7 @@ class FromAccountContainsTest extends TestCase
*/
public function testWillMatchEverythingNotNull(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$value = 'x';
$result = FromAccountContains::willMatchEverything($value);
$this->assertFalse($result);
@@ -86,6 +91,7 @@ class FromAccountContainsTest extends TestCase
*/
public function testWillMatchEverythingNull(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$value = null;
$result = FromAccountContains::willMatchEverything($value);
$this->assertTrue($result);
diff --git a/tests/Unit/TransactionRules/Triggers/FromAccountEndsTest.php b/tests/Unit/TransactionRules/Triggers/FromAccountEndsTest.php
index 0c362edd1f..5fb022732f 100644
--- a/tests/Unit/TransactionRules/Triggers/FromAccountEndsTest.php
+++ b/tests/Unit/TransactionRules/Triggers/FromAccountEndsTest.php
@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace Tests\Unit\TransactionRules\Triggers;
use FireflyIII\Models\TransactionJournal;
+use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\TransactionRules\Triggers\FromAccountEnds;
use Tests\TestCase;
@@ -36,6 +37,7 @@ class FromAccountEndsTest extends TestCase
*/
public function testTriggered(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$count = 0;
while ($count === 0) {
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
@@ -54,6 +56,7 @@ class FromAccountEndsTest extends TestCase
*/
public function testTriggeredLonger(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$count = 0;
while ($count === 0) {
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
@@ -72,6 +75,7 @@ class FromAccountEndsTest extends TestCase
*/
public function testTriggeredNot(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$trigger = FromAccountEnds::makeFromStrings('some name' . random_int(1, 234), false);
@@ -84,6 +88,7 @@ class FromAccountEndsTest extends TestCase
*/
public function testWillMatchEverythingEmpty(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$value = '';
$result = FromAccountEnds::willMatchEverything($value);
$this->assertTrue($result);
@@ -94,6 +99,7 @@ class FromAccountEndsTest extends TestCase
*/
public function testWillMatchEverythingNotNull(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$value = 'x';
$result = FromAccountEnds::willMatchEverything($value);
$this->assertFalse($result);
@@ -104,6 +110,7 @@ class FromAccountEndsTest extends TestCase
*/
public function testWillMatchEverythingNull(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$value = null;
$result = FromAccountEnds::willMatchEverything($value);
$this->assertTrue($result);
diff --git a/tests/Unit/TransactionRules/Triggers/FromAccountIsTest.php b/tests/Unit/TransactionRules/Triggers/FromAccountIsTest.php
index d4ef43b734..c746a39b85 100644
--- a/tests/Unit/TransactionRules/Triggers/FromAccountIsTest.php
+++ b/tests/Unit/TransactionRules/Triggers/FromAccountIsTest.php
@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace Tests\Unit\TransactionRules\Triggers;
use FireflyIII\Models\TransactionJournal;
+use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\TransactionRules\Triggers\FromAccountIs;
use Tests\TestCase;
use Log;
@@ -36,6 +37,7 @@ class FromAccountIsTest extends TestCase
*/
public function testTriggered(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$loops = 0; // FINAL LOOP METHOD.
do {
/** @var TransactionJournal $journal */
@@ -62,6 +64,7 @@ class FromAccountIsTest extends TestCase
*/
public function testTriggeredNot(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$trigger = FromAccountIs::makeFromStrings('some name' . random_int(1, 234), false);
@@ -74,6 +77,7 @@ class FromAccountIsTest extends TestCase
*/
public function testWillMatchEverythingEmpty(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$value = '';
$result = FromAccountIs::willMatchEverything($value);
$this->assertTrue($result);
@@ -84,6 +88,7 @@ class FromAccountIsTest extends TestCase
*/
public function testWillMatchEverythingNotNull(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$value = 'x';
$result = FromAccountIs::willMatchEverything($value);
$this->assertFalse($result);
@@ -94,6 +99,7 @@ class FromAccountIsTest extends TestCase
*/
public function testWillMatchEverythingNull(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$value = null;
$result = FromAccountIs::willMatchEverything($value);
$this->assertTrue($result);
diff --git a/tests/Unit/TransactionRules/Triggers/FromAccountStartsTest.php b/tests/Unit/TransactionRules/Triggers/FromAccountStartsTest.php
index ecf2f2e8cc..467f57c438 100644
--- a/tests/Unit/TransactionRules/Triggers/FromAccountStartsTest.php
+++ b/tests/Unit/TransactionRules/Triggers/FromAccountStartsTest.php
@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace Tests\Unit\TransactionRules\Triggers;
use FireflyIII\Models\TransactionJournal;
+use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\TransactionRules\Triggers\FromAccountStarts;
use Log;
use Tests\TestCase;
@@ -46,6 +47,7 @@ class FromAccountStartsTest extends TestCase
*/
public function testTriggered(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
Log::debug('In testTriggered()');
$loops = 0; // FINAL LOOP METHOD.
do {
@@ -77,6 +79,7 @@ class FromAccountStartsTest extends TestCase
*/
public function testTriggeredLonger(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
Log::debug('In testTriggeredLonger()');
$loops = 0; // FINAL LOOP METHOD.
do {
@@ -108,6 +111,7 @@ class FromAccountStartsTest extends TestCase
*/
public function testTriggeredNot(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$trigger = FromAccountStarts::makeFromStrings('some name' . random_int(1, 234), false);
@@ -120,6 +124,7 @@ class FromAccountStartsTest extends TestCase
*/
public function testWillMatchEverythingEmpty(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$value = '';
$result = FromAccountStarts::willMatchEverything($value);
$this->assertTrue($result);
@@ -130,6 +135,7 @@ class FromAccountStartsTest extends TestCase
*/
public function testWillMatchEverythingNotNull(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$value = 'x';
$result = FromAccountStarts::willMatchEverything($value);
$this->assertFalse($result);
@@ -140,6 +146,7 @@ class FromAccountStartsTest extends TestCase
*/
public function testWillMatchEverythingNull(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$value = null;
$result = FromAccountStarts::willMatchEverything($value);
$this->assertTrue($result);
diff --git a/tests/Unit/TransactionRules/Triggers/ToAccountContainsTest.php b/tests/Unit/TransactionRules/Triggers/ToAccountContainsTest.php
index cfff2cd793..a441ac7b20 100644
--- a/tests/Unit/TransactionRules/Triggers/ToAccountContainsTest.php
+++ b/tests/Unit/TransactionRules/Triggers/ToAccountContainsTest.php
@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace Tests\Unit\TransactionRules\Triggers;
use FireflyIII\Models\TransactionJournal;
+use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\TransactionRules\Triggers\ToAccountContains;
use Tests\TestCase;
@@ -36,6 +37,8 @@ class ToAccountContainsTest extends TestCase
*/
public function testTriggered(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
+
$count = 0;
do {
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
@@ -56,6 +59,7 @@ class ToAccountContainsTest extends TestCase
*/
public function testTriggeredNot(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$count = 0;
do {
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
@@ -76,6 +80,7 @@ class ToAccountContainsTest extends TestCase
*/
public function testWillMatchEverythingEmpty(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$value = '';
$result = ToAccountContains::willMatchEverything($value);
$this->assertTrue($result);
@@ -86,6 +91,7 @@ class ToAccountContainsTest extends TestCase
*/
public function testWillMatchEverythingNotNull(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$value = 'x';
$result = ToAccountContains::willMatchEverything($value);
$this->assertFalse($result);
@@ -96,6 +102,7 @@ class ToAccountContainsTest extends TestCase
*/
public function testWillMatchEverythingNull(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$value = null;
$result = ToAccountContains::willMatchEverything($value);
$this->assertTrue($result);
diff --git a/tests/Unit/TransactionRules/Triggers/ToAccountEndsTest.php b/tests/Unit/TransactionRules/Triggers/ToAccountEndsTest.php
index 795eb179fa..91d46c04a9 100644
--- a/tests/Unit/TransactionRules/Triggers/ToAccountEndsTest.php
+++ b/tests/Unit/TransactionRules/Triggers/ToAccountEndsTest.php
@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace Tests\Unit\TransactionRules\Triggers;
use FireflyIII\Models\TransactionJournal;
+use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\TransactionRules\Triggers\ToAccountEnds;
use Log;
use Tests\TestCase;
@@ -37,7 +38,8 @@ class ToAccountEndsTest extends TestCase
*/
public function testTriggered(): void
{
- $loops = 0; // FINAL LOOP METHOD.
+ $repository = $this->mock(JournalRepositoryInterface::class);
+ $loops = 0; // FINAL LOOP METHOD.
do {
/** @var TransactionJournal $journal */
$journal = $this->user()->transactionJournals()->inRandomOrder()->whereNull('deleted_at')->first();
@@ -68,7 +70,8 @@ class ToAccountEndsTest extends TestCase
*/
public function testTriggeredLonger(): void
{
- $loops = 0; // FINAL LOOP METHOD.
+ $repository = $this->mock(JournalRepositoryInterface::class);
+ $loops = 0; // FINAL LOOP METHOD.
do {
/** @var TransactionJournal $journal */
$journal = $this->user()->transactionJournals()->inRandomOrder()->whereNull('deleted_at')->first();
@@ -98,7 +101,8 @@ class ToAccountEndsTest extends TestCase
*/
public function testTriggeredNot(): void
{
- $loops = 0; // FINAL LOOP METHOD.
+ $repository = $this->mock(JournalRepositoryInterface::class);
+ $loops = 0; // FINAL LOOP METHOD.
do {
/** @var TransactionJournal $journal */
$journal = $this->user()->transactionJournals()->inRandomOrder()->whereNull('deleted_at')->first();
@@ -128,8 +132,9 @@ class ToAccountEndsTest extends TestCase
*/
public function testWillMatchEverythingEmpty(): void
{
- $value = '';
- $result = ToAccountEnds::willMatchEverything($value);
+ $repository = $this->mock(JournalRepositoryInterface::class);
+ $value = '';
+ $result = ToAccountEnds::willMatchEverything($value);
$this->assertTrue($result);
}
@@ -138,8 +143,9 @@ class ToAccountEndsTest extends TestCase
*/
public function testWillMatchEverythingNotNull(): void
{
- $value = 'x';
- $result = ToAccountEnds::willMatchEverything($value);
+ $repository = $this->mock(JournalRepositoryInterface::class);
+ $value = 'x';
+ $result = ToAccountEnds::willMatchEverything($value);
$this->assertFalse($result);
}
@@ -148,8 +154,9 @@ class ToAccountEndsTest extends TestCase
*/
public function testWillMatchEverythingNull(): void
{
- $value = null;
- $result = ToAccountEnds::willMatchEverything($value);
+ $repository = $this->mock(JournalRepositoryInterface::class);
+ $value = null;
+ $result = ToAccountEnds::willMatchEverything($value);
$this->assertTrue($result);
}
}
diff --git a/tests/Unit/TransactionRules/Triggers/ToAccountIsTest.php b/tests/Unit/TransactionRules/Triggers/ToAccountIsTest.php
index 44ef88bd18..a2ac324a0e 100644
--- a/tests/Unit/TransactionRules/Triggers/ToAccountIsTest.php
+++ b/tests/Unit/TransactionRules/Triggers/ToAccountIsTest.php
@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace Tests\Unit\TransactionRules\Triggers;
use FireflyIII\Models\TransactionJournal;
+use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\TransactionRules\Triggers\ToAccountIs;
use Tests\TestCase;
use Log;
@@ -37,6 +38,7 @@ class ToAccountIsTest extends TestCase
*/
public function testTriggered(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$loops = 0; // FINAL LOOP METHOD.
do {
/** @var TransactionJournal $journal */
@@ -64,6 +66,7 @@ class ToAccountIsTest extends TestCase
*/
public function testTriggeredNot(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$loops = 0; // FINAL LOOP METHOD.
do {
/** @var TransactionJournal $journal */
@@ -89,6 +92,7 @@ class ToAccountIsTest extends TestCase
*/
public function testWillMatchEverythingEmpty(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$value = '';
$result = ToAccountIs::willMatchEverything($value);
$this->assertTrue($result);
@@ -99,6 +103,7 @@ class ToAccountIsTest extends TestCase
*/
public function testWillMatchEverythingNotNull(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$value = 'x';
$result = ToAccountIs::willMatchEverything($value);
$this->assertFalse($result);
@@ -109,6 +114,7 @@ class ToAccountIsTest extends TestCase
*/
public function testWillMatchEverythingNull(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
$value = null;
$result = ToAccountIs::willMatchEverything($value);
$this->assertTrue($result);
diff --git a/tests/Unit/TransactionRules/Triggers/ToAccountStartsTest.php b/tests/Unit/TransactionRules/Triggers/ToAccountStartsTest.php
index 8b05f84aac..2eeb5b1fc7 100644
--- a/tests/Unit/TransactionRules/Triggers/ToAccountStartsTest.php
+++ b/tests/Unit/TransactionRules/Triggers/ToAccountStartsTest.php
@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace Tests\Unit\TransactionRules\Triggers;
use FireflyIII\Models\TransactionJournal;
+use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\TransactionRules\Triggers\ToAccountStarts;
use Log;
use Tests\TestCase;
@@ -37,6 +38,7 @@ class ToAccountStartsTest extends TestCase
*/
public function testTriggered(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
Log::debug('Now in testTriggered');
$loops = 0; // FINAL LOOP METHOD.
@@ -65,6 +67,7 @@ class ToAccountStartsTest extends TestCase
*/
public function testTriggeredLonger(): void
{
+ $repository = $this->mock(JournalRepositoryInterface::class);
Log::debug('Now in testTriggeredLonger');
@@ -93,7 +96,8 @@ class ToAccountStartsTest extends TestCase
*/
public function testTriggeredNot(): void
{
- $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
+ $repository = $this->mock(JournalRepositoryInterface::class);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$trigger = ToAccountStarts::makeFromStrings('some name' . random_int(1, 234), false);
$result = $trigger->triggered($journal);
@@ -105,8 +109,9 @@ class ToAccountStartsTest extends TestCase
*/
public function testWillMatchEverythingEmpty(): void
{
- $value = '';
- $result = ToAccountStarts::willMatchEverything($value);
+ $repository = $this->mock(JournalRepositoryInterface::class);
+ $value = '';
+ $result = ToAccountStarts::willMatchEverything($value);
$this->assertTrue($result);
}
@@ -115,8 +120,9 @@ class ToAccountStartsTest extends TestCase
*/
public function testWillMatchEverythingNotNull(): void
{
- $value = 'x';
- $result = ToAccountStarts::willMatchEverything($value);
+ $repository = $this->mock(JournalRepositoryInterface::class);
+ $value = 'x';
+ $result = ToAccountStarts::willMatchEverything($value);
$this->assertFalse($result);
}
@@ -125,8 +131,9 @@ class ToAccountStartsTest extends TestCase
*/
public function testWillMatchEverythingNull(): void
{
- $value = null;
- $result = ToAccountStarts::willMatchEverything($value);
+ $repository = $this->mock(JournalRepositoryInterface::class);
+ $value = null;
+ $result = ToAccountStarts::willMatchEverything($value);
$this->assertTrue($result);
}
}