mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Code cleanup and tests.
This commit is contained in:
parent
8bb7d5de3f
commit
f85ab74e2b
@ -27,11 +27,10 @@ use Route;
|
|||||||
*/
|
*/
|
||||||
class Help implements HelpInterface
|
class Help implements HelpInterface
|
||||||
{
|
{
|
||||||
|
const CACHEKEY = 'help_%s_%s';
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36';
|
protected $userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36';
|
||||||
|
|
||||||
const CACHEKEY = 'help_%s_%s';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $route
|
* @param string $route
|
||||||
* @param string $language
|
* @param string $language
|
||||||
|
@ -145,7 +145,7 @@ class HomeController extends Controller
|
|||||||
public function routes()
|
public function routes()
|
||||||
{
|
{
|
||||||
$set = RouteFacade::getRoutes();
|
$set = RouteFacade::getRoutes();
|
||||||
$ignore = ['chart.','javascript.','json.','report-data.','popup.','debugbar.'];
|
$ignore = ['chart.', 'javascript.', 'json.', 'report-data.', 'popup.', 'debugbar.'];
|
||||||
/** @var Route $route */
|
/** @var Route $route */
|
||||||
foreach ($set as $route) {
|
foreach ($set as $route) {
|
||||||
$name = $route->getName();
|
$name = $route->getName();
|
||||||
@ -157,7 +157,7 @@ class HomeController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$found) {
|
if (!$found) {
|
||||||
echo 'touch '.$route->getName() . '.md;';
|
echo 'touch ' . $route->getName() . '.md;';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ class PiggyBankController extends Controller
|
|||||||
/** @var Carbon $date */
|
/** @var Carbon $date */
|
||||||
$date = session('end', Carbon::now()->endOfMonth());
|
$date = session('end', Carbon::now()->endOfMonth());
|
||||||
$leftOnAccount = $piggyBank->leftOnAccount($date);
|
$leftOnAccount = $piggyBank->leftOnAccount($date);
|
||||||
$savedSoFar = $piggyBank->currentRelevantRep()->currentamount?? '0';
|
$savedSoFar = $piggyBank->currentRelevantRep()->currentamount ?? '0';
|
||||||
$leftToSave = bcsub($piggyBank->targetamount, $savedSoFar);
|
$leftToSave = bcsub($piggyBank->targetamount, $savedSoFar);
|
||||||
$maxAmount = min($leftOnAccount, $leftToSave);
|
$maxAmount = min($leftOnAccount, $leftToSave);
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use DaveJamesMiller\Breadcrumbs\Generator as BreadCrumbGenerator;
|
use DaveJamesMiller\Breadcrumbs\Generator as BreadCrumbGenerator;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
|
@ -65,19 +65,6 @@ class ImportJournal
|
|||||||
/** @var User */
|
/** @var User */
|
||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getDescription(): string
|
|
||||||
{
|
|
||||||
if ($this->description === '') {
|
|
||||||
return '(no description)';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->description;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ImportEntry constructor.
|
* ImportEntry constructor.
|
||||||
*/
|
*/
|
||||||
@ -157,6 +144,18 @@ class ImportJournal
|
|||||||
return $date;
|
return $date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
if ($this->description === '') {
|
||||||
|
return '(no description)';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->description;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $hash
|
* @param string $hash
|
||||||
*/
|
*/
|
||||||
|
@ -499,6 +499,7 @@ class ImportStorage
|
|||||||
['transaction_journals.id', 'transaction_journals.encrypted', 'transaction_journals.description',
|
['transaction_journals.id', 'transaction_journals.encrypted', 'transaction_journals.description',
|
||||||
'source_accounts.name as source_name', 'destination_accounts.name as destination_name']
|
'source_accounts.name as source_name', 'destination_accounts.name as destination_name']
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->filterTransferSet($set, $importJournal);
|
return $this->filterTransferSet($set, $importJournal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,7 +311,7 @@ class Amount
|
|||||||
$coloured = false;
|
$coloured = false;
|
||||||
$format = '<span class="text-info">%s</span>';
|
$format = '<span class="text-info">%s</span>';
|
||||||
}
|
}
|
||||||
if($transaction->transaction_type_type === TransactionType::OPENING_BALANCE) {
|
if ($transaction->transaction_type_type === TransactionType::OPENING_BALANCE) {
|
||||||
$amount = strval($transaction->transaction_amount);
|
$amount = strval($transaction->transaction_amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,21 +249,6 @@ class Steam
|
|||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @param $value
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function tryDecrypt($value)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$value = Crypt::decrypt($value);
|
|
||||||
} catch (DecryptException $e) {
|
|
||||||
// do not care.
|
|
||||||
}
|
|
||||||
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $accounts
|
* @param array $accounts
|
||||||
@ -361,4 +346,20 @@ class Steam
|
|||||||
return $amount;
|
return $amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $value
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function tryDecrypt($value)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$value = Crypt::decrypt($value);
|
||||||
|
} catch (DecryptException $e) {
|
||||||
|
// do not care.
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -41,10 +41,6 @@ class TwoFactorControllerTest extends TestCase
|
|||||||
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret', null])->andReturn($secretPreference)->once();
|
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret', null])->andReturn($secretPreference)->once();
|
||||||
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret'])->andReturn($secretPreference)->once();
|
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret'])->andReturn($secretPreference)->once();
|
||||||
|
|
||||||
$falsePref = new Preference;
|
|
||||||
$falsePref->data = false;
|
|
||||||
Preferences::shouldReceive('get')->withArgs(['shown_demo_two-factor.index', false])->andReturn($falsePref)->once();
|
|
||||||
|
|
||||||
$response = $this->get(route('two-factor.index'));
|
$response = $this->get(route('two-factor.index'));
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
}
|
}
|
||||||
@ -61,7 +57,6 @@ class TwoFactorControllerTest extends TestCase
|
|||||||
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthEnabled', false])->andReturn($falsePreference)->twice();
|
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthEnabled', false])->andReturn($falsePreference)->twice();
|
||||||
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret', null])->andReturn(null)->once();
|
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret', null])->andReturn(null)->once();
|
||||||
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret'])->andReturn(null)->once();
|
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret'])->andReturn(null)->once();
|
||||||
Preferences::shouldReceive('get')->withArgs(['shown_demo_two-factor.index', false])->andReturn($falsePreference)->once();
|
|
||||||
|
|
||||||
$response = $this->get(route('two-factor.index'));
|
$response = $this->get(route('two-factor.index'));
|
||||||
$response->assertStatus(302);
|
$response->assertStatus(302);
|
||||||
@ -84,10 +79,6 @@ class TwoFactorControllerTest extends TestCase
|
|||||||
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret', null])->andReturn($secretPreference)->once();
|
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret', null])->andReturn($secretPreference)->once();
|
||||||
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret'])->andReturn($secretPreference)->once();
|
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret'])->andReturn($secretPreference)->once();
|
||||||
|
|
||||||
$falsePref = new Preference;
|
|
||||||
$falsePref->data = false;
|
|
||||||
Preferences::shouldReceive('get')->withArgs(['shown_demo_two-factor.index', false])->andReturn($falsePref)->once();
|
|
||||||
|
|
||||||
$response = $this->get(route('two-factor.index'));
|
$response = $this->get(route('two-factor.index'));
|
||||||
$response->assertStatus(500);
|
$response->assertStatus(500);
|
||||||
}
|
}
|
||||||
@ -107,10 +98,6 @@ class TwoFactorControllerTest extends TestCase
|
|||||||
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret', null])->andReturn($secretPreference);
|
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret', null])->andReturn($secretPreference);
|
||||||
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret'])->andReturn($secretPreference);
|
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret'])->andReturn($secretPreference);
|
||||||
|
|
||||||
$falsePref = new Preference;
|
|
||||||
$falsePref->data = false;
|
|
||||||
Preferences::shouldReceive('get')->withArgs(['shown_demo_two-factor.lost', false])->andReturn($falsePref)->once();
|
|
||||||
|
|
||||||
$response = $this->get(route('two-factor.lost'));
|
$response = $this->get(route('two-factor.lost'));
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
}
|
}
|
||||||
|
@ -56,12 +56,9 @@ class HelpControllerTest extends TestCase
|
|||||||
$help->shouldReceive('getFromGithub')->withArgs(['index', 'nl_NL'])->andReturn('')->once();
|
$help->shouldReceive('getFromGithub')->withArgs(['index', 'nl_NL'])->andReturn('')->once();
|
||||||
|
|
||||||
// is US in cache?
|
// is US in cache?
|
||||||
$help->shouldReceive('inCache')->withArgs(['index', 'en_US'])->andReturn(true)->twice();
|
$help->shouldReceive('inCache')->withArgs(['index', 'en_US'])->andReturn(true)->once();
|
||||||
$help->shouldReceive('getFromCache')->withArgs(['index', 'en_US'])->andReturn('US from cache.')->once();
|
$help->shouldReceive('getFromCache')->withArgs(['index', 'en_US'])->andReturn('US from cache.')->once();
|
||||||
|
|
||||||
// put US in cache:
|
|
||||||
$help->shouldReceive('putInCache')->once();
|
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$response = $this->get(route('help.show', ['index']));
|
$response = $this->get(route('help.show', ['index']));
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
@ -87,12 +84,9 @@ class HelpControllerTest extends TestCase
|
|||||||
$help->shouldReceive('getFromGithub')->withArgs(['index', 'nl_NL'])->andReturn('')->once();
|
$help->shouldReceive('getFromGithub')->withArgs(['index', 'nl_NL'])->andReturn('')->once();
|
||||||
|
|
||||||
// is US in cache?
|
// is US in cache?
|
||||||
$help->shouldReceive('inCache')->withArgs(['index', 'en_US'])->andReturn(false)->twice();
|
$help->shouldReceive('inCache')->withArgs(['index', 'en_US'])->andReturn(false)->once();
|
||||||
$help->shouldReceive('getFromGithub')->withArgs(['index', 'en_US'])->andReturn('')->once();
|
$help->shouldReceive('getFromGithub')->withArgs(['index', 'en_US'])->andReturn('')->once();
|
||||||
|
|
||||||
// put US in cache:
|
|
||||||
$help->shouldReceive('putInCache')->once();
|
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$response = $this->get(route('help.show', ['index']));
|
$response = $this->get(route('help.show', ['index']));
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
|
Loading…
Reference in New Issue
Block a user