@@ -119,9 +119,24 @@ public function testImport()
119119 {
120120 $ records = $ this ->porter ->import ($ this ->specification );
121121
122+ self ::assertInstanceOf (PorterRecords::class, $ records );
123+ self ::assertNotSame ($ this ->specification , $ records ->getSpecification ());
124+ self ::assertInstanceOf (CountableProviderRecords::class, $ records ->getPreviousCollection ());
125+ self ::assertSame ('foo ' , $ records ->current ());
126+ }
127+
128+ public function testNonCountableIteratorImport ()
129+ {
130+ $ this ->provider ->shouldReceive ('fetch ' )->andReturnUsing (function () {
131+ yield 'foo ' ;
132+ });
133+
134+ $ records = $ this ->porter ->import ($ this ->specification );
135+
122136 self ::assertInstanceOf (PorterRecords::class, $ records );
123137 self ::assertNotSame ($ this ->specification , $ records ->getSpecification ());
124138 self ::assertInstanceOf (ProviderRecords::class, $ records ->getPreviousCollection ());
139+ self ::assertNotInstanceOf (CountableProviderRecords::class, $ records ->getPreviousCollection ());
125140 self ::assertSame ('foo ' , $ records ->current ());
126141 }
127142
@@ -145,6 +160,23 @@ public function testImportCountableRecords()
145160 self ::assertCount ($ count , $ records );
146161 }
147162
163+ public function testImportAndMapNonCountableRecords ()
164+ {
165+ $ iterateOne = function () {
166+ yield 'foo ' ;
167+ };
168+ $ records = $ this ->porter ->import (
169+ (new StaticDataImportSpecification (
170+ new ProviderRecords ($ iterateOne (), $ this ->resource )
171+ ))->setMapping (\Mockery::mock (Mapping::class))
172+ );
173+
174+ self ::assertInstanceOf (MappedRecords::class, $ records ->getPreviousCollection ());
175+ self ::assertInstanceOf (\Iterator::class, $ records );
176+ self ::assertNotInstanceOf (CountableMappedRecords::class, $ records ->getPreviousCollection ());
177+ self ::assertNotInstanceOf (\Countable::class, $ records );
178+ }
179+
148180 /**
149181 * Tests that when the resource is countable the count is propagated to the outermost collection via a mapped
150182 * collection.
0 commit comments