@@ -92,6 +92,28 @@ public function it_removes_unused_hash_columns()
92
92
$ this ->assertEquals ($ expected , $ actual );
93
93
}
94
94
95
+ /** @test */
96
+ public function it_maps_from_title_row ()
97
+ {
98
+ $ seeder = new \Flynsarmy \CsvSeeder \CsvSeeder ();
99
+ $ seeder ->table = 'tests_users ' ;
100
+
101
+ // First 3 columns of DB
102
+ $ actual = $ seeder ->createMappingFromRow (['id ' , 'first_name ' , 'last_name ' ]);
103
+ $ expected = [0 => 'id ' , 1 => 'first_name ' , 2 => 'last_name ' ];
104
+ $ this ->assertEquals ($ expected , $ actual );
105
+
106
+ // Random columns of DB
107
+ $ actual = $ seeder ->createMappingFromRow (['id ' , 'last_name ' , 'address ' ]);
108
+ $ expected = [0 => 'id ' , 1 => 'last_name ' , 2 => 'address ' ];
109
+ $ this ->assertEquals ($ expected , $ actual );
110
+
111
+ // Include a column that doesn't exist
112
+ $ actual = $ seeder ->createMappingFromRow (['id ' , 'last_name ' , 'this_col_doesnt_exist ' ]);
113
+ $ expected = [0 => 'id ' , 1 => 'last_name ' ];
114
+ $ this ->assertEquals ($ expected , $ actual );
115
+ }
116
+
95
117
/** @test */
96
118
public function it_reads_to_mapping_correctly ()
97
119
{
0 commit comments