From c616c9090b5e839938707d1ca3bf70b2de46b858 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Thu, 2 Sep 2010 11:51:44 +0200 Subject: [PATCH] AttrHelper Tests. --- t/helper/attr.t | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 t/helper/attr.t diff --git a/t/helper/attr.t b/t/helper/attr.t new file mode 100644 index 000000000..9f91865a4 --- /dev/null +++ b/t/helper/attr.t @@ -0,0 +1,40 @@ +use Test::More tests => 25; + +use DateTime; + +use_ok 'SL::DB::Part'; +use_ok 'SL::DB::Order'; +use_ok 'SL::Dispatcher'; + +SL::Dispatcher::pre_startup_setup(); + +$::form = Form->new; +$::myconfig{numberformat} = '1.000,00'; +$::myconfig{dateformat} = 'dd.mm.yyyy'; +$::locale = Locale->new('de'); + +my $p = new_ok 'SL::DB::Part'; +is($p->sellprice_as_number('2,30'), '2,30'); +is($p->sellprice, 2.30); +is($p->sellprice_as_number, '2,30'); +is($p->sellprice_as_number('2,3442'), '2,3442'); +is($p->sellprice, 2.3442); +is($p->sellprice_as_number, '2,3442'); + +my $o = new_ok 'SL::DB::Order'; +is($o->reqdate_as_date('11.12.2007'), '11.12.2007'); +is($o->reqdate->year, 2007); +is($o->reqdate->month, 12); +is($o->reqdate->day, 11); +is($o->reqdate_as_date, '11.12.2007'); +$o->reqdate(DateTime->new(year => 2010, month => 4, day => 12)); +is($o->reqdate_as_date, '12.04.2010'); + +is($o->marge_percent_as_percent('40'), '40,00'); +is($o->marge_percent, 0.40); +is($o->marge_percent_as_percent, '40,00'); +is($o->marge_percent_as_percent('22,4'), '22,40'); +is($o->marge_percent, 0.224); +is($o->marge_percent_as_percent, '22,40'); +is($o->marge_percent(0.231), 0.231); +is($o->marge_percent_as_percent, '23,10'); -- 2.20.1