From 03956af88ac062dda3e028e59b065b24cf190a17 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 6 Sep 2018 12:29:32 +0200 Subject: [PATCH] Warn when classes are used in testing environment; this means tests aren't efficient. --- app/Factory/AccountFactory.php | 10 +++++++++ app/Factory/AccountMetaFactory.php | 10 ++++++++- app/Factory/AttachmentFactory.php | 10 +++++++++ app/Factory/BillFactory.php | 10 +++++++++ app/Factory/BudgetFactory.php | 11 ++++++++++ app/Factory/CategoryFactory.php | 10 +++++++++ app/Factory/PiggyBankEventFactory.php | 10 +++++++++ app/Factory/PiggyBankFactory.php | 11 ++++++++++ app/Factory/RecurrenceFactory.php | 10 +++++++++ app/Factory/TagFactory.php | 11 ++++++++++ app/Factory/TransactionCurrencyFactory.php | 10 +++++++++ app/Factory/TransactionFactory.php | 10 +++++++++ app/Factory/TransactionJournalFactory.php | 10 +++++++++ app/Factory/TransactionJournalMetaFactory.php | 10 +++++++++ app/Factory/TransactionTypeFactory.php | 12 +++++++++- .../Chart/Basic/ChartJsGenerator.php | 12 +++++++++- app/Helpers/Attachments/AttachmentHelper.php | 5 +++++ app/Helpers/Chart/MetaPieChart.php | 6 +++++ .../Collector/TransactionCollector.php | 10 +++++++++ app/Helpers/FiscalHelper.php | 5 +++++ app/Helpers/Help/Help.php | 10 +++++++++ app/Helpers/Report/BalanceReportHelper.php | 5 +++++ app/Helpers/Report/BudgetReportHelper.php | 6 +++++ app/Helpers/Report/NetWorth.php | 10 +++++++++ app/Helpers/Report/PopupReport.php | 12 +++++++++- app/Helpers/Report/ReportHelper.php | 8 ++++++- app/Http/Controllers/Admin/LinkController.php | 22 +++++++++---------- app/Services/IP/IpifyOrg.php | 10 +++++++++ .../Destroy/AccountDestroyService.php | 10 +++++++++ .../Internal/Destroy/BillDestroyService.php | 10 +++++++++ .../Destroy/CategoryDestroyService.php | 10 +++++++++ .../Destroy/CurrencyDestroyService.php | 10 +++++++++ .../Destroy/JournalDestroyService.php | 10 +++++++++ .../Destroy/RecurrenceDestroyService.php | 10 +++++++++ app/Services/Internal/File/EncryptService.php | 10 +++++++++ .../Internal/Update/AccountUpdateService.php | 11 +++++++++- .../Internal/Update/BillUpdateService.php | 12 +++++++++- .../Internal/Update/CategoryUpdateService.php | 12 +++++++++- .../Internal/Update/CurrencyUpdateService.php | 12 +++++++++- .../Internal/Update/JournalUpdateService.php | 11 +++++++++- .../Update/TransactionUpdateService.php | 12 +++++++++- app/Services/Password/PwndVerifierV2.php | 10 +++++++++ app/Support/Search/Search.php | 5 +++++ .../Controllers/ExportControllerTest.php | 1 + 44 files changed, 410 insertions(+), 22 deletions(-) diff --git a/app/Factory/AccountFactory.php b/app/Factory/AccountFactory.php index 6be9b42330..3c22db43be 100644 --- a/app/Factory/AccountFactory.php +++ b/app/Factory/AccountFactory.php @@ -41,6 +41,16 @@ use Log; */ class AccountFactory { + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + use AccountServiceTrait; /** @var User */ private $user; diff --git a/app/Factory/AccountMetaFactory.php b/app/Factory/AccountMetaFactory.php index 5861e81b4d..f07b3c37e9 100644 --- a/app/Factory/AccountMetaFactory.php +++ b/app/Factory/AccountMetaFactory.php @@ -34,7 +34,15 @@ use Log; */ class AccountMetaFactory { - + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } /** * @param array $data * diff --git a/app/Factory/AttachmentFactory.php b/app/Factory/AttachmentFactory.php index 414b87661e..cfe5e97dcc 100644 --- a/app/Factory/AttachmentFactory.php +++ b/app/Factory/AttachmentFactory.php @@ -26,12 +26,22 @@ namespace FireflyIII\Factory; use FireflyIII\Models\Attachment; use FireflyIII\Models\Note; use FireflyIII\User; +use Log; /** * Class AttachmentFactory */ class AttachmentFactory { + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } /** @var User */ private $user; diff --git a/app/Factory/BillFactory.php b/app/Factory/BillFactory.php index c08cea5a8d..a01d37647a 100644 --- a/app/Factory/BillFactory.php +++ b/app/Factory/BillFactory.php @@ -36,6 +36,16 @@ use Log; */ class BillFactory { + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + use BillServiceTrait; /** @var User */ private $user; diff --git a/app/Factory/BudgetFactory.php b/app/Factory/BudgetFactory.php index 49ec300f00..5be0326937 100644 --- a/app/Factory/BudgetFactory.php +++ b/app/Factory/BudgetFactory.php @@ -27,12 +27,23 @@ namespace FireflyIII\Factory; use FireflyIII\Models\Budget; use FireflyIII\User; use Illuminate\Support\Collection; +use Log; /** * Class BudgetFactory. */ class BudgetFactory { + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + /** @var User */ private $user; diff --git a/app/Factory/CategoryFactory.php b/app/Factory/CategoryFactory.php index f68fe7c732..1df98e446a 100644 --- a/app/Factory/CategoryFactory.php +++ b/app/Factory/CategoryFactory.php @@ -34,6 +34,16 @@ use Log; */ class CategoryFactory { + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + /** @var User */ private $user; diff --git a/app/Factory/PiggyBankEventFactory.php b/app/Factory/PiggyBankEventFactory.php index 8117ddddcb..9aee6bfb92 100644 --- a/app/Factory/PiggyBankEventFactory.php +++ b/app/Factory/PiggyBankEventFactory.php @@ -37,6 +37,16 @@ use Log; */ class PiggyBankEventFactory { + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + /** * @param TransactionJournal $journal * @param PiggyBank|null $piggyBank diff --git a/app/Factory/PiggyBankFactory.php b/app/Factory/PiggyBankFactory.php index a81a421bf9..e22444d210 100644 --- a/app/Factory/PiggyBankFactory.php +++ b/app/Factory/PiggyBankFactory.php @@ -26,12 +26,23 @@ namespace FireflyIII\Factory; use FireflyIII\Models\PiggyBank; use FireflyIII\User; +use Log; /** * Class PiggyBankFactory */ class PiggyBankFactory { + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + /** @var User */ private $user; diff --git a/app/Factory/RecurrenceFactory.php b/app/Factory/RecurrenceFactory.php index 7ae0bf9787..a88f19d44d 100644 --- a/app/Factory/RecurrenceFactory.php +++ b/app/Factory/RecurrenceFactory.php @@ -39,6 +39,16 @@ use Log; */ class RecurrenceFactory { + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + use TransactionTypeTrait, TransactionServiceTrait, RecurringTransactionTrait; /** @var User */ diff --git a/app/Factory/TagFactory.php b/app/Factory/TagFactory.php index d3399d04a2..07ad4e3a0f 100644 --- a/app/Factory/TagFactory.php +++ b/app/Factory/TagFactory.php @@ -27,12 +27,23 @@ namespace FireflyIII\Factory; use FireflyIII\Models\Tag; use FireflyIII\User; use Illuminate\Support\Collection; +use Log; /** * Class TagFactory */ class TagFactory { + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + /** @var Collection */ private $tags; /** @var User */ diff --git a/app/Factory/TransactionCurrencyFactory.php b/app/Factory/TransactionCurrencyFactory.php index 7f7b4548af..bbf87849f8 100644 --- a/app/Factory/TransactionCurrencyFactory.php +++ b/app/Factory/TransactionCurrencyFactory.php @@ -36,6 +36,16 @@ use Log; */ class TransactionCurrencyFactory { + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + /** * @param array $data * diff --git a/app/Factory/TransactionFactory.php b/app/Factory/TransactionFactory.php index ad0f6d985e..a53e314045 100644 --- a/app/Factory/TransactionFactory.php +++ b/app/Factory/TransactionFactory.php @@ -40,6 +40,16 @@ use Log; */ class TransactionFactory { + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + use TransactionServiceTrait; /** @var User */ diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.php index 7cdb758772..f57af20e70 100644 --- a/app/Factory/TransactionJournalFactory.php +++ b/app/Factory/TransactionJournalFactory.php @@ -36,6 +36,16 @@ use Log; */ class TransactionJournalFactory { + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + use JournalServiceTrait, TransactionTypeTrait; /** @var User The user */ private $user; diff --git a/app/Factory/TransactionJournalMetaFactory.php b/app/Factory/TransactionJournalMetaFactory.php index 7ffc1db139..04f5310b21 100644 --- a/app/Factory/TransactionJournalMetaFactory.php +++ b/app/Factory/TransactionJournalMetaFactory.php @@ -34,6 +34,16 @@ use Log; */ class TransactionJournalMetaFactory { + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + /** * @param array $data * diff --git a/app/Factory/TransactionTypeFactory.php b/app/Factory/TransactionTypeFactory.php index d684555390..ff4865d890 100644 --- a/app/Factory/TransactionTypeFactory.php +++ b/app/Factory/TransactionTypeFactory.php @@ -26,12 +26,22 @@ declare(strict_types=1); namespace FireflyIII\Factory; use FireflyIII\Models\TransactionType; - +use Log; /** * Class TransactionTypeFactory */ class TransactionTypeFactory { + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + /** * @param string $type * diff --git a/app/Generator/Chart/Basic/ChartJsGenerator.php b/app/Generator/Chart/Basic/ChartJsGenerator.php index 28862b1706..e14cfb608e 100644 --- a/app/Generator/Chart/Basic/ChartJsGenerator.php +++ b/app/Generator/Chart/Basic/ChartJsGenerator.php @@ -23,12 +23,22 @@ declare(strict_types=1); namespace FireflyIII\Generator\Chart\Basic; use FireflyIII\Support\ChartColour; - +use Log; /** * Class ChartJsGenerator. */ class ChartJsGenerator implements GeneratorInterface { + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + /** * Will generate a Chart JS compatible array from the given input. Expects this format. * diff --git a/app/Helpers/Attachments/AttachmentHelper.php b/app/Helpers/Attachments/AttachmentHelper.php index 9c9c7bf55e..39bb6eb94e 100644 --- a/app/Helpers/Attachments/AttachmentHelper.php +++ b/app/Helpers/Attachments/AttachmentHelper.php @@ -63,8 +63,13 @@ class AttachmentHelper implements AttachmentHelperInterface $this->messages = new MessageBag; $this->attachments = new Collection; $this->uploadDisk = Storage::disk('upload'); + + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } } + /** * Returns the content of an attachment. * diff --git a/app/Helpers/Chart/MetaPieChart.php b/app/Helpers/Chart/MetaPieChart.php index a6c97ef32d..7c1ce502c6 100644 --- a/app/Helpers/Chart/MetaPieChart.php +++ b/app/Helpers/Chart/MetaPieChart.php @@ -38,6 +38,7 @@ use FireflyIII\Repositories\Category\CategoryRepositoryInterface; use FireflyIII\Repositories\Tag\TagRepositoryInterface; use FireflyIII\User; use Illuminate\Support\Collection; +use Log; /** * Class MetaPieChart. @@ -88,6 +89,11 @@ class MetaPieChart implements MetaPieChartInterface $this->budgets = new Collection; $this->categories = new Collection; $this->tags = new Collection; + + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } /** diff --git a/app/Helpers/Collector/TransactionCollector.php b/app/Helpers/Collector/TransactionCollector.php index 680ff6c944..5e7456b938 100644 --- a/app/Helpers/Collector/TransactionCollector.php +++ b/app/Helpers/Collector/TransactionCollector.php @@ -57,6 +57,16 @@ use Log; */ class TransactionCollector implements TransactionCollectorInterface { + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + /** @var array */ private $accountIds = []; diff --git a/app/Helpers/FiscalHelper.php b/app/Helpers/FiscalHelper.php index b3641939bc..1b51cb021a 100644 --- a/app/Helpers/FiscalHelper.php +++ b/app/Helpers/FiscalHelper.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace FireflyIII\Helpers; use Carbon\Carbon; +use Log; /** * Class FiscalHelper. @@ -38,6 +39,10 @@ class FiscalHelper implements FiscalHelperInterface public function __construct() { $this->useCustomFiscalYear = app('preferences')->get('customFiscalYear', false)->data; + + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } } /** diff --git a/app/Helpers/Help/Help.php b/app/Helpers/Help/Help.php index a07818d6cd..d50720049b 100644 --- a/app/Helpers/Help/Help.php +++ b/app/Helpers/Help/Help.php @@ -40,6 +40,16 @@ class Help implements HelpInterface /** @var string The user agent. */ protected $userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36'; + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + /** * Get from cache. * diff --git a/app/Helpers/Report/BalanceReportHelper.php b/app/Helpers/Report/BalanceReportHelper.php index ae1404c83f..80825a2ffd 100644 --- a/app/Helpers/Report/BalanceReportHelper.php +++ b/app/Helpers/Report/BalanceReportHelper.php @@ -51,6 +51,11 @@ class BalanceReportHelper implements BalanceReportHelperInterface public function __construct(BudgetRepositoryInterface $budgetRepository) { $this->budgetRepository = $budgetRepository; + + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } /** diff --git a/app/Helpers/Report/BudgetReportHelper.php b/app/Helpers/Report/BudgetReportHelper.php index dde31c246c..357dc01040 100644 --- a/app/Helpers/Report/BudgetReportHelper.php +++ b/app/Helpers/Report/BudgetReportHelper.php @@ -27,6 +27,7 @@ use FireflyIII\Models\Budget; use FireflyIII\Models\BudgetLimit; use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; use Illuminate\Support\Collection; +use Log; /** * Class BudgetReportHelper. @@ -46,6 +47,11 @@ class BudgetReportHelper implements BudgetReportHelperInterface public function __construct(BudgetRepositoryInterface $repository) { $this->repository = $repository; + + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } /** diff --git a/app/Helpers/Report/NetWorth.php b/app/Helpers/Report/NetWorth.php index 8e27cfc519..ad20cc3bb0 100644 --- a/app/Helpers/Report/NetWorth.php +++ b/app/Helpers/Report/NetWorth.php @@ -48,6 +48,16 @@ class NetWorth implements NetWorthInterface /** @var User */ private $user; + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + /** * Returns the user's net worth in an array with the following layout: * diff --git a/app/Helpers/Report/PopupReport.php b/app/Helpers/Report/PopupReport.php index a50b248377..a5fe92a31f 100644 --- a/app/Helpers/Report/PopupReport.php +++ b/app/Helpers/Report/PopupReport.php @@ -30,7 +30,7 @@ use FireflyIII\Models\Transaction; use FireflyIII\Models\TransactionType; use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use Illuminate\Support\Collection; - +use Log; /** * Class PopupReport. * @@ -38,6 +38,16 @@ use Illuminate\Support\Collection; */ class PopupReport implements PopupReportInterface { + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + /** * Collect the tranactions for one account and one budget. * diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.php index bd8c5af15a..42ed961e02 100644 --- a/app/Helpers/Report/ReportHelper.php +++ b/app/Helpers/Report/ReportHelper.php @@ -32,7 +32,7 @@ use FireflyIII\Models\Transaction; use FireflyIII\Repositories\Bill\BillRepositoryInterface; use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; use Illuminate\Support\Collection; - +use Log; /** * Class ReportHelper. * @@ -52,6 +52,12 @@ class ReportHelper implements ReportHelperInterface public function __construct(BudgetRepositoryInterface $budgetRepository) { $this->budgetRepository = $budgetRepository; + + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + + } /** diff --git a/app/Http/Controllers/Admin/LinkController.php b/app/Http/Controllers/Admin/LinkController.php index b16db6a4de..01b1814138 100644 --- a/app/Http/Controllers/Admin/LinkController.php +++ b/app/Http/Controllers/Admin/LinkController.php @@ -64,8 +64,8 @@ class LinkController extends Controller $subTitleIcon = 'fa-link'; // put previous url in session if not redirect from store (not "create another"). - if (true !== session('link_types.create.fromStore')) { - $this->rememberPreviousUri('link_types.create.uri'); + if (true !== session('link-types.create.fromStore')) { + $this->rememberPreviousUri('link-types.create.uri'); } return view('admin.link.create', compact('subTitle', 'subTitleIcon')); @@ -100,7 +100,7 @@ class LinkController extends Controller } } // put previous url in session - $this->rememberPreviousUri('link_types.delete.uri'); + $this->rememberPreviousUri('link-types.delete.uri'); return view('admin.link.delete', compact('linkType', 'subTitle', 'moveTo', 'count')); } @@ -123,7 +123,7 @@ class LinkController extends Controller $request->session()->flash('success', (string)trans('firefly.deleted_link_type', ['name' => $name])); app('preferences')->mark(); - return redirect($this->getPreviousUri('link_types.delete.uri')); + return redirect($this->getPreviousUri('link-types.delete.uri')); } /** @@ -145,10 +145,10 @@ class LinkController extends Controller $subTitleIcon = 'fa-link'; // put previous url in session if not redirect from store (not "return_to_edit"). - if (true !== session('link_types.edit.fromUpdate')) { - $this->rememberPreviousUri('link_types.edit.uri'); // @codeCoverageIgnore + if (true !== session('link-types.edit.fromUpdate')) { + $this->rememberPreviousUri('link-types.edit.uri'); // @codeCoverageIgnore } - $request->session()->forget('link_types.edit.fromUpdate'); + $request->session()->forget('link-types.edit.fromUpdate'); return view('admin.link.edit', compact('subTitle', 'subTitleIcon', 'linkType')); } @@ -207,10 +207,10 @@ class LinkController extends Controller ]; $linkType = $repository->store($data); $request->session()->flash('success', (string)trans('firefly.stored_new_link_type', ['name' => $linkType->name])); - $redirect = redirect($this->getPreviousUri('link_types.create.uri')); + $redirect = redirect($this->getPreviousUri('link-types.create.uri')); if (1 === (int)$request->get('create_another')) { // set value so create routine will not overwrite URL: - $request->session()->put('link_types.create.fromStore', true); + $request->session()->put('link-types.create.fromStore', true); $redirect = redirect(route('admin.links.create'))->withInput(); } @@ -245,10 +245,10 @@ class LinkController extends Controller $request->session()->flash('success', (string)trans('firefly.updated_link_type', ['name' => $linkType->name])); app('preferences')->mark(); - $redirect = redirect($this->getPreviousUri('link_types.edit.uri')); + $redirect = redirect($this->getPreviousUri('link-types.edit.uri')); if (1 === (int)$request->get('return_to_edit')) { // set value so edit routine will not overwrite URL: - $request->session()->put('link_types.edit.fromUpdate', true); + $request->session()->put('link-types.edit.fromUpdate', true); $redirect = redirect(route('admin.links.edit', [$linkType->id]))->withInput(['return_to_edit' => 1]); } diff --git a/app/Services/IP/IpifyOrg.php b/app/Services/IP/IpifyOrg.php index f5abb40d5e..8f1a7d7697 100644 --- a/app/Services/IP/IpifyOrg.php +++ b/app/Services/IP/IpifyOrg.php @@ -34,6 +34,16 @@ use RuntimeException; */ class IpifyOrg implements IPRetrievalInterface { + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + /** * Returns the user's IP address. * diff --git a/app/Services/Internal/Destroy/AccountDestroyService.php b/app/Services/Internal/Destroy/AccountDestroyService.php index daf3546323..cec7a802b3 100644 --- a/app/Services/Internal/Destroy/AccountDestroyService.php +++ b/app/Services/Internal/Destroy/AccountDestroyService.php @@ -37,6 +37,16 @@ use Log; */ class AccountDestroyService { + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + /** * @param Account $account * @param Account|null $moveTo diff --git a/app/Services/Internal/Destroy/BillDestroyService.php b/app/Services/Internal/Destroy/BillDestroyService.php index 061d7d21cd..c78bafb473 100644 --- a/app/Services/Internal/Destroy/BillDestroyService.php +++ b/app/Services/Internal/Destroy/BillDestroyService.php @@ -33,6 +33,16 @@ use Log; */ class BillDestroyService { + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + /** * @param Bill $bill */ diff --git a/app/Services/Internal/Destroy/CategoryDestroyService.php b/app/Services/Internal/Destroy/CategoryDestroyService.php index 2f1440a513..22a2fc8dd3 100644 --- a/app/Services/Internal/Destroy/CategoryDestroyService.php +++ b/app/Services/Internal/Destroy/CategoryDestroyService.php @@ -32,6 +32,16 @@ use Log; */ class CategoryDestroyService { + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + /** * @param Category $category */ diff --git a/app/Services/Internal/Destroy/CurrencyDestroyService.php b/app/Services/Internal/Destroy/CurrencyDestroyService.php index 04cf37b279..05869c4a54 100644 --- a/app/Services/Internal/Destroy/CurrencyDestroyService.php +++ b/app/Services/Internal/Destroy/CurrencyDestroyService.php @@ -32,6 +32,16 @@ use Log; */ class CurrencyDestroyService { + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + /** * @param TransactionCurrency $currency */ diff --git a/app/Services/Internal/Destroy/JournalDestroyService.php b/app/Services/Internal/Destroy/JournalDestroyService.php index 1adadb9e27..c00e86aed7 100644 --- a/app/Services/Internal/Destroy/JournalDestroyService.php +++ b/app/Services/Internal/Destroy/JournalDestroyService.php @@ -35,6 +35,16 @@ use Log; */ class JournalDestroyService { + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + /** * @param TransactionJournal $journal */ diff --git a/app/Services/Internal/Destroy/RecurrenceDestroyService.php b/app/Services/Internal/Destroy/RecurrenceDestroyService.php index 06ab42204b..a0af5df8f3 100644 --- a/app/Services/Internal/Destroy/RecurrenceDestroyService.php +++ b/app/Services/Internal/Destroy/RecurrenceDestroyService.php @@ -34,6 +34,16 @@ use Log; */ class RecurrenceDestroyService { + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + /** * Delete recurrence. * diff --git a/app/Services/Internal/File/EncryptService.php b/app/Services/Internal/File/EncryptService.php index 6b97fca04f..5380efcd83 100644 --- a/app/Services/Internal/File/EncryptService.php +++ b/app/Services/Internal/File/EncryptService.php @@ -33,6 +33,16 @@ use Log; */ class EncryptService { + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + /** * @param string $file * @param string $key diff --git a/app/Services/Internal/Update/AccountUpdateService.php b/app/Services/Internal/Update/AccountUpdateService.php index 59f8222cda..619d643129 100644 --- a/app/Services/Internal/Update/AccountUpdateService.php +++ b/app/Services/Internal/Update/AccountUpdateService.php @@ -25,6 +25,7 @@ namespace FireflyIII\Services\Internal\Update; use FireflyIII\Models\Account; use FireflyIII\Services\Internal\Support\AccountServiceTrait; +use Log; /** * Class AccountUpdateService @@ -32,7 +33,15 @@ use FireflyIII\Services\Internal\Support\AccountServiceTrait; class AccountUpdateService { use AccountServiceTrait; - + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } /** * Update account data. diff --git a/app/Services/Internal/Update/BillUpdateService.php b/app/Services/Internal/Update/BillUpdateService.php index 0450e6e90c..fa6d2d98b6 100644 --- a/app/Services/Internal/Update/BillUpdateService.php +++ b/app/Services/Internal/Update/BillUpdateService.php @@ -25,7 +25,7 @@ namespace FireflyIII\Services\Internal\Update; use FireflyIII\Models\Bill; use FireflyIII\Services\Internal\Support\BillServiceTrait; - +use Log; /** * @codeCoverageIgnore * Class BillUpdateService @@ -34,6 +34,16 @@ class BillUpdateService { use BillServiceTrait; + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + /** * @param Bill $bill * @param array $data diff --git a/app/Services/Internal/Update/CategoryUpdateService.php b/app/Services/Internal/Update/CategoryUpdateService.php index 677a71d4b8..0064a034c2 100644 --- a/app/Services/Internal/Update/CategoryUpdateService.php +++ b/app/Services/Internal/Update/CategoryUpdateService.php @@ -24,13 +24,23 @@ declare(strict_types=1); namespace FireflyIII\Services\Internal\Update; use FireflyIII\Models\Category; - +use Log; /** * Class CategoryUpdateService */ class CategoryUpdateService { + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + /** * @param Category $category * @param array $data diff --git a/app/Services/Internal/Update/CurrencyUpdateService.php b/app/Services/Internal/Update/CurrencyUpdateService.php index c5be7786ba..77c972faf9 100644 --- a/app/Services/Internal/Update/CurrencyUpdateService.php +++ b/app/Services/Internal/Update/CurrencyUpdateService.php @@ -24,12 +24,22 @@ declare(strict_types=1); namespace FireflyIII\Services\Internal\Update; use FireflyIII\Models\TransactionCurrency; - +use Log; /** * Class CurrencyUpdateService */ class CurrencyUpdateService { + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + /** * @param TransactionCurrency $currency * @param array $data diff --git a/app/Services/Internal/Update/JournalUpdateService.php b/app/Services/Internal/Update/JournalUpdateService.php index 99dae64026..483218200f 100644 --- a/app/Services/Internal/Update/JournalUpdateService.php +++ b/app/Services/Internal/Update/JournalUpdateService.php @@ -30,7 +30,6 @@ use FireflyIII\Models\TransactionType; use FireflyIII\Services\Internal\Support\JournalServiceTrait; use Illuminate\Support\Collection; use Log; - /** * Class to centralise code that updates a journal given the input by system. * @@ -39,6 +38,16 @@ use Log; class JournalUpdateService { use JournalServiceTrait; + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + /** * @param TransactionJournal $journal diff --git a/app/Services/Internal/Update/TransactionUpdateService.php b/app/Services/Internal/Update/TransactionUpdateService.php index 88a4b05f5a..49a0156cd2 100644 --- a/app/Services/Internal/Update/TransactionUpdateService.php +++ b/app/Services/Internal/Update/TransactionUpdateService.php @@ -26,7 +26,7 @@ namespace FireflyIII\Services\Internal\Update; use FireflyIII\Models\Transaction; use FireflyIII\Services\Internal\Support\TransactionServiceTrait; use FireflyIII\User; - +use Log; /** * Class TransactionUpdateService */ @@ -34,6 +34,16 @@ class TransactionUpdateService { use TransactionServiceTrait; + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + /** @var User */ private $user; diff --git a/app/Services/Password/PwndVerifierV2.php b/app/Services/Password/PwndVerifierV2.php index b78fdeb67b..156d2f8b17 100644 --- a/app/Services/Password/PwndVerifierV2.php +++ b/app/Services/Password/PwndVerifierV2.php @@ -33,6 +33,16 @@ use RuntimeException; */ class PwndVerifierV2 implements Verifier { + /** + * Constructor. + */ + public function __construct() + { + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } + /** * Verify the given password against (some) service. * diff --git a/app/Support/Search/Search.php b/app/Support/Search/Search.php index f456c4be8a..00c484866c 100644 --- a/app/Support/Search/Search.php +++ b/app/Support/Search/Search.php @@ -55,6 +55,11 @@ class Search implements SearchInterface { $this->modifiers = new Collection; $this->validModifiers = (array)config('firefly.search_modifiers'); + + if ('testing' === env('APP_ENV')) { + Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this))); + } + } /** diff --git a/tests/Feature/Controllers/ExportControllerTest.php b/tests/Feature/Controllers/ExportControllerTest.php index 862fa95e6c..f7a9928cf5 100644 --- a/tests/Feature/Controllers/ExportControllerTest.php +++ b/tests/Feature/Controllers/ExportControllerTest.php @@ -89,6 +89,7 @@ class ExportControllerTest extends TestCase $userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false); $journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal); + $repository->shouldReceive('exists')->andReturn(false); $this->be($this->user()); $response = $this->get(route('export.download', ['testExport']));