mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-22 12:11:19 +00:00
Update tests so repositories are not called. Saves on DB calls, speeds up tests.
This commit is contained in:
@@ -27,6 +27,7 @@ use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||
use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
@@ -57,6 +58,7 @@ class AttachmentControllerTest extends TestCase
|
||||
{
|
||||
// mock stuff:
|
||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('destroy')->once()->andReturn(true);
|
||||
@@ -78,6 +80,8 @@ class AttachmentControllerTest extends TestCase
|
||||
{
|
||||
// mock stuff:
|
||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$content = 'Attachment content ' . random_int(100, 1000);
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
@@ -104,6 +108,8 @@ class AttachmentControllerTest extends TestCase
|
||||
{
|
||||
// mock stuff:
|
||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$content = 'Attachment content ' . random_int(100, 1000);
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
@@ -128,6 +134,8 @@ class AttachmentControllerTest extends TestCase
|
||||
{
|
||||
// mock stuff:
|
||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
|
||||
@@ -165,6 +173,8 @@ class AttachmentControllerTest extends TestCase
|
||||
|
||||
// mock stuff:
|
||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
@@ -191,6 +201,8 @@ class AttachmentControllerTest extends TestCase
|
||||
|
||||
// mock stuff:
|
||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
@@ -218,6 +230,8 @@ class AttachmentControllerTest extends TestCase
|
||||
// mock stuff:
|
||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
@@ -253,6 +267,8 @@ class AttachmentControllerTest extends TestCase
|
||||
{
|
||||
// mock repositories
|
||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
|
||||
/** @var Attachment $attachment */
|
||||
$attachment = $this->user()->attachments()->first();
|
||||
@@ -286,6 +302,11 @@ class AttachmentControllerTest extends TestCase
|
||||
*/
|
||||
public function testUpload(): void
|
||||
{
|
||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
|
||||
|
||||
/** @var Attachment $attachment */
|
||||
$attachment = $this->user()->attachments()->first();
|
||||
$content = 'Hello there';
|
||||
|
@@ -25,8 +25,10 @@ namespace Tests\Api\V1\Controllers;
|
||||
|
||||
use FireflyConfig;
|
||||
use FireflyIII\Models\Configuration;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@@ -52,6 +54,9 @@ class ConfigurationControllerTest extends TestCase
|
||||
*/
|
||||
public function testIndex(): void
|
||||
{
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||
|
||||
$demoConfig = new Configuration;
|
||||
$demoConfig->name = 'is_demo_site';
|
||||
$demoConfig->data = false;
|
||||
@@ -96,6 +101,9 @@ class ConfigurationControllerTest extends TestCase
|
||||
*/
|
||||
public function testIndexNotOwner(): void
|
||||
{
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(false);
|
||||
|
||||
Passport::actingAs($this->emptyUser());
|
||||
$response = $this->get('/api/v1/configuration');
|
||||
$response->assertStatus(500);
|
||||
@@ -109,7 +117,9 @@ class ConfigurationControllerTest extends TestCase
|
||||
*/
|
||||
public function testUpdate(): void
|
||||
{
|
||||
$data = [
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||
$data = [
|
||||
'name' => 'permission_update_check',
|
||||
'value' => 1,
|
||||
|
||||
@@ -159,6 +169,9 @@ class ConfigurationControllerTest extends TestCase
|
||||
*/
|
||||
public function testUpdateBoolean(): void
|
||||
{
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||
|
||||
$data = [
|
||||
'name' => 'single_user_mode',
|
||||
'value' => 'true',
|
||||
@@ -209,6 +222,8 @@ class ConfigurationControllerTest extends TestCase
|
||||
*/
|
||||
public function testUpdateInvalid(): void
|
||||
{
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||
$data = [
|
||||
'name' => 'last_update_check',
|
||||
'value' => 'true',
|
||||
@@ -225,6 +240,9 @@ class ConfigurationControllerTest extends TestCase
|
||||
*/
|
||||
public function testUpdateNotOwner(): void
|
||||
{
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(false);
|
||||
|
||||
Passport::actingAs($this->emptyUser());
|
||||
$response = $this->post('/api/v1/configuration');
|
||||
$response->assertStatus(500);
|
||||
|
@@ -87,6 +87,7 @@ class CurrencyControllerTest extends TestCase
|
||||
$collection = TransactionCurrency::get();
|
||||
// mock stuff:
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
@@ -125,6 +126,7 @@ class CurrencyControllerTest extends TestCase
|
||||
// create stuff
|
||||
$currency = TransactionCurrency::first();
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
@@ -152,6 +154,7 @@ class CurrencyControllerTest extends TestCase
|
||||
|
||||
$currency = TransactionCurrency::first();
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
@@ -182,8 +185,10 @@ class CurrencyControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreWithDefault(): void
|
||||
{
|
||||
$currency = TransactionCurrency::first();
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$currency = TransactionCurrency::first();
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
$preference = new Preference;
|
||||
$preference->data = 'EUR';
|
||||
// mock calls:
|
||||
@@ -221,6 +226,7 @@ class CurrencyControllerTest extends TestCase
|
||||
{
|
||||
$currency = TransactionCurrency::first();
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
@@ -253,6 +259,7 @@ class CurrencyControllerTest extends TestCase
|
||||
{
|
||||
$currency = TransactionCurrency::first();
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$preference = new Preference;
|
||||
$preference->data = 'EUR';
|
||||
|
||||
|
@@ -29,12 +29,17 @@ use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Recurrence;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class RecurrenceControllerTest
|
||||
*/
|
||||
class RecurrenceControllerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
@@ -54,7 +59,9 @@ class RecurrenceControllerTest extends TestCase
|
||||
public function testDelete(): void
|
||||
{
|
||||
// mock stuff:
|
||||
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
@@ -77,7 +84,15 @@ class RecurrenceControllerTest extends TestCase
|
||||
$recurrences = $this->user()->recurrences()->get();
|
||||
|
||||
// mock stuff:
|
||||
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
|
||||
$budgetRepos->shouldReceive('findNull')->atLeast()->once()->withAnyArgs()
|
||||
->andReturn($this->user()->budgets()->first());
|
||||
|
||||
$piggyRepos->shouldReceive('findNull')->atLeast()->once()->withAnyArgs()
|
||||
->andReturn($this->user()->piggyBanks()->first());
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser');
|
||||
@@ -103,7 +118,12 @@ class RecurrenceControllerTest extends TestCase
|
||||
$recurrence = $this->user()->recurrences()->first();
|
||||
|
||||
// mock stuff:
|
||||
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
|
||||
$budgetRepos->shouldReceive('findNull')->atLeast()->once()->withAnyArgs()
|
||||
->andReturn($this->user()->budgets()->first());
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser');
|
||||
@@ -134,6 +154,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
|
||||
@@ -211,6 +232,8 @@ class RecurrenceControllerTest extends TestCase
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
|
||||
// mock calls:
|
||||
@@ -287,7 +310,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
|
||||
// mock calls:
|
||||
@@ -366,6 +389,8 @@ class RecurrenceControllerTest extends TestCase
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
|
||||
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
$expenseAccount = $this->user()->accounts()->where('account_type_id', 4)->first();
|
||||
@@ -447,6 +472,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
$expenseAccount = $this->user()->accounts()->where('account_type_id', 4)->first();
|
||||
@@ -526,6 +552,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
|
||||
@@ -617,6 +644,8 @@ class RecurrenceControllerTest extends TestCase
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
|
||||
// mock calls:
|
||||
@@ -691,6 +720,8 @@ class RecurrenceControllerTest extends TestCase
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
|
||||
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
|
||||
@@ -764,6 +795,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
|
||||
@@ -851,6 +883,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
|
||||
@@ -924,6 +957,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
|
||||
@@ -997,6 +1031,8 @@ class RecurrenceControllerTest extends TestCase
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
|
||||
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
|
||||
@@ -1070,6 +1106,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
|
||||
@@ -1143,6 +1180,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
|
||||
@@ -1216,6 +1254,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser');
|
||||
@@ -1286,6 +1325,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser');
|
||||
@@ -1359,6 +1399,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser');
|
||||
@@ -1436,6 +1477,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
|
||||
@@ -1501,6 +1543,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
|
||||
@@ -1564,6 +1607,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
$otherAssetAccount = $this->user()->accounts()->where('account_type_id', 3)->where('id', '!=', $assetAccount->id)->first();
|
||||
@@ -1644,6 +1688,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
|
||||
|
@@ -56,13 +56,13 @@ class UserControllerTest extends TestCase
|
||||
*/
|
||||
public function testDelete(): void
|
||||
{
|
||||
$userRepository = $this->mock(UserRepositoryInterface::class);
|
||||
$userRepository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||
$userRepository->shouldReceive('destroy')->once();
|
||||
// create a user first:
|
||||
$user = User::create(['email' => 'some@newu' . random_int(1, 10000) . 'ser.nl', 'password' => 'hello', 'blocked' => 0]);
|
||||
|
||||
// call API
|
||||
$response = $this->delete('/api/v1/users/' . $user->id);
|
||||
$response = $this->delete('/api/v1/users/' . $this->user()->id);
|
||||
$response->assertStatus(204);
|
||||
$this->assertDatabaseMissing('users', ['id' => $user->id]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,6 +73,8 @@ class UserControllerTest extends TestCase
|
||||
*/
|
||||
public function testDeleteNoAdmin(): void
|
||||
{
|
||||
$userRepository = $this->mock(UserRepositoryInterface::class);
|
||||
$userRepository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(false);
|
||||
Passport::actingAs($this->emptyUser());
|
||||
|
||||
// create a user first:
|
||||
|
Reference in New Issue
Block a user