mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-05-04 05:06:37 +00:00
Various code cleanup.
This commit is contained in:
@@ -136,6 +136,30 @@ class UpdateControllerTest extends TestCase
|
||||
$response->assertSee('the latest available release');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Admin\UpdateController::updateCheck
|
||||
*/
|
||||
public function testUpdateCheckError()
|
||||
{
|
||||
$falseConfig = new Configuration;
|
||||
$falseConfig->data = false;
|
||||
FireflyConfig::shouldReceive('get')->withArgs(['is_demo_site', false])->once()->andReturn($falseConfig);
|
||||
|
||||
$version = config('firefly.version') . '-alpha';
|
||||
$releases = [
|
||||
new Release(['id' => 'x', 'title' => $version, 'content' => '', 'updated' => new Carbon]),
|
||||
];
|
||||
$updater = $this->mock(UpdateRequest::class);
|
||||
$updater->shouldReceive('call')->andThrow(FireflyException::class, 'Something broke.');
|
||||
$updater->shouldReceive('getReleases')->andReturn($releases);
|
||||
|
||||
// expect a new release (because of .1)
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('admin.update-check.manual'));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('An error occurred while checking');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Admin\UpdateController::updateCheck
|
||||
*/
|
||||
@@ -161,28 +185,4 @@ class UpdateControllerTest extends TestCase
|
||||
$response->assertSee($version);
|
||||
$response->assertSee('which is newer than the');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Admin\UpdateController::updateCheck
|
||||
*/
|
||||
public function testUpdateCheckError()
|
||||
{
|
||||
$falseConfig = new Configuration;
|
||||
$falseConfig->data = false;
|
||||
FireflyConfig::shouldReceive('get')->withArgs(['is_demo_site', false])->once()->andReturn($falseConfig);
|
||||
|
||||
$version = config('firefly.version') . '-alpha';
|
||||
$releases = [
|
||||
new Release(['id' => 'x', 'title' => $version, 'content' => '', 'updated' => new Carbon]),
|
||||
];
|
||||
$updater = $this->mock(UpdateRequest::class);
|
||||
$updater->shouldReceive('call')->andThrow(FireflyException::class, 'Something broke.');
|
||||
$updater->shouldReceive('getReleases')->andReturn($releases);
|
||||
|
||||
// expect a new release (because of .1)
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('admin.update-check.manual'));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('An error occurred while checking');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ class TwoFactorControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostIndex()
|
||||
{
|
||||
$data = ['code' => '123456'];
|
||||
$data = ['code' => '123456'];
|
||||
Google2FA::shouldReceive('verifyKey')->andReturn(true)->once();
|
||||
$this->session(['remember_login' => true]);
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ class StatusControllerTest extends TestCase
|
||||
*/
|
||||
public function testStatusFinished()
|
||||
{
|
||||
$tag = $this->user()->tags()->first();
|
||||
$tag = $this->user()->tags()->first();
|
||||
$repository = $this->mock(TagRepositoryInterface::class);
|
||||
$repository->shouldReceive('find')->andReturn($tag);
|
||||
$this->be($this->user());
|
||||
|
||||
@@ -27,10 +27,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Google2FA;
|
||||
use Illuminate\Support\Collection;
|
||||
use Preferences;
|
||||
use Tests\TestCase;
|
||||
use Google2FA;
|
||||
|
||||
/**
|
||||
* Class PreferencesControllerTest
|
||||
|
||||
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Controllers\Transaction;
|
||||
|
||||
use FireflyIII\Models\LinkType;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionJournalLink;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
@@ -64,6 +63,31 @@ class LinkControllerTest extends TestCase
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\LinkController::store
|
||||
*/
|
||||
public function testStore()
|
||||
{
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$data = [
|
||||
'link_other' => 8,
|
||||
'link_type' => '1_inward',
|
||||
];
|
||||
|
||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('find')->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('findLink')->andReturn(false);
|
||||
$repository->shouldReceive('storeLink')->andReturn(new TransactionJournalLink);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('transactions.link.store', [1]), $data);
|
||||
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
$response->assertRedirect(route('transactions.show', [1]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\LinkController::store
|
||||
*/
|
||||
@@ -88,32 +112,6 @@ class LinkControllerTest extends TestCase
|
||||
$response->assertRedirect(route('transactions.show', [1]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\LinkController::store
|
||||
*/
|
||||
public function testStore()
|
||||
{
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$data = [
|
||||
'link_other' => 8,
|
||||
'link_type' => '1_inward',
|
||||
];
|
||||
|
||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('find')->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('findLink')->andReturn(false);
|
||||
$repository->shouldReceive('storeLink')->andReturn(new TransactionJournalLink);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('transactions.link.store', [1]), $data);
|
||||
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
$response->assertRedirect(route('transactions.show', [1]));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\LinkController::store
|
||||
*/
|
||||
@@ -136,7 +134,7 @@ class LinkControllerTest extends TestCase
|
||||
*/
|
||||
public function testSwitchLink()
|
||||
{
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$repository->shouldReceive('switchLink')->andReturn(false);
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.link.switch', [1]));
|
||||
|
||||
@@ -75,7 +75,7 @@ class SingleControllerTest extends TestCase
|
||||
*/
|
||||
public function testCreate()
|
||||
{
|
||||
$accounts = $this->user()->accounts()->where('account_type_id',3)->get();
|
||||
$accounts = $this->user()->accounts()->where('account_type_id', 3)->get();
|
||||
Steam::shouldReceive('phpBytes')->andReturn(2048);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('getActiveAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn($accounts);
|
||||
@@ -207,10 +207,10 @@ class SingleControllerTest extends TestCase
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::edit
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::groupedAccountList
|
||||
*/
|
||||
public function testEditRedirect()
|
||||
public function testEditReconcile()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$withdrawal = TransactionJournal::where('transaction_type_id', 1)
|
||||
$withdrawal = TransactionJournal::where('transaction_type_id', 5)
|
||||
->whereNull('transaction_journals.deleted_at')
|
||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->groupBy('transaction_journals.id')
|
||||
@@ -224,10 +224,10 @@ class SingleControllerTest extends TestCase
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::edit
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::groupedAccountList
|
||||
*/
|
||||
public function testEditReconcile()
|
||||
public function testEditRedirect()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$withdrawal = TransactionJournal::where('transaction_type_id', 5)
|
||||
$withdrawal = TransactionJournal::where('transaction_type_id', 1)
|
||||
->whereNull('transaction_journals.deleted_at')
|
||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->groupBy('transaction_journals.id')
|
||||
|
||||
Reference in New Issue
Block a user