Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 417cc3a7

Von Sven Schöling vor mehr als 13 Jahren hinzugefügt

  • ID 417cc3a7e5d4a96713b71b1d723196bddeeb01cc
  • Vorgänger 17d58914
  • Nachfolger 8a635325

One-To-One dispatch test.

Unterschiede anzeigen:

SL/Helper/Csv/Dispatcher.pm
35 35
    my ($acc, $class) = @$step;
36 36
    if ($class) {
37 37
      eval "require $class; 1" or die "could not load class '$class'";
38
      $obj->$acc($class->new) if ! $$obj->$acc;
38
      $obj->$acc($class->new) if ! $obj->$acc;
39 39
      $obj = $obj->$acc;
40 40
    } else {
41 41
      $obj->$acc($value);
......
74 74
  for my $step ( split /\./, $path ) {
75 75
    if ($cur_class->can($step)) {
76 76
      if ($cur_class->meta->relationship($step)) { #a
77
        my $next_class = $cur_class->meta->relationsship($step)->class;
77
        my $next_class = $cur_class->meta->relationship($step)->class;
78 78
        push @{ $spec->{steps} }, [ $step, $next_class ];
79 79
        $cur_class = $next_class;
80 80
      } else { # simple dispatch
t/helper/csv.t
140 140
$csv->parse;
141 141
is $csv->get_objects->[0]->lastcost, '1221.52', 'ignore_unkown_columns works';
142 142

  
143
#####
144

  
145
$csv = SL::Helper::Csv->new(
146
  file   => \<<EOL,
147
description;partnumber;sellprice;lastcost_as_number;buchungsgruppe;
148
Kaffee;;0.12;1,221.52;Standard 7%
149
Beer;1123245;0.12;1.5234;16 %
150
EOL
151
  numberformat => '1,000.00',
152
  class  => 'SL::DB::Part',
153
  profile => {
154
    buchungsgruppe => "buchungsgruppen.description",
155
  }
156
);
157
$csv->parse;
158
isa_ok $csv->get_objects->[0]->buchungsgruppe, 'SL::DB::Buchungsgruppe', 'deep dispatch auto vivify works';
159
is $csv->get_objects->[0]->buchungsgruppe->description, 'Standard 7%', '...and gets set correctly';
160

  
143 161

  
144 162
done_testing();
145 163
# vim: ft=perl

Auch abrufbar als: Unified diff