Warn about expensive code in test environment.

This commit is contained in:
James Cole
2019-06-22 10:25:57 +02:00
parent 0f70cc5780
commit 2710a30a7c
15 changed files with 328 additions and 127 deletions

View File

@@ -28,6 +28,7 @@ use FireflyIII\Models\Account;
use FireflyIII\Models\Transaction;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
use stdClass;
/**
@@ -44,6 +45,9 @@ class Steam
*/
public function balance(Account $account, Carbon $date): string
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__));
}
// abuse chart properties:
$cache = new CacheProperties;
$cache->addProperty($account->id);
@@ -93,6 +97,9 @@ class Steam
*/
public function balanceIgnoreVirtual(Account $account, Carbon $date): string
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__));
}
// abuse chart properties:
$cache = new CacheProperties;
$cache->addProperty($account->id);
@@ -139,6 +146,9 @@ class Steam
*/
public function balanceInRange(Account $account, Carbon $start, Carbon $end): array
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__));
}
// abuse chart properties:
$cache = new CacheProperties;
$cache->addProperty($account->id);
@@ -225,7 +235,9 @@ class Steam
*/
public function balancePerCurrency(Account $account, Carbon $date): array
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__));
}
// abuse chart properties:
$cache = new CacheProperties;
$cache->addProperty($account->id);
@@ -259,6 +271,9 @@ class Steam
*/
public function balancesByAccounts(Collection $accounts, Carbon $date): array
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__));
}
$ids = $accounts->pluck('id')->toArray();
// cache this property.
$cache = new CacheProperties;
@@ -291,6 +306,9 @@ class Steam
*/
public function balancesPerCurrencyByAccounts(Collection $accounts, Carbon $date): array
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__));
}
$ids = $accounts->pluck('id')->toArray();
// cache this property.
$cache = new CacheProperties;
@@ -383,6 +401,9 @@ class Steam
*/
public function getLastActivities(array $accounts): array
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__));
}
$list = [];
$set = auth()->user()->transactions()