Revision 90af0ce7
Von Sven Schöling vor mehr als 13 Jahren hinzugefügt
t/helper/csv.t | ||
---|---|---|
1 |
use Test::More; |
|
1 |
use Test::More tests => 29;
|
|
2 | 2 |
use SL::Dispatcher; |
3 |
use Data::Dumper; |
|
3 | 4 |
use utf8; |
4 | 5 |
|
5 | 6 |
use_ok 'SL::Helper::Csv'; |
... | ... | |
159 | 160 |
is $csv->get_objects->[0]->buchungsgruppe->description, 'Standard 7%', '...and gets set correctly'; |
160 | 161 |
|
161 | 162 |
|
162 |
done_testing(); |
|
163 |
##### |
|
164 |
|
|
165 |
$csv = SL::Helper::Csv->new( |
|
166 |
file => \<<EOL, |
|
167 |
description;partnumber;sellprice;lastcost_as_number;make_1;model_1; |
|
168 |
Kaffee;;0.12;1,221.52;213;Chair 0815 |
|
169 |
Beer;1123245;0.12;1.5234; |
|
170 |
EOL |
|
171 |
numberformat => '1,000.00', |
|
172 |
class => 'SL::DB::Part', |
|
173 |
profile => { |
|
174 |
make_1 => "makemodels.0.make", |
|
175 |
model_1 => "makemodels.0.model", |
|
176 |
} |
|
177 |
); |
|
178 |
$csv->parse; |
|
179 |
my @mm = $csv->get_objects->[0]->makemodel; |
|
180 |
is scalar @mm, 1, 'one-to-many dispatch'; |
|
181 |
is $csv->get_objects->[0]->makemodels->[0]->model, 'Chair 0815', '... and works'; |
|
182 |
|
|
183 |
##### |
|
184 |
|
|
185 |
|
|
186 |
$csv = SL::Helper::Csv->new( |
|
187 |
file => \<<EOL, |
|
188 |
description;partnumber;sellprice;lastcost_as_number;make_1;model_1;make_2;model_2; |
|
189 |
Kaffee;;0.12;1,221.52;213;Chair 0815;523;Table 15 |
|
190 |
EOL |
|
191 |
numberformat => '1,000.00', |
|
192 |
class => 'SL::DB::Part', |
|
193 |
profile => { |
|
194 |
make_1 => "makemodels.0.make", |
|
195 |
model_1 => "makemodels.0.model", |
|
196 |
make_2 => "makemodels.1.make", |
|
197 |
model_2 => "makemodels.1.model", |
|
198 |
} |
|
199 |
); |
|
200 |
$csv->parse; |
|
201 |
|
|
202 |
print Dumper($csv->errors); |
|
203 |
|
|
204 |
my @mm = $csv->get_objects->[0]->makemodel; |
|
205 |
is scalar @mm, 1, 'multiple one-to-many dispatch'; |
|
206 |
is $csv->get_objects->[0]->makemodels->[0]->model, 'Chair 0815', '...check 1'; |
|
207 |
is $csv->get_objects->[0]->makemodels->[0]->make, '213', '...check 2'; |
|
208 |
is $csv->get_objects->[0]->makemodels->[1]->model, 'Table 15', '...check 3'; |
|
209 |
is $csv->get_objects->[0]->makemodels->[1]->make, '523', '...check 4'; |
|
210 |
|
|
163 | 211 |
# vim: ft=perl |
Auch abrufbar als: Unified diff
Multiple Dispatch - one-to-many.