Finish command tests

This commit is contained in:
James Cole
2019-06-13 15:48:35 +02:00
parent 6bcb2ec144
commit 6964424bdc
29 changed files with 783 additions and 531 deletions

View File

@@ -28,6 +28,7 @@ use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
use FireflyIII\Models\Preference;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\Transformers\CurrencyTransformer;
use Laravel\Passport\Passport;
use Log;
@@ -64,6 +65,7 @@ class CurrencyControllerTest extends TestCase
$currency = TransactionCurrency::first();
$repository = $this->mock(CurrencyRepositoryInterface::class);
$transformer = $this->mock(CurrencyTransformer::class);
$userRepository = $this->mock(UserRepositoryInterface::class);
// mock transformer
$transformer->shouldReceive('setParameters')->withAnyArgs()->atLeast()->once();
@@ -103,6 +105,7 @@ class CurrencyControllerTest extends TestCase
$currency = TransactionCurrency::first();
$repository = $this->mock(CurrencyRepositoryInterface::class);
$transformer = $this->mock(CurrencyTransformer::class);
$userRepository = $this->mock(UserRepositoryInterface::class);
// mock transformer
$transformer->shouldReceive('setParameters')->withAnyArgs()->atLeast()->once();
@@ -148,6 +151,7 @@ class CurrencyControllerTest extends TestCase
$currency = TransactionCurrency::first();
$repository = $this->mock(CurrencyRepositoryInterface::class);
$transformer = $this->mock(CurrencyTransformer::class);
$this->mock(UserRepositoryInterface::class);
// mock transformer
$transformer->shouldReceive('setParameters')->withAnyArgs()->atLeast()->once();
@@ -187,6 +191,7 @@ class CurrencyControllerTest extends TestCase
$currency = TransactionCurrency::first();
$repository = $this->mock(CurrencyRepositoryInterface::class);
$transformer = $this->mock(CurrencyTransformer::class);
$this->mock(UserRepositoryInterface::class);
$preference = new Preference;
$preference->data = 'EUR';

View File

@@ -181,6 +181,7 @@ class LinkTypeControllerTest extends TestCase
{
// mock stuff:
$repository = $this->mock(LinkTypeRepositoryInterface::class);
$userRepository = $this->mock(UserRepositoryInterface::class);
// create editable link type:
$linkType = LinkType::create(

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace Tests\Api\V1\Controllers;
use FireflyIII\Models\Preference;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Transformers\PreferenceTransformer;
use Laravel\Passport\Passport;
use Log;
@@ -56,6 +57,7 @@ class PreferencesControllerTest extends TestCase
public function testUpdateArray(): void
{
$transformer = $this->mock(PreferenceTransformer::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
// mock calls to transformer:
$transformer->shouldReceive('setParameters')->withAnyArgs()->atLeast()->once();
@@ -63,6 +65,7 @@ class PreferencesControllerTest extends TestCase
$transformer->shouldReceive('getDefaultIncludes')->withAnyArgs()->atLeast()->once()->andReturn([]);
$transformer->shouldReceive('getAvailableIncludes')->withAnyArgs()->atLeast()->once()->andReturn([]);
$transformer->shouldReceive('transform')->atLeast()->once()->andReturn(['id' => 5]);
$accountRepos->shouldReceive('setUser')->atLeast()->once();
/** @var Preference $preference */
$preference = Preferences::setForUser($this->user(), 'frontPageAccounts', [1, 2, 3]);
@@ -78,6 +81,7 @@ class PreferencesControllerTest extends TestCase
public function testUpdateBoolean(): void
{
$transformer = $this->mock(PreferenceTransformer::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
// mock calls to transformer:
$transformer->shouldReceive('setParameters')->withAnyArgs()->atLeast()->once();
@@ -85,6 +89,7 @@ class PreferencesControllerTest extends TestCase
$transformer->shouldReceive('getDefaultIncludes')->withAnyArgs()->atLeast()->once()->andReturn([]);
$transformer->shouldReceive('getAvailableIncludes')->withAnyArgs()->atLeast()->once()->andReturn([]);
$transformer->shouldReceive('transform')->atLeast()->once()->andReturn(['id' => 5]);
$accountRepos->shouldReceive('setUser')->atLeast()->once();
/** @var Preference $preference */
$preference = Preferences::setForUser($this->user(), 'twoFactorAuthEnabled', false);
@@ -101,6 +106,7 @@ class PreferencesControllerTest extends TestCase
public function testUpdateDefault(): void
{
$transformer = $this->mock(PreferenceTransformer::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
// mock calls to transformer:
$transformer->shouldReceive('setParameters')->withAnyArgs()->atLeast()->once();
@@ -108,6 +114,7 @@ class PreferencesControllerTest extends TestCase
$transformer->shouldReceive('getDefaultIncludes')->withAnyArgs()->atLeast()->once()->andReturn([]);
$transformer->shouldReceive('getAvailableIncludes')->withAnyArgs()->atLeast()->once()->andReturn([]);
$transformer->shouldReceive('transform')->atLeast()->once()->andReturn(['id' => 5]);
$accountRepos->shouldReceive('setUser')->atLeast()->once();
/** @var Preference $preference */
$preference = Preferences::setForUser($this->user(), 'currencyPreference', false);
@@ -123,6 +130,7 @@ class PreferencesControllerTest extends TestCase
public function testUpdateInteger(): void
{
$transformer = $this->mock(PreferenceTransformer::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
// mock calls to transformer:
$transformer->shouldReceive('setParameters')->withAnyArgs()->atLeast()->once();
@@ -130,6 +138,7 @@ class PreferencesControllerTest extends TestCase
$transformer->shouldReceive('getDefaultIncludes')->withAnyArgs()->atLeast()->once()->andReturn([]);
$transformer->shouldReceive('getAvailableIncludes')->withAnyArgs()->atLeast()->once()->andReturn([]);
$transformer->shouldReceive('transform')->atLeast()->once()->andReturn(['id' => 5]);
$accountRepos->shouldReceive('setUser')->atLeast()->once();
/** @var Preference $preference */
$preference = Preferences::setForUser($this->user(), 'listPageSize', 13);