@@ -61,7 +61,7 @@ public function testIgnoreRow()
61
61
{
62
62
LoadFile::file (realpath (__DIR__ . '/../data/people.csv ' ), true )
63
63
->into ('people ' )
64
- ->ignore (1 )
64
+ ->ignoreLines (1 )
65
65
->columns ([DB ::raw ('@forename ' ), DB ::raw ('@surname ' ), 'dob ' ])
66
66
->set ([
67
67
'greeting ' => 'Hello ' ,
@@ -83,4 +83,48 @@ public function testIgnoreRow()
83
83
'greeting ' => 'Hello ' ,
84
84
]);
85
85
}
86
+
87
+ public function testReplace ()
88
+ {
89
+ LoadFile::file (realpath (__DIR__ . '/../data/people-simple.csv ' ), true )
90
+ ->replace ()
91
+ ->into ('people ' )
92
+ ->columns (['name ' , 'dob ' , 'greeting ' ])
93
+ ->fields (', ' , '" ' , '\\\\' , true )
94
+ ->load ();
95
+
96
+ $ this ->assertDatabaseHas ('people ' , [
97
+ 'name ' => 'John Doe ' ,
98
+ 'dob ' => '1980-01-01 ' ,
99
+ 'greeting ' => 'Bonjour ' ,
100
+ ]);
101
+
102
+ $ this ->assertDatabaseHas ('people ' , [
103
+ 'name ' => 'Jane Doe ' ,
104
+ 'dob ' => '1975-06-30 ' ,
105
+ 'greeting ' => 'Hello ' ,
106
+ ]);
107
+ }
108
+
109
+ public function testIgnore ()
110
+ {
111
+ LoadFile::file (realpath (__DIR__ . '/../data/people-simple.csv ' ), true )
112
+ ->ignore ()
113
+ ->into ('people ' )
114
+ ->columns (['name ' , 'dob ' , 'greeting ' ])
115
+ ->fields (', ' , '" ' , '\\\\' , true )
116
+ ->load ();
117
+
118
+ $ this ->assertDatabaseHas ('people ' , [
119
+ 'name ' => 'John Doe ' ,
120
+ 'dob ' => '1980-01-01 ' ,
121
+ 'greeting ' => 'Bonjour ' ,
122
+ ]);
123
+
124
+ $ this ->assertDatabaseHas ('people ' , [
125
+ 'name ' => 'Jane Doe ' ,
126
+ 'dob ' => '1975-06-30 ' ,
127
+ 'greeting ' => 'Hello ' ,
128
+ ]);
129
+ }
86
130
}
0 commit comments