Various code cleanup.

This commit is contained in:
James Cole
2018-02-09 19:11:55 +01:00
parent ac98822a55
commit 95648c37b3
30 changed files with 142 additions and 256 deletions

View File

@@ -74,6 +74,7 @@ class BillController extends Controller
public function destroy(Bill $bill) public function destroy(Bill $bill)
{ {
$this->repository->destroy($bill); $this->repository->destroy($bill);
return response()->json(null, 204); return response()->json(null, 204);
} }

View File

@@ -252,6 +252,7 @@ class JournalCollector implements JournalCollectorInterface
$cache->addProperty($key); $cache->addProperty($key);
if ($cache->has()) { if ($cache->has()) {
Log::debug(sprintf('Return cache of query with ID "%s".', $key)); Log::debug(sprintf('Return cache of query with ID "%s".', $key));
return $cache->get(); // @codeCoverageIgnore return $cache->get(); // @codeCoverageIgnore
} }

View File

@@ -27,7 +27,6 @@ use FireflyIII\Models\Budget;
use FireflyIII\Models\Category; use FireflyIII\Models\Category;
use FireflyIII\Models\Tag; use FireflyIII\Models\Tag;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;

View File

@@ -290,9 +290,6 @@ class AccountController extends Controller
if (AccountType::INITIAL_BALANCE === $account->accountType->type) { if (AccountType::INITIAL_BALANCE === $account->accountType->type) {
return $this->redirectToOriginalAccount($account); return $this->redirectToOriginalAccount($account);
} }
if ($end < $start) {
throw new FireflyException('End is after start!');
}
$range = Preferences::get('viewRange', '1M')->data; $range = Preferences::get('viewRange', '1M')->data;
if (null === $start) { if (null === $start) {
$start = session('start'); $start = session('start');
@@ -300,6 +297,9 @@ class AccountController extends Controller
if (null === $end) { if (null === $end) {
$end = app('navigation')->endOfPeriod($start, $range); $end = app('navigation')->endOfPeriod($start, $range);
} }
if ($end < $start) {
throw new FireflyException('End is after start!');
}
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type); $subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type);
$page = intval($request->get('page')); $page = intval($request->get('page'));

View File

@@ -75,6 +75,7 @@ class ResetPasswordController extends Controller
if (true === $singleUserMode && $userCount > 0) { if (true === $singleUserMode && $userCount > 0) {
$allowRegistration = false; $allowRegistration = false;
} }
return view('auth.passwords.reset')->with( return view('auth.passwords.reset')->with(
['token' => $token, 'email' => $request->email, 'allowRegistration' => $allowRegistration] ['token' => $token, 'email' => $request->email, 'allowRegistration' => $allowRegistration]
); );

View File

@@ -35,7 +35,6 @@ use Illuminate\Http\Request;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log; use Log;
use Preferences; use Preferences;
use Session;
use View; use View;
/** /**

View File

@@ -25,8 +25,8 @@ namespace FireflyIII\Http\Controllers\Transaction;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\MassDeleteJournalRequest; use FireflyIII\Http\Requests\MassDeleteJournalRequest;
use FireflyIII\Http\Requests\MassEditJournalRequest;
use FireflyIII\Http\Requests\MassEditBulkJournalRequest; use FireflyIII\Http\Requests\MassEditBulkJournalRequest;
use FireflyIII\Http\Requests\MassEditJournalRequest;
use FireflyIII\Models\AccountType; use FireflyIII\Models\AccountType;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;

View File

@@ -24,8 +24,8 @@ namespace FireflyIII\Http;
use FireflyIII\Http\Middleware\Authenticate; use FireflyIII\Http\Middleware\Authenticate;
use FireflyIII\Http\Middleware\AuthenticateTwoFactor; use FireflyIII\Http\Middleware\AuthenticateTwoFactor;
use FireflyIII\Http\Middleware\EncryptCookies;
use FireflyIII\Http\Middleware\Binder; use FireflyIII\Http\Middleware\Binder;
use FireflyIII\Http\Middleware\EncryptCookies;
use FireflyIII\Http\Middleware\IsAdmin; use FireflyIII\Http\Middleware\IsAdmin;
use FireflyIII\Http\Middleware\Range; use FireflyIII\Http\Middleware\Range;
use FireflyIII\Http\Middleware\RedirectIfAuthenticated; use FireflyIII\Http\Middleware\RedirectIfAuthenticated;

View File

@@ -40,6 +40,16 @@ class Request extends FormRequest
return 1 === intval($this->input($field)); return 1 === intval($this->input($field));
} }
/**
* @param string $field
*
* @return int
*/
public function integer(string $field): int
{
return intval($this->get($field));
}
/** /**
* @param string $field * @param string $field
* *
@@ -137,14 +147,4 @@ class Request extends FormRequest
return $return; return $return;
} }
/**
* @param string $field
*
* @return int
*/
public function integer(string $field): int
{
return intval($this->get($field));
}
} }

