mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 02:26:58 +00:00
Repositories will now warn if used in test environment.
This commit is contained in:
@@ -46,6 +46,16 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
/** @var User */
|
/** @var User */
|
||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
if ('testing' === env('APP_ENV')) {
|
||||||
|
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $types
|
* @param array $types
|
||||||
*
|
*
|
||||||
|
@@ -38,6 +38,16 @@ class AccountTasker implements AccountTaskerInterface
|
|||||||
/** @var User */
|
/** @var User */
|
||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
if ('testing' === env('APP_ENV')) {
|
||||||
|
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Collection $accounts
|
* @param Collection $accounts
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
|
@@ -45,6 +45,16 @@ class AttachmentRepository implements AttachmentRepositoryInterface
|
|||||||
/** @var User */
|
/** @var User */
|
||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
if ('testing' === env('APP_ENV')) {
|
||||||
|
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Attachment $attachment
|
* @param Attachment $attachment
|
||||||
*
|
*
|
||||||
|
@@ -48,6 +48,16 @@ class BillRepository implements BillRepositoryInterface
|
|||||||
/** @var User */
|
/** @var User */
|
||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
if ('testing' === env('APP_ENV')) {
|
||||||
|
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Bill $bill
|
* @param Bill $bill
|
||||||
*
|
*
|
||||||
|
@@ -54,6 +54,16 @@ class BudgetRepository implements BudgetRepositoryInterface
|
|||||||
/** @var User */
|
/** @var User */
|
||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
if ('testing' === env('APP_ENV')) {
|
||||||
|
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A method that returns the amount of money budgeted per day for this budget,
|
* A method that returns the amount of money budgeted per day for this budget,
|
||||||
* on average.
|
* on average.
|
||||||
|
@@ -47,6 +47,16 @@ class CategoryRepository implements CategoryRepositoryInterface
|
|||||||
/** @var User */
|
/** @var User */
|
||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
if ('testing' === env('APP_ENV')) {
|
||||||
|
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Category $category
|
* @param Category $category
|
||||||
*
|
*
|
||||||
|
@@ -43,10 +43,13 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
|||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CurrencyRepository constructor.
|
* Constructor.
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
if ('testing' === env('APP_ENV')) {
|
||||||
|
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -39,6 +39,16 @@ class ExportJobRepository implements ExportJobRepositoryInterface
|
|||||||
/** @var User */
|
/** @var User */
|
||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
if ('testing' === env('APP_ENV')) {
|
||||||
|
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ExportJob $job
|
* @param ExportJob $job
|
||||||
* @param string $status
|
* @param string $status
|
||||||
|
@@ -53,6 +53,10 @@ class ImportJobRepository implements ImportJobRepositoryInterface
|
|||||||
{
|
{
|
||||||
$this->maxUploadSize = (int)config('firefly.maxUploadSize');
|
$this->maxUploadSize = (int)config('firefly.maxUploadSize');
|
||||||
$this->uploadDisk = Storage::disk('upload');
|
$this->uploadDisk = Storage::disk('upload');
|
||||||
|
|
||||||
|
if ('testing' === env('APP_ENV')) {
|
||||||
|
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -380,7 +384,6 @@ class ImportJobRepository implements ImportJobRepositoryInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*
|
*
|
||||||
|
@@ -54,6 +54,16 @@ class JournalRepository implements JournalRepositoryInterface
|
|||||||
/** @var User */
|
/** @var User */
|
||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
if ('testing' === env('APP_ENV')) {
|
||||||
|
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** @noinspection MoreThanThreeArgumentsInspection */
|
/** @noinspection MoreThanThreeArgumentsInspection */
|
||||||
/**
|
/**
|
||||||
* @param TransactionJournal $journal
|
* @param TransactionJournal $journal
|
||||||
|
@@ -40,6 +40,16 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
|
|||||||
/** @var User */
|
/** @var User */
|
||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
if ('testing' === env('APP_ENV')) {
|
||||||
|
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param LinkType $linkType
|
* @param LinkType $linkType
|
||||||
*
|
*
|
||||||
|
@@ -44,6 +44,16 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
|||||||
/** @var User */
|
/** @var User */
|
||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
if ('testing' === env('APP_ENV')) {
|
||||||
|
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param PiggyBank $piggyBank
|
* @param PiggyBank $piggyBank
|
||||||
* @param string $amount
|
* @param string $amount
|
||||||
|
@@ -56,6 +56,16 @@ class RecurringRepository implements RecurringRepositoryInterface
|
|||||||
/** @var User */
|
/** @var User */
|
||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
if ('testing' === env('APP_ENV')) {
|
||||||
|
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy a recurring transaction.
|
* Destroy a recurring transaction.
|
||||||
*
|
*
|
||||||
|
@@ -29,6 +29,7 @@ use FireflyIII\Models\RuleGroup;
|
|||||||
use FireflyIII\Models\RuleTrigger;
|
use FireflyIII\Models\RuleTrigger;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class RuleRepository.
|
* Class RuleRepository.
|
||||||
@@ -40,6 +41,16 @@ class RuleRepository implements RuleRepositoryInterface
|
|||||||
/** @var User */
|
/** @var User */
|
||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
if ('testing' === env('APP_ENV')) {
|
||||||
|
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
|
@@ -27,6 +27,7 @@ use FireflyIII\Models\RuleGroup;
|
|||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class RuleGroupRepository.
|
* Class RuleGroupRepository.
|
||||||
@@ -36,6 +37,16 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
|||||||
/** @var User */
|
/** @var User */
|
||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
if ('testing' === env('APP_ENV')) {
|
||||||
|
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
|
@@ -43,6 +43,16 @@ class TagRepository implements TagRepositoryInterface
|
|||||||
/** @var User */
|
/** @var User */
|
||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
if ('testing' === env('APP_ENV')) {
|
||||||
|
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
|
@@ -36,6 +36,16 @@ use Log;
|
|||||||
*/
|
*/
|
||||||
class UserRepository implements UserRepositoryInterface
|
class UserRepository implements UserRepositoryInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
if ('testing' === env('APP_ENV')) {
|
||||||
|
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
@@ -55,6 +65,7 @@ class UserRepository implements UserRepositoryInterface
|
|||||||
$roleObject = Role::where('name', $role)->first();
|
$roleObject = Role::where('name', $role)->first();
|
||||||
if (null === $roleObject) {
|
if (null === $roleObject) {
|
||||||
Log::error(sprintf('Could not find role "%s" in attachRole()', $role));
|
Log::error(sprintf('Could not find role "%s" in attachRole()', $role));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -39,6 +39,16 @@ class FixerIOv2 implements ExchangeRateInterface
|
|||||||
/** @var User */
|
/** @var User */
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
if ('testing' === env('APP_ENV')) {
|
||||||
|
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param TransactionCurrency $fromCurrency
|
* @param TransactionCurrency $fromCurrency
|
||||||
* @param TransactionCurrency $toCurrency
|
* @param TransactionCurrency $toCurrency
|
||||||
|
@@ -30,11 +30,12 @@ use FireflyIII\Models\TransactionJournal;
|
|||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
use Mockery;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Class CreateControllerTest
|
* Class CreateControllerTest
|
||||||
@@ -60,9 +61,13 @@ class CreateControllerTest extends TestCase
|
|||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
$repository->shouldReceive('get')->andReturn(new Collection);
|
$repository->shouldReceive('get')->andReturn(new Collection);
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
|
|
||||||
|
// mock hasRole for user repository:
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(),'owner'])->andReturn(true)->atLeast()->once();
|
||||||
|
|
||||||
// get all types:
|
// get all types:
|
||||||
$accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Debt'])->andReturn(AccountType::find(11))->once();
|
$accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Debt'])->andReturn(AccountType::find(11))->once();
|
||||||
$accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Loan'])->andReturn(AccountType::find(9))->once();
|
$accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Loan'])->andReturn(AccountType::find(9))->once();
|
||||||
@@ -87,7 +92,7 @@ class CreateControllerTest extends TestCase
|
|||||||
// mock stuff
|
// mock stuff
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
|
||||||
$repository->shouldReceive('store')->once()->andReturn(factory(Account::class)->make());
|
$repository->shouldReceive('store')->once()->andReturn(factory(Account::class)->make());
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
|
|
||||||
@@ -116,7 +121,7 @@ class CreateControllerTest extends TestCase
|
|||||||
// mock stuff
|
// mock stuff
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
|
||||||
$repository->shouldReceive('store')->once()->andReturn(factory(Account::class)->make());
|
$repository->shouldReceive('store')->once()->andReturn(factory(Account::class)->make());
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
|
|
||||||
|
@@ -29,8 +29,10 @@ use FireflyIII\Models\TransactionJournal;
|
|||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
|
use Mockery;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,10 +59,13 @@ class DeleteControllerTest extends TestCase
|
|||||||
// mock stuff
|
// mock stuff
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
$repository->shouldReceive('getAccountsByType')->withArgs([[AccountType::ASSET]])->andReturn(new Collection);
|
$repository->shouldReceive('getAccountsByType')->withArgs([[AccountType::ASSET]])->andReturn(new Collection);
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
|
|
||||||
|
// mock hasRole for user repository:
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(),'owner'])->andReturn(true)->atLeast()->once();
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$account = $this->user()->accounts()->where('account_type_id', 3)->whereNull('deleted_at')->first();
|
$account = $this->user()->accounts()->where('account_type_id', 3)->whereNull('deleted_at')->first();
|
||||||
$response = $this->get(route('accounts.delete', [$account->id]));
|
$response = $this->get(route('accounts.delete', [$account->id]));
|
||||||
@@ -78,7 +83,6 @@ class DeleteControllerTest extends TestCase
|
|||||||
// mock stuff
|
// mock stuff
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
|
||||||
$repository->shouldReceive('findNull')->withArgs([0])->once()->andReturn(null);
|
$repository->shouldReceive('findNull')->withArgs([0])->once()->andReturn(null);
|
||||||
$repository->shouldReceive('destroy')->andReturn(true);
|
$repository->shouldReceive('destroy')->andReturn(true);
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
|
@@ -31,6 +31,7 @@ use FireflyIII\Models\TransactionJournal;
|
|||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
use Mockery;
|
use Mockery;
|
||||||
@@ -59,8 +60,13 @@ class EditControllerTest extends TestCase
|
|||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
|
$repository->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
|
||||||
|
|
||||||
|
// mock hasRole for user repository:
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||||
|
|
||||||
$repository->shouldReceive('findNull')->once()->andReturn(TransactionCurrency::find(1));
|
|
||||||
$repository->shouldReceive('get')->andReturn(new Collection);
|
$repository->shouldReceive('get')->andReturn(new Collection);
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
$accountRepos->shouldReceive('getNoteText')->andReturn('Some text')->once();
|
$accountRepos->shouldReceive('getNoteText')->andReturn('Some text')->once();
|
||||||
@@ -100,6 +106,10 @@ class EditControllerTest extends TestCase
|
|||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
|
// mock hasRole for user repository:
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||||
|
|
||||||
$repository->shouldReceive('findNull')->once()->andReturn(TransactionCurrency::find(1));
|
$repository->shouldReceive('findNull')->once()->andReturn(TransactionCurrency::find(1));
|
||||||
$repository->shouldReceive('get')->andReturn(new Collection);
|
$repository->shouldReceive('get')->andReturn(new Collection);
|
||||||
@@ -142,6 +152,10 @@ class EditControllerTest extends TestCase
|
|||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
|
// mock hasRole for user repository:
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||||
|
|
||||||
Amount::shouldReceive('getDefaultCurrency')->andReturn(TransactionCurrency::find(2));
|
Amount::shouldReceive('getDefaultCurrency')->andReturn(TransactionCurrency::find(2));
|
||||||
$repository->shouldReceive('findNull')->once()->andReturn(null);
|
$repository->shouldReceive('findNull')->once()->andReturn(null);
|
||||||
@@ -187,6 +201,7 @@ class EditControllerTest extends TestCase
|
|||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
|
||||||
$repository->shouldReceive('update')->once();
|
$repository->shouldReceive('update')->once();
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
|
|
||||||
|
@@ -28,6 +28,7 @@ use FireflyIII\Models\TransactionJournal;
|
|||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
use Mockery;
|
use Mockery;
|
||||||
@@ -67,6 +68,11 @@ class IndexControllerTest extends TestCase
|
|||||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
|
// mock hasRole for user repository:
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(),'owner'])->andReturn(true)->atLeast()->once();
|
||||||
|
|
||||||
$repository->shouldReceive('getAccountsByType')->andReturn(new Collection([$account]));
|
$repository->shouldReceive('getAccountsByType')->andReturn(new Collection([$account]));
|
||||||
$repository->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
|
$repository->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
|
@@ -30,6 +30,7 @@ use FireflyIII\Models\TransactionJournal;
|
|||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
use Mockery;
|
use Mockery;
|
||||||
@@ -57,6 +58,13 @@ class ReconcileControllerTest extends TestCase
|
|||||||
public function testEdit(): void
|
public function testEdit(): void
|
||||||
{
|
{
|
||||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
|
||||||
|
// mock hasRole for user repository:
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||||
|
|
||||||
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 5)->first();
|
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 5)->first();
|
||||||
$transaction = $journal->transactions()->where('amount', '>', 0)->first();
|
$transaction = $journal->transactions()->where('amount', '>', 0)->first();
|
||||||
$repository->shouldReceive('firstNull')->andReturn($journal);
|
$repository->shouldReceive('firstNull')->andReturn($journal);
|
||||||
@@ -80,6 +88,9 @@ class ReconcileControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testEditRedirect(): void
|
public function testEditRedirect(): void
|
||||||
{
|
{
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
|
||||||
$journal = $this->user()->transactionJournals()->where('transaction_type_id', '!=', 5)->first();
|
$journal = $this->user()->transactionJournals()->where('transaction_type_id', '!=', 5)->first();
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$response = $this->get(route('accounts.reconcile.edit', [$journal->id]));
|
$response = $this->get(route('accounts.reconcile.edit', [$journal->id]));
|
||||||
@@ -95,7 +106,13 @@ class ReconcileControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testReconcile(): void
|
public function testReconcile(): void
|
||||||
{
|
{
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
|
||||||
|
// mock hasRole for user repository:
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||||
|
|
||||||
$repository->shouldReceive('findNull')->once()->andReturn(TransactionCurrency::find(1));
|
$repository->shouldReceive('findNull')->once()->andReturn(TransactionCurrency::find(1));
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$response = $this->get(route('accounts.reconcile', [1, '20170101', '20170131']));
|
$response = $this->get(route('accounts.reconcile', [1, '20170101', '20170131']));
|
||||||
@@ -126,7 +143,13 @@ class ReconcileControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testReconcileNoDates(): void
|
public function testReconcileNoDates(): void
|
||||||
{
|
{
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
|
||||||
|
// mock hasRole for user repository:
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||||
|
|
||||||
$repository->shouldReceive('findNull')->once()->andReturn(TransactionCurrency::find(1));
|
$repository->shouldReceive('findNull')->once()->andReturn(TransactionCurrency::find(1));
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
@@ -144,7 +167,13 @@ class ReconcileControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testReconcileNoEndDate(): void
|
public function testReconcileNoEndDate(): void
|
||||||
{
|
{
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
|
||||||
|
// mock hasRole for user repository:
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||||
|
|
||||||
$repository->shouldReceive('findNull')->once()->andReturn(TransactionCurrency::find(1));
|
$repository->shouldReceive('findNull')->once()->andReturn(TransactionCurrency::find(1));
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
@@ -162,6 +191,9 @@ class ReconcileControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testReconcileNotAsset(): void
|
public function testReconcileNotAsset(): void
|
||||||
{
|
{
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
|
||||||
$account = $this->user()->accounts()->where('account_type_id', '!=', 6)->where('account_type_id', '!=', 3)->first();
|
$account = $this->user()->accounts()->where('account_type_id', '!=', 6)->where('account_type_id', '!=', 3)->first();
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$response = $this->get(route('accounts.reconcile', [$account->id, '20170101', '20170131']));
|
$response = $this->get(route('accounts.reconcile', [$account->id, '20170101', '20170131']));
|
||||||
@@ -175,8 +207,16 @@ class ReconcileControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testShow(): void
|
public function testShow(): void
|
||||||
{
|
{
|
||||||
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 5)->first();
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
|
||||||
|
// mock hasRole for user repository:
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||||
|
|
||||||
|
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 5)->first();
|
||||||
|
|
||||||
$repository->shouldReceive('firstNull')->andReturn(new TransactionJournal);
|
$repository->shouldReceive('firstNull')->andReturn(new TransactionJournal);
|
||||||
$repository->shouldReceive('getAssetTransaction')->once()->andReturn($journal->transactions()->first());
|
$repository->shouldReceive('getAssetTransaction')->once()->andReturn($journal->transactions()->first());
|
||||||
|
|
||||||
@@ -196,8 +236,12 @@ class ReconcileControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testShowError(): void
|
public function testShowError(): void
|
||||||
{
|
{
|
||||||
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 5)->first();
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
|
||||||
|
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 5)->first();
|
||||||
|
|
||||||
$repository->shouldReceive('firstNull')->andReturn(new TransactionJournal);
|
$repository->shouldReceive('firstNull')->andReturn(new TransactionJournal);
|
||||||
$repository->shouldReceive('getAssetTransaction')->once()->andReturnNull();
|
$repository->shouldReceive('getAssetTransaction')->once()->andReturnNull();
|
||||||
|
|
||||||
@@ -217,6 +261,9 @@ class ReconcileControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testShowSomethingElse(): void
|
public function testShowSomethingElse(): void
|
||||||
{
|
{
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
|
||||||
$journal = $this->user()->transactionJournals()->where('transaction_type_id', '!=', 5)->first();
|
$journal = $this->user()->transactionJournals()->where('transaction_type_id', '!=', 5)->first();
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$response = $this->get(route('accounts.reconcile.show', [$journal->id]));
|
$response = $this->get(route('accounts.reconcile.show', [$journal->id]));
|
||||||
@@ -234,6 +281,8 @@ class ReconcileControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
|
||||||
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
|
||||||
$journalRepos->shouldReceive('reconcileById')->andReturn(true);
|
$journalRepos->shouldReceive('reconcileById')->andReturn(true);
|
||||||
$journalRepos->shouldReceive('store')->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('store')->andReturn(new TransactionJournal);
|
||||||
@@ -262,6 +311,9 @@ class ReconcileControllerTest extends TestCase
|
|||||||
public function testUpdate(): void
|
public function testUpdate(): void
|
||||||
{
|
{
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
|
||||||
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
|
||||||
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([new Account]));
|
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([new Account]));
|
||||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([new Account]));
|
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([new Account]));
|
||||||
@@ -285,9 +337,7 @@ class ReconcileControllerTest extends TestCase
|
|||||||
public function testUpdateNotReconcile(): void
|
public function testUpdateNotReconcile(): void
|
||||||
{
|
{
|
||||||
$journal = $this->user()->transactionJournals()->where('transaction_type_id', '!=', 5)->first();
|
$journal = $this->user()->transactionJournals()->where('transaction_type_id', '!=', 5)->first();
|
||||||
$data = [
|
$data = ['amount' => '5',];
|
||||||
'amount' => '5',
|
|
||||||
];
|
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$response = $this->post(route('accounts.reconcile.update', [$journal->id]), $data);
|
$response = $this->post(route('accounts.reconcile.update', [$journal->id]), $data);
|
||||||
@@ -302,9 +352,7 @@ class ReconcileControllerTest extends TestCase
|
|||||||
public function testUpdateZero(): void
|
public function testUpdateZero(): void
|
||||||
{
|
{
|
||||||
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 5)->first();
|
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 5)->first();
|
||||||
$data = [
|
$data = ['amount' => '0',];
|
||||||
'amount' => '0',
|
|
||||||
];
|
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$response = $this->post(route('accounts.reconcile.update', [$journal->id]), $data);
|
$response = $this->post(route('accounts.reconcile.update', [$journal->id]), $data);
|
||||||
|
@@ -32,9 +32,11 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
|||||||
use FireflyIII\Repositories\Account\AccountTaskerInterface;
|
use FireflyIII\Repositories\Account\AccountTaskerInterface;
|
||||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use Illuminate\Pagination\LengthAwarePaginator;
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
|
use Mockery;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -68,6 +70,10 @@ class ShowControllerTest extends TestCase
|
|||||||
$tasker = $this->mock(AccountTaskerInterface::class);
|
$tasker = $this->mock(AccountTaskerInterface::class);
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
|
// mock hasRole for user repository:
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(),'owner'])->andReturn(true)->atLeast()->once();
|
||||||
|
|
||||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||||
|
|
||||||
@@ -115,6 +121,10 @@ class ShowControllerTest extends TestCase
|
|||||||
$tasker = $this->mock(AccountTaskerInterface::class);
|
$tasker = $this->mock(AccountTaskerInterface::class);
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
|
// mock hasRole for user repository:
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(),'owner'])->andReturn(true)->atLeast()->once();
|
||||||
|
|
||||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||||
|
|
||||||
@@ -156,7 +166,6 @@ class ShowControllerTest extends TestCase
|
|||||||
// mock
|
// mock
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
|
||||||
$this->session(['start' => '2018-01-01', 'end' => '2017-12-01']);
|
$this->session(['start' => '2018-01-01', 'end' => '2017-12-01']);
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
@@ -172,7 +181,6 @@ class ShowControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
// mock
|
// mock
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
$date = new Carbon;
|
$date = new Carbon;
|
||||||
$this->session(['start' => $date, 'end' => clone $date]);
|
$this->session(['start' => $date, 'end' => clone $date]);
|
||||||
@@ -197,6 +205,12 @@ class ShowControllerTest extends TestCase
|
|||||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
|
||||||
|
// mock hasRole for user repository:
|
||||||
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(),'owner'])->andReturn(true)->atLeast()->once();
|
||||||
|
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
$collector->shouldReceive('setAccounts')->andReturnSelf();
|
$collector->shouldReceive('setAccounts')->andReturnSelf();
|
||||||
$collector->shouldReceive('setRange')->andReturnSelf();
|
$collector->shouldReceive('setRange')->andReturnSelf();
|
||||||
@@ -204,7 +218,7 @@ class ShowControllerTest extends TestCase
|
|||||||
$collector->shouldReceive('setPage')->andReturnSelf();
|
$collector->shouldReceive('setPage')->andReturnSelf();
|
||||||
$collector->shouldReceive('getPaginatedTransactions')->andReturn(new LengthAwarePaginator([], 0, 10));
|
$collector->shouldReceive('getPaginatedTransactions')->andReturn(new LengthAwarePaginator([], 0, 10));
|
||||||
|
|
||||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
$repository->shouldReceive('oldestJournalDate')->andReturn(new Carbon);
|
$repository->shouldReceive('oldestJournalDate')->andReturn(new Carbon);
|
||||||
$repository->shouldReceive('getMetaValue')->andReturn('');
|
$repository->shouldReceive('getMetaValue')->andReturn('');
|
||||||
$repository->shouldReceive('isLiability')->andReturn(false);
|
$repository->shouldReceive('isLiability')->andReturn(false);
|
||||||
@@ -230,8 +244,7 @@ class ShowControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||||
$date = new Carbon;
|
$date = new Carbon;
|
||||||
$this->session(['start' => $date, 'end' => clone $date]);
|
$this->session(['start' => $date, 'end' => clone $date]);
|
||||||
@@ -258,6 +271,7 @@ class ShowControllerTest extends TestCase
|
|||||||
$tasker = $this->mock(AccountTaskerInterface::class);
|
$tasker = $this->mock(AccountTaskerInterface::class);
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
|
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
|
||||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||||
|
|
||||||
@@ -265,7 +279,7 @@ class ShowControllerTest extends TestCase
|
|||||||
$tasker->shouldReceive('amountOutInPeriod')->withAnyArgs()->andReturn('-1');
|
$tasker->shouldReceive('amountOutInPeriod')->withAnyArgs()->andReturn('-1');
|
||||||
$tasker->shouldReceive('amountInInPeriod')->withAnyArgs()->andReturn('1');
|
$tasker->shouldReceive('amountInInPeriod')->withAnyArgs()->andReturn('1');
|
||||||
|
|
||||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
$repository->shouldReceive('getMetaValue')->andReturn('');
|
$repository->shouldReceive('getMetaValue')->andReturn('');
|
||||||
$repository->shouldReceive('isLiability')->andReturn(true);
|
$repository->shouldReceive('isLiability')->andReturn(true);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user