From: Sven Schöling Date: Wed, 23 Feb 2011 16:46:47 +0000 (+0100) Subject: One-To-One dispatch test. X-Git-Tag: release-2.7.0beta1~396^2~75 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=417cc3a7e5d4a96713b71b1d723196bddeeb01cc;p=kivitendo-erp.git One-To-One dispatch test. --- diff --git a/SL/Helper/Csv/Dispatcher.pm b/SL/Helper/Csv/Dispatcher.pm index e060f8254..3b6044342 100644 --- a/SL/Helper/Csv/Dispatcher.pm +++ b/SL/Helper/Csv/Dispatcher.pm @@ -35,7 +35,7 @@ sub apply { my ($acc, $class) = @$step; if ($class) { eval "require $class; 1" or die "could not load class '$class'"; - $obj->$acc($class->new) if ! $$obj->$acc; + $obj->$acc($class->new) if ! $obj->$acc; $obj = $obj->$acc; } else { $obj->$acc($value); @@ -74,7 +74,7 @@ sub make_spec { for my $step ( split /\./, $path ) { if ($cur_class->can($step)) { if ($cur_class->meta->relationship($step)) { #a - my $next_class = $cur_class->meta->relationsship($step)->class; + my $next_class = $cur_class->meta->relationship($step)->class; push @{ $spec->{steps} }, [ $step, $next_class ]; $cur_class = $next_class; } else { # simple dispatch diff --git a/t/helper/csv.t b/t/helper/csv.t index 2a58cabee..58d2d55d9 100644 --- a/t/helper/csv.t +++ b/t/helper/csv.t @@ -140,6 +140,24 @@ EOL $csv->parse; is $csv->get_objects->[0]->lastcost, '1221.52', 'ignore_unkown_columns works'; +##### + +$csv = SL::Helper::Csv->new( + file => \< '1,000.00', + class => 'SL::DB::Part', + profile => { + buchungsgruppe => "buchungsgruppen.description", + } +); +$csv->parse; +isa_ok $csv->get_objects->[0]->buchungsgruppe, 'SL::DB::Buchungsgruppe', 'deep dispatch auto vivify works'; +is $csv->get_objects->[0]->buchungsgruppe->description, 'Standard 7%', '...and gets set correctly'; + done_testing(); # vim: ft=perl