From 417cc3a7e5d4a96713b71b1d723196bddeeb01cc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Wed, 23 Feb 2011 17:46:47 +0100 Subject: [PATCH] One-To-One dispatch test. --- SL/Helper/Csv/Dispatcher.pm | 4 ++-- t/helper/csv.t | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) 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 -- 2.20.1