View File

@@ -263,6 +263,7 @@ class FileConfigurator implements ConfiguratorInterface
* Shorthand method to set the extended status. * Shorthand method to set the extended status.
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*
* @param array $extended * @param array $extended
*/ */
private function setExtendedStatus(array $extended): void private function setExtendedStatus(array $extended): void

View File

@@ -125,6 +125,7 @@ class CsvProcessor implements FileProcessorInterface
* Shorthand method to set the extended status. * Shorthand method to set the extended status.
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*
* @param array $array * @param array $array
*/ */
public function setExtendedStatus(array $array) public function setExtendedStatus(array $array)

View File

@@ -67,9 +67,10 @@ class FilePrerequisites implements PrerequisitesInterface
*/ */
public function hasPrerequisites(): bool public function hasPrerequisites(): bool
{ {
if($this->user->hasRole('demo')) { if ($this->user->hasRole('demo')) {
throw new FireflyException('Apologies, the demo user cannot import files.'); throw new FireflyException('Apologies, the demo user cannot import files.');
} }
return false; return false;
} }

View File

@@ -114,7 +114,6 @@ class FileRoutine implements RoutineInterface
Log::debug('Back in run()'); Log::debug('Back in run()');
Log::debug('Updated job...'); Log::debug('Updated job...');
Log::debug(sprintf('%d journals in $storage->journals', $storage->journals->count())); Log::debug(sprintf('%d journals in $storage->journals', $storage->journals->count()));
$this->journals = $storage->journals; $this->journals = $storage->journals;
@@ -177,6 +176,16 @@ class FileRoutine implements RoutineInterface
$this->repository->addStepsDone($this->job, 1); $this->repository->addStepsDone($this->job, 1);
} }
/**
* Shorthand
*
* @param int $steps
*/
private function addTotalSteps(int $steps)
{
$this->repository->addTotalSteps($this->job, $steps);
}
/** /**
* *
*/ */
@@ -220,6 +229,7 @@ class FileRoutine implements RoutineInterface
} }
Log::info(sprintf('Linked %d journals to tag #%d ("%s")', $this->journals->count(), $tag->id, $tag->tag)); Log::info(sprintf('Linked %d journals to tag #%d ("%s")', $this->journals->count(), $tag->id, $tag->tag));
$this->addStep(); $this->addStep();
return $tag; return $tag;
} }
@@ -281,16 +291,6 @@ class FileRoutine implements RoutineInterface
$this->repository->setTotalSteps($this->job, $steps); $this->repository->setTotalSteps($this->job, $steps);
} }
/**
* Shorthand
*
* @param int $steps
*/
private function addTotalSteps(int $steps)
{
$this->repository->addTotalSteps($this->job, $steps);
}
/** /**
* @param Collection $objects * @param Collection $objects
* *

View File

@@ -29,7 +29,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Watson\Validating\ValidatingTrait; use Watson\Validating\ValidatingTrait;
use Illuminate\Contracts\Auth\Factory as Auth;
/** /**
* Class Bill. * Class Bill.
*/ */

View File

