mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
Improve test coverage.
This commit is contained in:
@@ -132,6 +132,7 @@ class AccountFactory
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $accountName
|
||||
* @param string $accountType
|
||||
*
|
||||
|
@@ -65,7 +65,7 @@ class AccountMetaFactory
|
||||
// if $data has field and $entry is null, create new one:
|
||||
if (null === $entry) {
|
||||
Log::debug(sprintf('Created meta-field "%s":"%s" for account #%d ("%s") ', $field, $value, $account->id, $account->name));
|
||||
$this->create(['account_id' => $account->id, 'name' => $field, 'data' => $value]);
|
||||
return $this->create(['account_id' => $account->id, 'name' => $field, 'data' => $value]);
|
||||
}
|
||||
|
||||
// if $data has field and $entry is not null, update $entry:
|
||||
@@ -75,12 +75,13 @@ class AccountMetaFactory
|
||||
Log::debug(sprintf('Updated meta-field "%s":"%s" for #%d ("%s") ', $field, $value, $account->id, $account->name));
|
||||
}
|
||||
}
|
||||
if ('' === $value && null !== $entry && isset($data[$field])) {
|
||||
if ('' === $value && null !== $entry) {
|
||||
try {
|
||||
$entry->delete();
|
||||
} catch (Exception $e) {
|
||||
Log::debug(sprintf('Could not delete entry: %s', $e->getMessage()));
|
||||
} catch (Exception $e) { // @codeCoverageIgnore
|
||||
Log::debug(sprintf('Could not delete entry: %s', $e->getMessage())); // @codeCoverageIgnore
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return $entry;
|
||||
|
@@ -59,10 +59,10 @@ class TransactionFactory
|
||||
$currencyId = isset($data['currency']) ? $data['currency']->id : $currencyId;
|
||||
if ('' === $data['amount']) {
|
||||
Log::error('Empty string in data.', $data);
|
||||
throw new FireflyException('Amount is an empty string, which Firefly III cannot handle. Apologies.'); // @codeCoverageIgnore
|
||||
throw new FireflyException('Amount is an empty string, which Firefly III cannot handle. Apologies.');
|
||||
}
|
||||
if (null === $currencyId) {
|
||||
throw new FireflyException('Cannot store transaction without currency information.'); // @codeCoverageIgnore
|
||||
throw new FireflyException('Cannot store transaction without currency information.');
|
||||
}
|
||||
$data['foreign_amount'] = '' === (string)$data['foreign_amount'] ? null : $data['foreign_amount'];
|
||||
Log::debug(sprintf('Create transaction for account #%d ("%s") with amount %s', $data['account']->id, $data['account']->name, $data['amount']));
|
||||
@@ -154,7 +154,7 @@ class TransactionFactory
|
||||
]
|
||||
);
|
||||
if (null === $source || null === $dest) {
|
||||
throw new FireflyException('Could not create transactions.');
|
||||
throw new FireflyException('Could not create transactions.'); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
// set foreign currency
|
||||
|
@@ -28,7 +28,6 @@ namespace FireflyIII\Factory;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* Class TransactionTypeFactory
|
||||
*/
|
||||
class TransactionTypeFactory
|
||||
|
Reference in New Issue
Block a user