mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Expand tests, do code cleanup.
This commit is contained in:
@@ -24,6 +24,11 @@ namespace Tests;
|
||||
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
|
||||
/**
|
||||
* Trait CreatesApplication
|
||||
*
|
||||
* @package Tests
|
||||
*/
|
||||
trait CreatesApplication
|
||||
{
|
||||
/**
|
||||
|
@@ -57,6 +57,8 @@ class HelpControllerTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\HelpController::show
|
||||
* @covers \FireflyIII\Http\Controllers\HelpController::getHelpText
|
||||
* @throws \Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testShowBackupFromCache()
|
||||
{
|
||||
@@ -86,6 +88,8 @@ class HelpControllerTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\HelpController::show
|
||||
* @covers \FireflyIII\Http\Controllers\HelpController::getHelpText
|
||||
* @throws \Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testShowBackupFromGithub()
|
||||
{
|
||||
|
@@ -115,6 +115,7 @@ class ProfileControllerTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ProfileController::index
|
||||
* @covers \FireflyIII\Http\Controllers\ProfileController::__construct
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testIndex()
|
||||
{
|
||||
|
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
namespace Tests\Feature\Controllers;
|
||||
|
||||
use FireflyIII\Support\Search\SearchInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@@ -48,4 +49,21 @@ class SearchControllerTest extends TestCase
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\SearchController::search
|
||||
* @covers \FireflyIII\Http\Controllers\SearchController::__construct
|
||||
*/
|
||||
public function testSearch()
|
||||
{
|
||||
$search = $this->mock(SearchInterface::class);
|
||||
$search->shouldReceive('parseQuery')->once();
|
||||
$search->shouldReceive('setLimit')->withArgs([50])->once();
|
||||
$search->shouldReceive('searchTransactions')->once()->andReturn(new Collection);
|
||||
|
||||
$this->be($this->user());
|
||||
|
||||
$response = $this->get(route('search.search') . '?query=test');
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
}
|
||||
|
@@ -291,6 +291,7 @@ class SingleControllerTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::store
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::groupedActiveAccountList
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testStoreSuccess()
|
||||
{
|
||||
@@ -338,6 +339,7 @@ class SingleControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::update
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testUpdate()
|
||||
{
|
||||
|
@@ -25,6 +25,7 @@ namespace Tests\Feature\Controllers;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Helpers\Filter\InternalTransferFilter;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalTaskerInterface;
|
||||
@@ -41,10 +42,12 @@ use Tests\TestCase;
|
||||
*/
|
||||
class TransactionControllerTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\TransactionController::index
|
||||
* @covers \FireflyIII\Http\Controllers\TransactionController::__construct
|
||||
* @covers \FireflyIII\Http\Controllers\TransactionController::getPeriodOverview
|
||||
* @covers \FireflyIII\Http\Controllers\TransactionController::sumPerCurrency
|
||||
*/
|
||||
public function testIndex()
|
||||
{
|
||||
@@ -104,9 +107,19 @@ class TransactionControllerTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\TransactionController::index
|
||||
* @covers \FireflyIII\Http\Controllers\TransactionController::getPeriodOverview
|
||||
* @covers \FireflyIII\Http\Controllers\TransactionController::sumPerCurrency
|
||||
*/
|
||||
public function testIndexByDate()
|
||||
{
|
||||
$transaction = new Transaction;
|
||||
$transaction->transaction_currency_id = 1;
|
||||
$transaction->transaction_currency_symbol = 'x';
|
||||
$transaction->transaction_currency_code = 'ABC';
|
||||
$transaction->transaction_currency_dp = 2;
|
||||
$transaction->transaction_amount = '5';
|
||||
$collection = new Collection([$transaction]);
|
||||
|
||||
|
||||
// mock stuff
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
@@ -122,7 +135,7 @@ class TransactionControllerTest extends TestCase
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
|
||||
$collector->shouldReceive('removeFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf();
|
||||
$collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([], 0, 10));
|
||||
$collector->shouldReceive('getJournals')->andReturn(new Collection);
|
||||
$collector->shouldReceive('getJournals')->andReturn($collection);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.index', ['transfer', '2016-01-01']));
|
||||
@@ -135,9 +148,18 @@ class TransactionControllerTest extends TestCase
|
||||
* @covers \FireflyIII\Http\Controllers\TransactionController::index
|
||||
* @covers \FireflyIII\Http\Controllers\TransactionController::__construct
|
||||
* @covers \FireflyIII\Http\Controllers\TransactionController::getPeriodOverview
|
||||
* @covers \FireflyIII\Http\Controllers\TransactionController::sumPerCurrency
|
||||
*/
|
||||
public function testIndexDeposit()
|
||||
{
|
||||
$transaction = new Transaction;
|
||||
$transaction->transaction_currency_id = 1;
|
||||
$transaction->transaction_currency_symbol = 'x';
|
||||
$transaction->transaction_currency_code = 'ABC';
|
||||
$transaction->transaction_currency_dp = 2;
|
||||
$transaction->transaction_amount = '5';
|
||||
$collection = new Collection([$transaction]);
|
||||
|
||||
// mock stuff
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
@@ -153,7 +175,7 @@ class TransactionControllerTest extends TestCase
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
|
||||
$collector->shouldReceive('removeFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf();
|
||||
$collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([], 0, 10));
|
||||
$collector->shouldReceive('getJournals')->andReturn(new Collection);
|
||||
$collector->shouldReceive('getJournals')->andReturn($collection);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.index', ['deposit']));
|
||||
@@ -166,9 +188,18 @@ class TransactionControllerTest extends TestCase
|
||||
* @covers \FireflyIII\Http\Controllers\TransactionController::index
|
||||
* @covers \FireflyIII\Http\Controllers\TransactionController::__construct
|
||||
* @covers \FireflyIII\Http\Controllers\TransactionController::getPeriodOverview
|
||||
* @covers \FireflyIII\Http\Controllers\TransactionController::sumPerCurrency
|
||||
*/
|
||||
public function testIndexWithdrawal()
|
||||
{
|
||||
$transaction = new Transaction;
|
||||
$transaction->transaction_currency_id = 1;
|
||||
$transaction->transaction_currency_symbol = 'x';
|
||||
$transaction->transaction_currency_code = 'ABC';
|
||||
$transaction->transaction_currency_dp = 2;
|
||||
$transaction->transaction_amount = '5';
|
||||
$collection = new Collection([$transaction]);
|
||||
|
||||
// mock stuff
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
@@ -184,7 +215,7 @@ class TransactionControllerTest extends TestCase
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
|
||||
$collector->shouldReceive('removeFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf();
|
||||
$collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([], 0, 10));
|
||||
$collector->shouldReceive('getJournals')->andReturn(new Collection);
|
||||
$collector->shouldReceive('getJournals')->andReturn($collection);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.index', ['withdrawal']));
|
||||
@@ -193,6 +224,23 @@ class TransactionControllerTest extends TestCase
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\TransactionController::reconcile
|
||||
*/
|
||||
public function testReconcile()
|
||||
{
|
||||
$data = ['transactions' => [1, 2]];
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository->shouldReceive('first')->times(1)->andReturn(new TransactionJournal);
|
||||
|
||||
$repository->shouldReceive('findTransaction')->andReturn(new Transaction)->twice();
|
||||
$repository->shouldReceive('reconcile')->twice();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('transactions.reconcile'), $data);
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\TransactionController::reorder
|
||||
*/
|
||||
|
@@ -24,6 +24,9 @@ namespace Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class ExampleTest
|
||||
*/
|
||||
class ExampleTest extends TestCase
|
||||
{
|
||||
/**
|
||||
|
@@ -42,6 +42,8 @@ abstract class TestCase extends BaseTestCase
|
||||
/**
|
||||
* @param User $user
|
||||
* @param string $range
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function changeDateRange(User $user, $range)
|
||||
{
|
||||
|
@@ -24,6 +24,9 @@ namespace Tests\Unit;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class ExampleTest
|
||||
*/
|
||||
class ExampleTest extends TestCase
|
||||
{
|
||||
/**
|
||||
|
@@ -161,6 +161,9 @@ class MetaPieChartTest extends TestCase
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
private function fakeOthers(): Collection
|
||||
{
|
||||
$set = new Collection;
|
||||
@@ -181,6 +184,9 @@ class MetaPieChartTest extends TestCase
|
||||
return $set;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
private function fakeTransactions(): Collection
|
||||
{
|
||||
$set = new Collection;
|
||||
|
@@ -28,6 +28,9 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Actions\AddTag;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class AddTagTest
|
||||
*/
|
||||
class AddTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
|
@@ -27,6 +27,9 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Actions\AppendDescription;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class AppendDescriptionTest
|
||||
*/
|
||||
class AppendDescriptionTest extends TestCase
|
||||
{
|
||||
/**
|
||||
|
Reference in New Issue
Block a user