@@ -22,15 +22,11 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\Journal; namespace FireflyIII\Repositories\Journal;
use DB;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\Tag;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
use Log;
/** /**
* Trait UpdateJournalsTrait. * Trait UpdateJournalsTrait.

View File

@@ -32,14 +32,6 @@ use Illuminate\Support\Collection;
interface UserRepositoryInterface interface UserRepositoryInterface
{ {
/**
* @param string $name
* @param string $displayName
* @param string $description
*
* @return Role
*/
public function createRole(string $name, string $displayName, string $description): Role;
/** /**
* Returns a collection of all users. * Returns a collection of all users.
* *
@@ -47,13 +39,6 @@ interface UserRepositoryInterface
*/ */
public function all(): Collection; public function all(): Collection;
/**
* @param string $role
*
* @return Role|null
*/
public function getRole(string $role): ?Role;
/** /**
* Gives a user a role. * Gives a user a role.
* *
@@ -101,6 +86,15 @@ interface UserRepositoryInterface
*/ */
public function count(): int; public function count(): int;
/**
* @param string $name
* @param string $displayName
* @param string $description
*
* @return Role
*/
public function createRole(string $name, string $displayName, string $description): Role;
/** /**
* @param User $user * @param User $user
* *
@@ -129,6 +123,13 @@ interface UserRepositoryInterface
*/ */
public function first(): ?User; public function first(): ?User;
/**
* @param string $role
*
* @return Role|null
*/
public function getRole(string $role): ?Role;
/** /**
* Return basic user information. * Return basic user information.
* *

View File

@@ -57,14 +57,6 @@ class Transaction extends SpectreObject
/** @var Carbon */ /** @var Carbon */
private $updatedAt; private $updatedAt;
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/** /**
* Transaction constructor. * Transaction constructor.
* *
@@ -87,39 +79,6 @@ class Transaction extends SpectreObject
$this->updatedAt = new Carbon($data['updated_at']); $this->updatedAt = new Carbon($data['updated_at']);
} }
/**
* @return string
*/
public function getMode(): string
{
return $this->mode;
}
/**
* @return string
*/
public function getStatus(): string
{
return $this->status;
}
/**
* @return bool
*/
public function isDuplicated(): bool
{
return $this->duplicated;
}
/**
* @return TransactionExtra
*/
public function getExtra(): TransactionExtra
{
return $this->extra;
}
/** /**
* @return string * @return string
*/ */
@@ -152,6 +111,14 @@ class Transaction extends SpectreObject
return $this->description; return $this->description;
} }
/**
* @return TransactionExtra
*/
public function getExtra(): TransactionExtra
{
return $this->extra;
}
/** /**
* @return string * @return string
*/ */
@@ -177,6 +144,14 @@ class Transaction extends SpectreObject
return $hashed; return $hashed;
} }
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/** /**
* @return Carbon * @return Carbon
*/ */
@@ -185,5 +160,29 @@ class Transaction extends SpectreObject
return $this->madeOn; return $this->madeOn;
} }
/**
* @return string
*/
public function getMode(): string
{
return $this->mode;
}
/**
* @return string
*/
public function getStatus(): string
{
return $this->status;
}
/**
* @return bool
*/
public function isDuplicated(): bool
{
return $this->duplicated;
}
} }

View File

@@ -26,6 +26,7 @@ namespace FireflyIII\Services\Spectre\Request;
use FireflyIII\Services\Spectre\Object\Customer; use FireflyIII\Services\Spectre\Object\Customer;
use FireflyIII\Services\Spectre\Object\Login; use FireflyIII\Services\Spectre\Object\Login;
use Log; use Log;
/** /**
* Class ListLoginsRequest * Class ListLoginsRequest
*/ */
@@ -37,14 +38,6 @@ class ListLoginsRequest extends SpectreRequest
/** @var array */ /** @var array */
private $logins = []; private $logins = [];
/**
* @return array
*/
public function getLogins(): array
{
return $this->logins;
}
/** /**
* *
*/ */
@@ -79,6 +72,14 @@ class ListLoginsRequest extends SpectreRequest
} }
} }
/**
* @return array
*/
public function getLogins(): array
{
return $this->logins;
}
/** /**
* @param Customer $customer * @param Customer $customer
*/ */

View File

@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Services\Spectre\Request; namespace FireflyIII\Services\Spectre\Request;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Services\Spectre\Exception\DuplicatedCustomerException;
use FireflyIII\Services\Spectre\Exception\SpectreException; use FireflyIII\Services\Spectre\Exception\SpectreException;
use FireflyIII\User; use FireflyIII\User;
use Log; use Log;

View File

@@ -25,7 +25,6 @@ namespace FireflyIII\Support;
use Amount as Amt; use Amount as Amt;
use Carbon\Carbon; use Carbon\Carbon;
use Eloquent; use Eloquent;
use FireflyIII\Exceptions\FireflyException;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\MessageBag; use Illuminate\Support\MessageBag;
use RuntimeException; use RuntimeException;

View File

