my %types = map { $_->name => $_->type } ref($self)->meta->columns;
- # Special case for *_as_man_days/*_as_man_days_unit: the _unit
- # variation must always be called after the non-unit method.
- my @man_days_attributes = grep { m/_as_man_days$/ } keys %attributes;
+ # Special case for *_as_man_days / *_as_man_days_string /
+ # *_as_man_days_unit: the _unit variation must always be called
+ # after the non-unit methods.
+ my @man_days_attributes = grep { m/_as_man_days(?:_string)?$/ } keys %attributes;
foreach my $attribute (@man_days_attributes) {
my $value = delete $attributes{$attribute};
$self->$attribute(defined($value) && ($value eq '') ? undef : $value);
package main;
-use Test::More tests => 83;
+use Test::More tests => 91;
use Test::Exception;
use strict;
is(new_item->assign_attributes('dummy_as_man_days', 3, 'dummy_as_man_days_unit', 'man_day')->dummy, 24, 'assign_attributes array 3man_day');
is(new_item->assign_attributes('dummy_as_man_days_unit', 'man_day', 'dummy_as_man_days', 3 )->dummy, 24, 'assign_attributes array man_day3');
+is(new_item->assign_attributes(dummy_as_man_days_string => '5,25', dummy_as_man_days_unit => 'h' )->dummy, 5.25, 'assign_attributes hash string 5,25h');
+is(new_item->assign_attributes(dummy_as_man_days_unit => 'h', dummy_as_man_days_string => '5,25')->dummy, 5.25, 'assign_attributes hash string h5,25');
+
+is(new_item->assign_attributes(dummy_as_man_days_string => '5,25', dummy_as_man_days_unit => 'man_day')->dummy, 42, 'assign_attributes hash string 5,25man_day');
+is(new_item->assign_attributes(dummy_as_man_days_unit => 'man_day', dummy_as_man_days_string => '5,25' )->dummy, 42, 'assign_attributes hash string man_day5,25');
+
+is(new_item->assign_attributes('dummy_as_man_days_string', '5,25', 'dummy_as_man_days_unit', 'h' )->dummy, 5.25, 'assign_attributes array 5,25h');
+is(new_item->assign_attributes('dummy_as_man_days_unit', 'h', 'dummy_as_man_days_string', '5,25')->dummy, 5.25, 'assign_attributes array h5,25');
+
+is(new_item->assign_attributes('dummy_as_man_days_string', '5,25', 'dummy_as_man_days_unit', 'man_day')->dummy, 42, 'assign_attributes array 5,25man_day');
+is(new_item->assign_attributes('dummy_as_man_days_unit', 'man_day', 'dummy_as_man_days_string', '5,25' )->dummy, 42, 'assign_attributes array man_day5,25');
+
# Parametervalidierung
throws_ok { new_item()->dummy_as_man_days_unit('invalid') } qr/unknown.*unit/i, 'unknown unit';
lives_ok { new_item()->dummy_as_man_days_unit('h') } 'known unit h';