Update some tests.

This commit is contained in:
James Cole
2020-01-05 19:29:28 +01:00
parent 465947dddf
commit 39d61feede
26 changed files with 211 additions and 140 deletions

View File

@@ -49,13 +49,6 @@ class VersionCheckEventHandler
public function checkForUpdates(RequestedVersionCheckStatus $event): void
{
Log::debug('Now in checkForUpdates()');
// in Sandstorm, cannot check for updates:
$sandstorm = 1 === (int)getenv('SANDSTORM');
if (true === $sandstorm) {
Log::debug('This is Sandstorm instance, done.');
return;
}
// should not check for updates:
$permission = app('fireflyconfig')->get('permission_update_check', -1);

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Http\Requests\BillFormRequest;
@@ -40,6 +41,7 @@ use League\Fractal\Manager;
use League\Fractal\Resource\Item;
use League\Fractal\Serializer\DataArraySerializer;
use Symfony\Component\HttpFoundation\ParameterBag;
use Log;
/**
* Class BillController.
@@ -366,8 +368,10 @@ class BillController extends Controller
{
$billData = $request->getBillData();
$billData['active'] = true;
$bill = $this->billRepository->store($billData);
if (null === $bill) {
try {
$bill = $this->billRepository->store($billData);
} catch (FireflyException $e) {
Log::error($e->getMessage());
$request->session()->flash('error', (string)trans('firefly.bill_store_error'));
return redirect(route('bills.create'))->withInput();

View File

@@ -251,7 +251,7 @@ class BudgetController extends Controller
foreach ($result as $combinedId => $info) {
$parts = explode('-', $combinedId);
$assetId = (int)$parts[0];
$title = sprintf('%s (%s)', $names[$assetId], $info['currency_name']);
$title = sprintf('%s (%s)', $names[$assetId] ?? '(empty)', $info['currency_name']);
$chartData[$title]
= [
'amount' => $info['amount'],
@@ -315,7 +315,7 @@ class BudgetController extends Controller
foreach ($result as $combinedId => $info) {
$parts = explode('-', $combinedId);
$categoryId = (int)$parts[0];
$title = sprintf('%s (%s)', $names[$categoryId], $info['currency_name']);
$title = sprintf('%s (%s)', $names[$categoryId] ?? '(empty)', $info['currency_name']);
$chartData[$title] = [
'amount' => $info['amount'],
'currency_symbol' => $info['currency_symbol'],

View File

@@ -359,7 +359,14 @@ class CurrencyController extends Controller
}
$data['enabled'] = true;
$currency = $this->repository->store($data);
try {
$currency = $this->repository->store($data);
} catch (FireflyException $e) {
Log::error($e->getMessage());
Log::channel('audit')->info('Could not store (POST) currency without admin rights.', $data);
$request->session()->flash('error', (string)trans('firefly.could_not_store_currency'));
$currency = null;
}
$redirect = redirect($this->getPreviousUri('currencies.create.uri'));
if (null !== $currency) {
@@ -373,10 +380,6 @@ class CurrencyController extends Controller
// @codeCoverageIgnoreEnd
}
}
if (null === $currency) {
Log::channel('audit')->info('Could not store (POST) currency without admin rights.', $data);
$request->session()->flash('error', (string)trans('firefly.could_not_store_currency'));
}
return $redirect;
}

View File

@@ -95,12 +95,12 @@ class Note extends Model
}
/**
* @param string $value
* @param string|null $value
*
* @return string
* @return string|null
*/
public function getTextAttribute(string $value): string
public function getTextAttribute(?string $value): ?string
{
return htmlspecialchars_decode($value, ENT_QUOTES);
return null === $value ? null : htmlspecialchars_decode($value, ENT_QUOTES);
}
}

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\Currency;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\CurrencyExchangeRate;
use FireflyIII\Models\Preference;
use FireflyIII\Models\TransactionCurrency;
@@ -233,7 +234,7 @@ interface CurrencyRepositoryInterface
/**
* @param array $data
*
* @throws FireflyException
* @return TransactionCurrency
*/
public function store(array $data): TransactionCurrency;

View File

@@ -25,7 +25,7 @@ namespace FireflyIII\Services\Github\Request;
/**
* Interface GithubRequest
*
* @deprecated
*/
interface GithubRequest
{

View File

@@ -34,7 +34,9 @@ use SimpleXMLElement;
/**
* Class UpdateRequest
*
* @codeCoverageIgnore
* @deprecated
*/
class UpdateRequest implements GithubRequest
{