mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Expand tests.
This commit is contained in:
parent
fd1f06c2cb
commit
e2f3788ff5
@ -438,8 +438,9 @@ class CategoryController extends Controller
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
Log::debug('Going to get period expenses and incomes.');
|
||||
Log::debug(sprintf('Going to get period expenses and incomes between %s and %s.', $start->format('Y-m-d'), $end->format('Y-m-d')));
|
||||
while ($end >= $start) {
|
||||
Log::debug('Loop!');
|
||||
$end = Navigation::startOfPeriod($end, $range);
|
||||
$currentEnd = Navigation::endOfPeriod($end, $range);
|
||||
|
||||
@ -483,6 +484,7 @@ class CategoryController extends Controller
|
||||
);
|
||||
$end = Navigation::subtractPeriod($end, $range, 1);
|
||||
}
|
||||
Log::debug('End of loops');
|
||||
$cache->store($entries);
|
||||
|
||||
return $entries;
|
||||
|
@ -229,7 +229,8 @@ class PiggyBankController extends Controller
|
||||
'sumOfTargets' => $piggyBank->targetamount,
|
||||
'leftToSave' => $piggyBank->leftToSave,
|
||||
];
|
||||
} else {
|
||||
}
|
||||
if (isset($accounts[$account->id])) {
|
||||
$accounts[$account->id]['sumOfSaved'] = bcadd($accounts[$account->id]['sumOfSaved'], strval($piggyBank->savedSoFar));
|
||||
$accounts[$account->id]['sumOfTargets'] = bcadd($accounts[$account->id]['sumOfTargets'], $piggyBank->targetamount);
|
||||
$accounts[$account->id]['leftToSave'] = bcadd($accounts[$account->id]['leftToSave'], $piggyBank->leftToSave);
|
||||
|
@ -212,11 +212,12 @@ class TransactionController extends Controller
|
||||
$cache->addProperty('transaction-list-entries');
|
||||
|
||||
if ($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
Log::debug('Going to get period expenses and incomes.');
|
||||
Log::debug(sprintf('Going to get period expenses and incomes between %s and %s.', $start->format('Y-m-d'), $end->format('Y-m-d')));
|
||||
while ($end >= $start) {
|
||||
Log::debug('Loop start!');
|
||||
$end = Navigation::startOfPeriod($end, $range);
|
||||
$currentEnd = Navigation::endOfPeriod($end, $range);
|
||||
|
||||
@ -238,6 +239,7 @@ class TransactionController extends Controller
|
||||
'transferred' => 0,
|
||||
'date' => clone $end,
|
||||
];
|
||||
Log::debug(sprintf('What is %s', $what));
|
||||
switch ($what) {
|
||||
default:
|
||||
throw new FireflyException(sprintf('Cannot handle "%s"', $what));
|
||||
@ -249,6 +251,7 @@ class TransactionController extends Controller
|
||||
break;
|
||||
case 'transfers':
|
||||
case 'transfer':
|
||||
Log::debug('HERE');
|
||||
$array['transferred'] = Steam::positive($sum);
|
||||
break;
|
||||
|
||||
@ -256,6 +259,7 @@ class TransactionController extends Controller
|
||||
$entries->push($array);
|
||||
$end = Navigation::subtractPeriod($end, $range, 1);
|
||||
}
|
||||
Log::debug('End of loop');
|
||||
$cache->store($entries);
|
||||
|
||||
return $entries;
|
||||
|
@ -33,6 +33,21 @@ $factory->define(
|
||||
}
|
||||
);
|
||||
|
||||
$factory->define(
|
||||
FireflyIII\Models\PiggyBank::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'id' => $faker->numberBetween(1, 10),
|
||||
'account_id' => $faker->numberBetween(1, 10),
|
||||
'name' => $faker->words(3, true),
|
||||
'target_amount' => '1000.00',
|
||||
'startdate' => '2017-01-01',
|
||||
'order' => 1,
|
||||
'active' => 1,
|
||||
'encrypted' => 0,
|
||||
];
|
||||
}
|
||||
);
|
||||
|
||||
$factory->define(
|
||||
FireflyIII\Models\Tag::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
|
@ -20,6 +20,7 @@ use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
use Steam;
|
||||
use Tests\TestCase;
|
||||
|
||||
class CategoryControllerTest extends TestCase
|
||||
@ -114,6 +115,7 @@ class CategoryControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\CategoryController::noCategory
|
||||
* @covers \FireflyIII\Http\Controllers\CategoryController::noCategoryPeriodEntries
|
||||
* @dataProvider dateRangeProvider
|
||||
*
|
||||
* @param string $range
|
||||
@ -137,6 +139,7 @@ class CategoryControllerTest extends TestCase
|
||||
$collector->shouldReceive('disableInternalFilter')->andReturnSelf();
|
||||
$collector->shouldReceive('setLimit')->andReturnSelf();
|
||||
|
||||
Steam::shouldReceive('positive')->once()->andReturn('1');
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
@ -148,6 +151,7 @@ class CategoryControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\CategoryController::noCategory
|
||||
* @covers \FireflyIII\Http\Controllers\CategoryController::noCategoryPeriodEntries
|
||||
* @dataProvider dateRangeProvider
|
||||
*
|
||||
* @param string $range
|
||||
@ -181,6 +185,7 @@ class CategoryControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\CategoryController::noCategory
|
||||
* @covers \FireflyIII\Http\Controllers\CategoryController::noCategoryPeriodEntries
|
||||
* @dataProvider dateRangeProvider
|
||||
*
|
||||
* @param string $range
|
||||
@ -204,6 +209,8 @@ class CategoryControllerTest extends TestCase
|
||||
$collector->shouldReceive('disableInternalFilter')->andReturnSelf();
|
||||
$collector->shouldReceive('setLimit')->andReturnSelf();
|
||||
|
||||
Steam::shouldReceive('positive')->once()->andReturn('1');
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
$response = $this->get(route('categories.no-category', ['2016-01-01']));
|
||||
|
@ -31,6 +31,24 @@ use Tests\TestCase;
|
||||
*/
|
||||
class AccountControllerTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Chart\AccountController::all
|
||||
*/
|
||||
public function testAll()
|
||||
{
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
|
||||
$accountRepos->shouldReceive('oldestJournalDate')->once()->andReturn(Carbon::now()->subMonth());
|
||||
Steam::shouldReceive('balanceInRange')->andReturn(['2012-01-01' => '0']);
|
||||
$generator->shouldReceive('singleSet')->andReturn([]);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('chart.account.all', [1]));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Chart\AccountController::expenseAccounts
|
||||
* @covers \FireflyIII\Generator\Chart\Basic\GeneratorInterface::singleSet
|
||||
@ -188,6 +206,7 @@ class AccountControllerTest extends TestCase
|
||||
{
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$generator->shouldReceive('multiSet')->andreturn([]);
|
||||
Steam::shouldReceive('balanceInRange')->andReturn(['2012-01-01' => '0']);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('chart.account.report', ['1', '20120101', '20120131']));
|
||||
|
@ -19,6 +19,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Steam;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -141,8 +142,11 @@ class PiggyBankControllerTest extends TestCase
|
||||
// mock stuff
|
||||
$repository = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$piggyBank = factory(PiggyBank::class)->make();
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('getPiggyBanks')->andReturn(new Collection);
|
||||
$repository->shouldReceive('getPiggyBanks')->andReturn(new Collection([$piggyBank]));
|
||||
|
||||
Steam::shouldReceive('balanceIgnoreVirtual')->twice()->andReturn('1');
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('piggy-banks.index'));
|
||||
|
@ -26,6 +26,7 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use Steam;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -53,6 +54,7 @@ class SingleControllerTest extends TestCase
|
||||
*/
|
||||
public function testCreate()
|
||||
{
|
||||
Steam::shouldReceive('phpBytes')->andReturn(2048);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('getActiveAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
|
@ -17,6 +17,7 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalTaskerInterface;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
use Steam;
|
||||
use Tests\TestCase;
|
||||
|
||||
class TransactionControllerTest extends TestCase
|
||||
@ -45,6 +46,8 @@ class TransactionControllerTest extends TestCase
|
||||
$collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([], 0, 10));
|
||||
$collector->shouldReceive('getJournals')->andReturn(new Collection);
|
||||
|
||||
Steam::shouldReceive('positive')->once()->andReturn('1');
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.index', ['transfer']));
|
||||
$response->assertStatus(200);
|
||||
@ -103,6 +106,7 @@ class TransactionControllerTest extends TestCase
|
||||
$collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([], 0, 10));
|
||||
$collector->shouldReceive('getJournals')->andReturn(new Collection);
|
||||
|
||||
Steam::shouldReceive('positive')->once()->andReturn('1');
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.index', ['transfer', '2016-01-01']));
|
||||
|
Loading…
Reference in New Issue
Block a user