. */ declare(strict_types=1); namespace Tests\Unit\Import\Mapper; use FireflyIII\Import\Mapper\AssetAccounts; use FireflyIII\Models\Account; use FireflyIII\Models\AccountType; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use Illuminate\Support\Collection; use Log; use Tests\TestCase; /** * Class AssetAccountsTest */ class AssetAccountsTest extends TestCase { /** * */ public function setUp(): void { parent::setUp(); Log::info(sprintf('Now in %s.', \get_class($this))); } /** * @covers \FireflyIII\Import\Mapper\AssetAccounts */ public function testGetMapBasic(): void { $asset = AccountType::where('type', AccountType::ASSET)->first(); $loan = AccountType::where('type', AccountType::LOAN)->first(); $one = new Account; $one->id = 23; $one->name = 'Something'; $one->iban = 'IBAN'; $one->account_type_id = $asset->id; $two = new Account; $two->id = 19; $two->name = 'Else'; $two->account_type_id = $loan->id; $collection = new Collection([$one, $two]); $repository = $this->mock(AccountRepositoryInterface::class); $repository->shouldReceive('getAccountsByType')->withArgs( [[AccountType::DEFAULT, AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::CREDITCARD, AccountType::MORTGAGE,]] )->andReturn($collection)->once(); $mapper = new AssetAccounts(); $mapping = $mapper->getMap(); $this->assertCount(3, $mapping); // assert this is what the result looks like: $result = [ 0 => (string)trans('import.map_do_not_map'), 19 => 'Liability: Else', 23 => 'Something (IBAN)', ]; $this->assertEquals($result, $mapping); } }