. */ declare(strict_types=1); namespace Tests\Unit\Import\Mapper; use FireflyIII\Import\Mapper\Bills; use FireflyIII\Models\Bill; use FireflyIII\Repositories\Bill\BillRepositoryInterface; use Illuminate\Support\Collection; use Log; use Tests\TestCase; /** * Class BillsTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.TooManyPublicMethods) */ class BillsTest extends TestCase { /** * */ public function setUp(): void { parent::setUp(); Log::info(sprintf('Now in %s.', get_class($this))); } /** * @covers \FireflyIII\Import\Mapper\Bills */ public function testGetMapBasic(): void { $one = new Bill; $one->id = 5; $one->name = 'Something'; $one->match = 'hi,bye'; $two = new Bill; $two->id = 9; $two->name = 'Else'; $two->match = 'match'; $collection = new Collection([$one, $two]); $repository = $this->mock(BillRepositoryInterface::class); $repository->shouldReceive('getBills')->andReturn($collection)->once(); $mapper = new Bills(); $mapping = $mapper->getMap(); $this->assertCount(3, $mapping); // assert this is what the result looks like: $result = [ 0 => (string)trans('import.map_do_not_map'), 9 => 'Else', 5 => 'Something', ]; $this->assertEquals($result, $mapping); } }