Warn when classes are used in testing environment; this means tests aren't efficient.

This commit is contained in:
James Cole 2018-09-06 12:29:32 +02:00
parent 013c8707ac
commit 03956af88a
44 changed files with 410 additions and 22 deletions

View File

@ -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;

View File

@ -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
*

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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 */

View File

@ -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 */

View File

@ -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
*

View File

@ -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 */

View File

@ -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;

View File

@ -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
*

View File

@ -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
*

View File

@ -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.
*

View File

@ -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.
*

View File

@ -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)));
}
}
/**

View File

@ -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 = [];

View File

@ -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)));
}
}
/**

View File

@ -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.
*

View File

@ -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)));
}
}
/**

View File

@ -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)));
}
}
/**

View File

@ -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:
*

View File

@ -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.
*

View File

@ -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)));
}
}
/**

View File

@ -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]);
}

View File

@ -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.
*

View File

@ -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

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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.
*

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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.
*

View File

@ -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)));
}
}
/**

View File

@ -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']));