@@ -88,6 +88,7 @@ class Transaction extends Twig_Extension
$currency->decimal_places = $transaction->foreign_currency_dp; $currency->decimal_places = $transaction->foreign_currency_dp;
$str .= ' (' . sprintf($format, app('amount')->formatAnything($currency, $amount, $coloured)) . ')'; $str .= ' (' . sprintf($format, app('amount')->formatAnything($currency, $amount, $coloured)) . ')';
} }
return $str; return $str;
} }
@@ -115,6 +116,7 @@ class Transaction extends Twig_Extension
$fakeCurrency->symbol = $transaction['foreign_currency_symbol']; $fakeCurrency->symbol = $transaction['foreign_currency_symbol'];
$string .= ' (' . app('amount')->formatAnything($fakeCurrency, $amount, true) . ')'; $string .= ' (' . app('amount')->formatAnything($fakeCurrency, $amount, true) . ')';
} }
return $string; return $string;
} }
@@ -201,6 +203,7 @@ class Transaction extends Twig_Extension
} }
$txt = ''; $txt = '';
return $txt; return $txt;
} }
@@ -350,10 +353,12 @@ class Transaction extends Twig_Extension
$count = TransactionModel::where('transaction_journal_id', $journalId)->whereNull('deleted_at')->count(); $count = TransactionModel::where('transaction_journal_id', $journalId)->whereNull('deleted_at')->count();
if ($count > 2) { if ($count > 2) {
$res = '<i class="fa fa-fw fa-share-alt" aria-hidden="true"></i>'; $res = '<i class="fa fa-fw fa-share-alt" aria-hidden="true"></i>';
return $res; return $res;
} }
$res = ''; $res = '';
return $res; return $res;
} }
@@ -403,6 +408,7 @@ class Transaction extends Twig_Extension
} }
$txt = sprintf('<a title="%1$s" href="%2$s">%1$s</a>', e($name), route('accounts.show', [$transactionId])); $txt = sprintf('<a title="%1$s" href="%2$s">%1$s</a>', e($name), route('accounts.show', [$transactionId]));
return $txt; return $txt;
} }
} }

View File

@@ -54,7 +54,7 @@ class AttachmentTransformer extends TransformerAbstract
'rel' => 'self', 'rel' => 'self',
'uri' => '/attachment/' . $attachment->id, 'uri' => '/attachment/' . $attachment->id,
], ],
] ],
]; ];
} }

View File

@@ -53,7 +53,7 @@ class NoteTransformer extends TransformerAbstract
'rel' => 'self', 'rel' => 'self',
'uri' => '/note/' . $note->id, 'uri' => '/note/' . $note->id,
], ],
] ],
]; ];
} }

View File

