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

@@ -202,6 +202,9 @@ class Amount
*/
public function getAllCurrencies(): Collection
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__));
}
return TransactionCurrency::orderBy('code', 'ASC')->get();
}
@@ -210,6 +213,9 @@ class Amount
*/
public function getCurrencies(): Collection
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__));
}
return TransactionCurrency::where('enabled', true)->orderBy('code', 'ASC')->get();
}
@@ -218,6 +224,9 @@ class Amount
*/
public function getCurrencyCode(): string
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__));
}
$cache = new CacheProperties;
$cache->addProperty('getCurrencyCode');
if ($cache->has()) {
@@ -241,6 +250,9 @@ class Amount
*/
public function getCurrencySymbol(): string
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__));
}
$cache = new CacheProperties;
$cache->addProperty('getCurrencySymbol');
if ($cache->has()) {
@@ -261,6 +273,9 @@ class Amount
*/
public function getDefaultCurrency(): TransactionCurrency
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__));
}
/** @var User $user */
$user = auth()->user();
@@ -276,6 +291,9 @@ class Amount
*/
public function getDefaultCurrencyByUser(User $user): TransactionCurrency
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__));
}
$cache = new CacheProperties;
$cache->addProperty('getDefaultCurrency');
$cache->addProperty($user->id);