Repositories will now warn if used in test environment.

This commit is contained in:
James Cole
2018-09-03 08:41:03 +02:00
parent fb61229bf3
commit bb9f763729
24 changed files with 294 additions and 33 deletions

View File

@@ -46,6 +46,16 @@ class AccountRepository implements AccountRepositoryInterface
/** @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)));
}
}
/**
* @param array $types
*

View File

@@ -38,6 +38,16 @@ class AccountTasker implements AccountTaskerInterface
/** @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)));
}
}
/**
* @param Collection $accounts
* @param Carbon $start

View File

@@ -45,6 +45,16 @@ class AttachmentRepository implements AttachmentRepositoryInterface
/** @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)));
}
}
/**
* @param Attachment $attachment
*

View File

@@ -48,6 +48,16 @@ class BillRepository implements BillRepositoryInterface
/** @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)));
}
}
/**
* @param Bill $bill
*

View File

@@ -54,6 +54,16 @@ class BudgetRepository implements BudgetRepositoryInterface
/** @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)));
}
}
/**
* A method that returns the amount of money budgeted per day for this budget,
* on average.

View File

@@ -47,6 +47,16 @@ class CategoryRepository implements CategoryRepositoryInterface
/** @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)));
}
}
/**
* @param Category $category
*

View File

@@ -43,10 +43,13 @@ class CurrencyRepository implements CurrencyRepositoryInterface
private $user;
/**
* CurrencyRepository constructor.
* Constructor.
*/
public function __construct()
{
if ('testing' === env('APP_ENV')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
}
}
/**

View File

@@ -39,6 +39,16 @@ class ExportJobRepository implements ExportJobRepositoryInterface
/** @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)));
}
}
/**
* @param ExportJob $job
* @param string $status

View File

@@ -53,6 +53,10 @@ class ImportJobRepository implements ImportJobRepositoryInterface
{
$this->maxUploadSize = (int)config('firefly.maxUploadSize');
$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)));
}
}
/**
@@ -380,7 +384,6 @@ class ImportJobRepository implements ImportJobRepositoryInterface
}
/**
* @codeCoverageIgnore
*

View File

@@ -54,6 +54,16 @@ class JournalRepository implements JournalRepositoryInterface
/** @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)));
}
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param TransactionJournal $journal

View File

@@ -40,6 +40,16 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
/** @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)));
}
}
/**
* @param LinkType $linkType
*

View File

@@ -44,6 +44,16 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
/** @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)));
}
}
/**
* @param PiggyBank $piggyBank
* @param string $amount

View File

@@ -56,6 +56,16 @@ class RecurringRepository implements RecurringRepositoryInterface
/** @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)));
}
}
/**
* Destroy a recurring transaction.
*

View File

@@ -29,6 +29,7 @@ use FireflyIII\Models\RuleGroup;
use FireflyIII\Models\RuleTrigger;
use FireflyIII\User;
use Illuminate\Support\Collection;
use Log;
/**
* Class RuleRepository.
@@ -40,6 +41,16 @@ class RuleRepository implements RuleRepositoryInterface
/** @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)));
}
}
/**
* @return int
*/

View File

@@ -27,6 +27,7 @@ use FireflyIII\Models\RuleGroup;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Collection;
use Log;
/**
* Class RuleGroupRepository.
@@ -36,6 +37,16 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
/** @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)));
}
}
/**
* @return int
*/

View File

@@ -43,6 +43,16 @@ class TagRepository implements TagRepositoryInterface
/** @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)));
}
}
/**
* @return int
*/

View File

@@ -36,6 +36,16 @@ use Log;
*/
class UserRepository implements UserRepositoryInterface
{
/**
* Constructor.
*/
public function __construct()
{
if ('testing' === env('APP_ENV')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
}
}
/**
* @return Collection
*/
@@ -55,6 +65,7 @@ class UserRepository implements UserRepositoryInterface
$roleObject = Role::where('name', $role)->first();
if (null === $roleObject) {
Log::error(sprintf('Could not find role "%s" in attachRole()', $role));
return false;
}