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
|
||||
{
|
||||
const CACHEKEY = 'help_%s_%s';
|
||||
/** @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';
|
||||
|
||||
const CACHEKEY = 'help_%s_%s';
|
||||
|
||||
/**
|
||||
* @param string $route
|
||||
* @param string $language
|
||||
|
@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Carbon\Carbon;
|
||||
use DaveJamesMiller\Breadcrumbs\Generator as BreadCrumbGenerator;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
|
@ -65,19 +65,6 @@ class ImportJournal
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription(): string
|
||||
{
|
||||
if ($this->description === '') {
|
||||
return '(no description)';
|
||||
}
|
||||
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ImportEntry constructor.
|
||||
*/
|
||||
@ -157,6 +144,18 @@ class ImportJournal
|
||||
return $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription(): string
|
||||
{
|
||||
if ($this->description === '') {
|
||||
return '(no description)';
|
||||
}
|
||||
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $hash
|
||||
*/
|
||||
|
@ -499,6 +499,7 @@ class ImportStorage
|
||||
['transaction_journals.id', 'transaction_journals.encrypted', 'transaction_journals.description',
|
||||
'source_accounts.name as source_name', 'destination_accounts.name as destination_name']
|
||||
);
|
||||
|
||||
return $this->filterTransferSet($set, $importJournal);
|
||||
}
|
||||
|
||||
|
@ -249,21 +249,6 @@ class Steam
|
||||
|
||||
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
|
||||
@ -361,4 +346,20 @@ class Steam
|
||||
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'])->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->assertStatus(200);
|
||||
}
|
||||
@ -61,7 +57,6 @@ class TwoFactorControllerTest extends TestCase
|
||||
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthEnabled', false])->andReturn($falsePreference)->twice();
|
||||
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret', null])->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->assertStatus(302);
|
||||
@ -84,10 +79,6 @@ class TwoFactorControllerTest extends TestCase
|
||||
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret', null])->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->assertStatus(500);
|
||||
}
|
||||
@ -107,10 +98,6 @@ class TwoFactorControllerTest extends TestCase
|
||||
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret', null])->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->assertStatus(200);
|
||||
}
|
||||
|
@ -56,12 +56,9 @@ class HelpControllerTest extends TestCase
|
||||
$help->shouldReceive('getFromGithub')->withArgs(['index', 'nl_NL'])->andReturn('')->once();
|
||||
|
||||
// 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();
|
||||
|
||||
// put US in cache:
|
||||
$help->shouldReceive('putInCache')->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('help.show', ['index']));
|
||||
$response->assertStatus(200);
|
||||
@ -87,12 +84,9 @@ class HelpControllerTest extends TestCase
|
||||
$help->shouldReceive('getFromGithub')->withArgs(['index', 'nl_NL'])->andReturn('')->once();
|
||||
|
||||
// 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();
|
||||
|
||||
// put US in cache:
|
||||
$help->shouldReceive('putInCache')->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('help.show', ['index']));
|
||||
$response->assertStatus(200);
|
||||
|
Loading…
Reference in New Issue
Block a user