Optimise tests

This commit is contained in:
James Cole
2020-08-01 05:34:32 +02:00
parent e0b71c316b
commit 57cb325639
3 changed files with 21 additions and 46 deletions

View File

@@ -62,13 +62,9 @@ class AccountFactoryTest extends TestCase
* @covers \FireflyIII\Services\Internal\Support\AccountServiceTrait
* @covers \FireflyIII\Services\Internal\Support\LocationServiceTrait
*/
public function testCreate(): void
public function testCreateNoMockery(): void
{
// mock repositories
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$metaFactory = $this->mock(AccountMetaFactory::class);
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
$euro = $this->getEuro();
$data = [
'account_type_id' => null,
'account_type' => 'asset',
@@ -79,16 +75,6 @@ class AccountFactoryTest extends TestCase
'account_role' => 'defaultAsset',
];
// no currency submitted means: find the EURO:
Amount::shouldReceive('getDefaultCurrencyByUser')->atLeast()->once()->andReturn($euro);
$currencyFactory->shouldReceive('find')->withArgs([0, ''])->atLeast()->once()->andReturnNull();
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'account_role', 'defaultAsset'])->atLeast()->once()->andReturnNull();
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'currency_id', '1'])->atLeast()->once()->andReturnNull();
// get opening balance group (null for new accounts)
$accountRepos->shouldReceive('getOpeningBalanceGroup')->atLeast()->once()->andReturn(null);
/** @var AccountFactory $factory */
$factory = app(AccountFactory::class);
$factory->setUser($this->user());