22
33namespace BayAreaWebPro \SimpleCsv \Tests \Unit ;
44
5+ use BayAreaWebPro \SimpleCsv \LazyCsvCollection ;
56use Symfony \Component \HttpFoundation \StreamedResponse ;
67
78use Illuminate \Support \LazyCollection ;
@@ -34,6 +35,23 @@ private function getRandomStoragePath()
3435 return storage_path (Str::random (16 ) . '.csv ' );
3536 }
3637
38+ public function test_imported_lazy_collection_methods ()
39+ {
40+ $ collection = new LazyCsvCollection (LazyGenerator::make (5 , function () {
41+ return ['null_field_exported_empty ' => '' ];
42+ }));
43+ foreach ($ collection as $ row ){
44+ $ this ->assertNotNull ($ row ['null_field_exported_empty ' ]);
45+ }
46+
47+ $ collection = new LazyCsvCollection (LazyGenerator::make (5 , function () {
48+ return ['null_field_exported_empty ' => '' ];
49+ }));
50+ foreach ($ collection ->emptyToNull () as $ row ){
51+ $ this ->assertNull ($ row ['null_field_exported_empty ' ]);
52+ }
53+ }
54+
3755 public function test_export_from_iterables ()
3856 {
3957 $ items = $ this ->getCollectionData (10 )->toArray ();
@@ -75,7 +93,8 @@ public function test_export_files_and_restore()
7593 }
7694
7795 $ decoded = SimpleCsv::import ($ path );
78- $ this ->assertTrue ($ decoded instanceof LazyCollection);
96+ $ this ->assertInstanceOf (LazyCollection::class, $ decoded );
97+
7998 foreach ($ decoded as $ decodedItem ) {
8099 $ this ->assertStringContainsString ($ decodedItem ['email ' ], $ fileData );
81100 }
@@ -89,7 +108,7 @@ public function test_can_download_streams()
89108
90109 $ response = SimpleCsv::download ($ collectionLazy , 'download.csv ' );
91110
92- $ this ->assertTrue ( $ response instanceof StreamedResponse );
111+ $ this ->assertInstanceOf (StreamedResponse::class, $ response );
93112
94113 //Capture Streamed Output...
95114 ob_start ();
0 commit comments