@@ -76,7 +76,7 @@ Breadcrumbs::register(
Breadcrumbs::register( Breadcrumbs::register(
'accounts.show', 'accounts.show',
function (BreadCrumbsGenerator $breadcrumbs, Account $account, Carbon $start, Carbon $end) { function (BreadCrumbsGenerator $breadcrumbs, Account $account, Carbon $start = null, Carbon $end = null) {
$what = config('firefly.shortNamesByFullName.' . $account->accountType->type); $what = config('firefly.shortNamesByFullName.' . $account->accountType->type);
$breadcrumbs->parent('accounts.index', $what); $breadcrumbs->parent('accounts.index', $what);
@@ -84,25 +84,25 @@ Breadcrumbs::register(
$title = trans( $title = trans(
'firefly.between_dates_breadcrumb', 'firefly.between_dates_breadcrumb',
['start' => $start->formatLocalized(strval(trans('config.month_and_day'))), ['start' => $start ? $start->formatLocalized(strval(trans('config.month_and_day'))) : '',
'end' => $end->formatLocalized(strval(trans('config.month_and_day'))),] 'end' => $end ? $end->formatLocalized(strval(trans('config.month_and_day'))) : '',]
); );
$breadcrumbs->push($title, route('accounts.show', [$account->id, $start, $end])); $breadcrumbs->push($title, route('accounts.show', $account));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'accounts.reconcile', 'accounts.reconcile',
function (BreadCrumbsGenerator $breadcrumbs, Account $account) { function (BreadCrumbsGenerator $breadcrumbs, Account $account) {
$breadcrumbs->parent('accounts.show', $account, '(nothing)', new Carbon, new Carbon); $breadcrumbs->parent('accounts.show', $account);
$breadcrumbs->push(trans('firefly.reconcile_account', ['account' =>$account->name]), route('accounts.reconcile', [$account->id])); $breadcrumbs->push(trans('firefly.reconcile_account', ['account' => $account->name]), route('accounts.reconcile', [$account->id]));
} }
); );
Breadcrumbs::register( Breadcrumbs::register(
'accounts.reconcile.show', 'accounts.reconcile.show',
function (BreadCrumbsGenerator $breadcrumbs, Account $account, TransactionJournal $journal) { function (BreadCrumbsGenerator $breadcrumbs, Account $account, TransactionJournal $journal) {
$breadcrumbs->parent('accounts.show', $account, '(nothing)', new Carbon, new Carbon); $breadcrumbs->parent('accounts.show', $account);
$title = trans('firefly.reconciliation') . ' "' . $journal->description . '"'; $title = trans('firefly.reconciliation') . ' "' . $journal->description . '"';
$breadcrumbs->push($title, route('accounts.reconcile.show', [$journal->id])); $breadcrumbs->push($title, route('accounts.reconcile.show', [$journal->id]));
} }
@@ -111,7 +111,7 @@ Breadcrumbs::register(
Breadcrumbs::register( Breadcrumbs::register(
'accounts.delete', 'accounts.delete',
function (BreadCrumbsGenerator $breadcrumbs, Account $account) { function (BreadCrumbsGenerator $breadcrumbs, Account $account) {
$breadcrumbs->parent('accounts.show', $account, '(nothing)', new Carbon, new Carbon); $breadcrumbs->parent('accounts.show', $account);
$breadcrumbs->push(trans('firefly.delete_account', ['name' => $account->name]), route('accounts.delete', [$account->id])); $breadcrumbs->push(trans('firefly.delete_account', ['name' => $account->name]), route('accounts.delete', [$account->id]));
} }
); );
@@ -119,7 +119,7 @@ Breadcrumbs::register(
Breadcrumbs::register( Breadcrumbs::register(
'accounts.edit', 'accounts.edit',
function (BreadCrumbsGenerator $breadcrumbs, Account $account) { function (BreadCrumbsGenerator $breadcrumbs, Account $account) {
$breadcrumbs->parent('accounts.show', $account, '(nothing)', new Carbon, new Carbon); $breadcrumbs->parent('accounts.show', $account);
$what = config('firefly.shortNamesByFullName.' . $account->accountType->type); $what = config('firefly.shortNamesByFullName.' . $account->accountType->type);
$breadcrumbs->push(trans('firefly.edit_' . $what . '_account', ['name' => $account->name]), route('accounts.edit', [$account->id])); $breadcrumbs->push(trans('firefly.edit_' . $what . '_account', ['name' => $account->name]), route('accounts.edit', [$account->id]));

View File

@@ -203,40 +203,6 @@ class AccountControllerTest extends TestCase
$response->assertSee('<ol class="breadcrumb">'); $response->assertSee('<ol class="breadcrumb">');
} }
/**
* @covers \FireflyIII\Http\Controllers\AccountController::show
* @dataProvider dateRangeProvider
*
* @param string $range
*/
public function testShowAll(string $range)
{
// mock stuff
$transaction = factory(Transaction::class)->make();
$collector = $this->mock(JournalCollectorInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->twice()->andReturn(new TransactionJournal);
$collector->shouldReceive('setAccounts')->andReturnSelf();
$collector->shouldReceive('setRange')->andReturnSelf();
$collector->shouldReceive('setLimit')->andReturnSelf();
$collector->shouldReceive('setPage')->andReturnSelf();
$collector->shouldReceive('setTypes')->andReturnSelf();
$collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([$transaction], 0, 10));
$tasker = $this->mock(AccountTaskerInterface::class);
$tasker->shouldReceive('amountOutInPeriod')->withAnyArgs()->andReturn('-1');
$tasker->shouldReceive('amountInInPeriod')->withAnyArgs()->andReturn('1');
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$response = $this->get(route('accounts.show', [1, 'all']));
$response->assertStatus(200);
// has bread crumb
$response->assertSee('<ol class="breadcrumb">');
}
/** /**
* @covers \FireflyIII\Http\Controllers\AccountController::show * @covers \FireflyIII\Http\Controllers\AccountController::show
* @covers \FireflyIII\Http\Controllers\AccountController::redirectToOriginalAccount * @covers \FireflyIII\Http\Controllers\AccountController::redirectToOriginalAccount
@@ -256,39 +222,6 @@ class AccountControllerTest extends TestCase
$response->assertStatus(500); $response->assertStatus(500);
} }
/**
* @covers \FireflyIII\Http\Controllers\AccountController::show
* @dataProvider dateRangeProvider
*
* @param string $range
*/
public function testShowByDate(string $range)
{
// mock stuff
$transaction = factory(Transaction::class)->make();
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$collector = $this->mock(JournalCollectorInterface::class);
$collector->shouldReceive('setAccounts')->andReturnSelf();
$collector->shouldReceive('setRange')->andReturnSelf();
$collector->shouldReceive('setLimit')->andReturnSelf();
$collector->shouldReceive('setPage')->andReturnSelf();
$collector->shouldReceive('setTypes')->andReturnSelf();
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
$collector->shouldReceive('getJournals')->andReturn(new Collection([$transaction]));
$collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([$transaction], 0, 10));
$repository = $this->mock(AccountRepositoryInterface::class);
$repository->shouldReceive('oldestJournalDate')->andReturn(new Carbon)->once();
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$response = $this->get(route('accounts.show', [1, '2016-01-01']));
$response->assertStatus(200);
// has bread crumb
$response->assertSee('<ol class="breadcrumb">');
}
/** /**
* @covers \FireflyIII\Http\Controllers\AccountController::show * @covers \FireflyIII\Http\Controllers\AccountController::show

View File

@@ -398,15 +398,17 @@ class CategoryControllerTest extends TestCase
$collector = $this->mock(JournalCollectorInterface::class); $collector = $this->mock(JournalCollectorInterface::class);
$collector->shouldReceive('setPage')->andReturnSelf()->once(); $collector->shouldReceive('setPage')->andReturnSelf()->once();
$collector->shouldReceive('setLimit')->andReturnSelf()->once(); $collector->shouldReceive('setLimit')->andReturnSelf()->once();
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->once(); $collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->atLeast(1);
$collector->shouldReceive('setRange')->andReturnSelf()->once(); $collector->shouldReceive('setRange')->andReturnSelf()->atLeast(1);
$collector->shouldReceive('removeFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf()->once(); $collector->shouldReceive('removeFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf()->atLeast(1);
$collector->shouldReceive('withBudgetInformation')->andReturnSelf()->once(); $collector->shouldReceive('withBudgetInformation')->andReturnSelf()->atLeast(1);
$collector->shouldReceive('withCategoryInformation')->andReturnSelf()->once(); $collector->shouldReceive('withCategoryInformation')->andReturnSelf()->atLeast(1);
$collector->shouldReceive('withOpposingAccount')->andReturnSelf()->once(); $collector->shouldReceive('withOpposingAccount')->andReturnSelf()->atLeast(1);
$collector->shouldReceive('setCategory')->andReturnSelf()->once(); $collector->shouldReceive('setCategory')->andReturnSelf()->atLeast(1);
$collector->shouldReceive('setTypes')->andReturnSelf()->atLeast(1);
$collector->shouldReceive('getJournals')->andReturn(new Collection)->atLeast(1);
$collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([], 0, 10))->once(); $collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([], 0, 10))->atLeast(1);
$this->be($this->user()); $this->be($this->user());
$this->changeDateRange($this->user(), $range); $this->changeDateRange($this->user(), $range);

View File

@@ -47,42 +47,6 @@ use Tests\TestCase;
*/ */
class AccountControllerTest extends 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::all
*/
public function testAllLongRange()
{
$generator = $this->mock(GeneratorInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$carbon = new Carbon;
$carbon->subMonths(5);
$accountRepos->shouldReceive('oldestJournalDate')->once()->andReturn($carbon);
Steam::shouldReceive('balance')->andReturn('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\Http\Controllers\Chart\AccountController::expenseAccounts
@@ -328,7 +292,7 @@ class AccountControllerTest extends TestCase
$this->be($this->user()); $this->be($this->user());
$this->changeDateRange($this->user(), $range); $this->changeDateRange($this->user(), $range);
$response = $this->get(route('chart.account.period', [1, '2012-01-01'])); $response = $this->get(route('chart.account.period', [1, '2012-01-01','2012-01-31']));
$response->assertStatus(200); $response->assertStatus(200);
} }
@@ -369,22 +333,4 @@ class AccountControllerTest extends TestCase
$response->assertStatus(200); $response->assertStatus(200);
} }
/**
* @covers \FireflyIII\Http\Controllers\Chart\AccountController::single
* @dataProvider dateRangeProvider
*
* @param string $range
*/
public function testSingle(string $range)
{
$generator = $this->mock(GeneratorInterface::class);
Steam::shouldReceive('balanceInRange')->andReturn(['2012-01-01' => '0']);
$generator->shouldReceive('singleSet')->andReturn([]);
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$response = $this->get(route('chart.account.single', [1]));
$response->assertStatus(200);
}
} }