mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-16 14:48:11 +00:00
Improve test coverage and efficiency for accounts and budgets.
This commit is contained in:
@@ -25,12 +25,11 @@ namespace Tests\Feature\Controllers\Budget;
|
||||
|
||||
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Log;
|
||||
use Mockery;
|
||||
use Preferences;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@@ -54,14 +53,13 @@ class CreateControllerTest extends TestCase
|
||||
*/
|
||||
public function testCreate(): void
|
||||
{
|
||||
Log::debug('Now in testCreate()');
|
||||
// mock stuff
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$this->mock(BudgetRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$this->mockDefaultSession();
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('budgets.create'));
|
||||
@@ -78,20 +76,20 @@ class CreateControllerTest extends TestCase
|
||||
{
|
||||
Log::debug('Now in testStore()');
|
||||
// mock stuff
|
||||
$budget = factory(Budget::class)->make();
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$budget = $this->getRandomBudget();
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('findNull')->andReturn($budget);
|
||||
$repository->shouldReceive('store')->andReturn($budget);
|
||||
$repository->shouldReceive('cleanupBudgets');
|
||||
|
||||
$this->mockDefaultSession();
|
||||
Preferences::shouldReceive('mark')->atLeast()->once();
|
||||
|
||||
$this->session(['budgets.create.uri' => 'http://localhost']);
|
||||
|
||||
$data = [
|
||||
'name' => 'New Budget ' . $this->randomInt(),
|
||||
'name' => sprintf('New Budget %s', $this->randomInt()),
|
||||
];
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('budgets.store'), $data);
|
||||
|
||||
Reference in New Issue
Block a user