Revision 76e3efe6
Von Sven Schöling vor etwa 13 Jahren hinzugefügt
t/helper/csv.t | ||
---|---|---|
9 | 9 |
$csv = SL::Helper::Csv->new( |
10 | 10 |
file => \"Kaffee\n", |
11 | 11 |
header => [ 'description' ], |
12 |
class => 'SL::DB::Part', |
|
12 | 13 |
); |
13 | 14 |
|
14 | 15 |
isa_ok $csv->_csv, 'Text::CSV_XS'; |
... | ... | |
16 | 17 |
isa_ok $csv->parse, 'SL::Helper::Csv', 'parsing returns self'; |
17 | 18 |
is_deeply $csv->get_data, [ { description => 'Kaffee' } ], 'simple case works'; |
18 | 19 |
|
19 |
$csv->class('SL::DB::Part'); |
|
20 | 20 |
|
21 | 21 |
is $csv->get_objects->[0]->description, 'Kaffee', 'get_object works'; |
22 | 22 |
#### |
23 | 23 |
|
24 |
SL::Dispatcher::pre_startup_setup(); |
|
24 |
{ |
|
25 |
no warnings 'once'; |
|
26 |
$::dispatcher = SL::Dispatcher->new; |
|
27 |
$::dispatcher->pre_startup_setup(); |
|
28 |
} |
|
25 | 29 |
|
26 | 30 |
$::form = Form->new; |
27 | 31 |
$::myconfig{numberformat} = '1.000,00'; |
... | ... | |
31 | 35 |
$csv = SL::Helper::Csv->new( |
32 | 36 |
file => \"Kaffee;0.12;12,2;1,5234\n", |
33 | 37 |
header => [ 'description', 'sellprice', 'lastcost_as_number', 'listprice' ], |
34 |
dispatch => { listprice => 'listprice_as_number' },
|
|
38 |
profile => { listprice => 'listprice_as_number' },
|
|
35 | 39 |
class => 'SL::DB::Part', |
36 | 40 |
); |
37 | 41 |
$csv->parse; |
... | ... | |
50 | 54 |
EOL |
51 | 55 |
sep_char => ',', |
52 | 56 |
quote_char => "'", |
53 |
dispatch => { listprice => 'listprice_as_number' },
|
|
57 |
profile => { listprice => 'listprice_as_number' },
|
|
54 | 58 |
class => 'SL::DB::Part', |
55 | 59 |
); |
56 | 60 |
$csv->parse; |
... | ... | |
202 | 206 |
|
203 | 207 |
print Dumper($csv->errors); |
204 | 208 |
|
205 |
my @mm = $csv->get_objects->[0]->makemodel;
|
|
209 |
@mm = $csv->get_objects->[0]->makemodel; |
|
206 | 210 |
is scalar @mm, 1, 'multiple one-to-many dispatch'; |
207 | 211 |
is $csv->get_objects->[0]->makemodels->[0]->model, 'Chair 0815', '...check 1'; |
208 | 212 |
is $csv->get_objects->[0]->makemodels->[0]->make, '213', '...check 2'; |
Auch abrufbar als: Unified diff
csv test updates.