Lines 19-24
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
|
|
22 |
use Test::MockModule; |
22 |
use Test::More tests => 13; |
23 |
use Test::More tests => 13; |
23 |
use Test::Warn; |
24 |
use Test::Warn; |
24 |
use File::Basename qw(dirname); |
25 |
use File::Basename qw(dirname); |
Lines 84-90
subtest 'Build all sources' => sub {
Link Here
|
84 |
|
85 |
|
85 |
|
86 |
|
86 |
subtest 'Test length of some generated fields' => sub { |
87 |
subtest 'Test length of some generated fields' => sub { |
87 |
plan tests => 3; |
88 |
plan tests => 4; |
88 |
|
89 |
|
89 |
# Test the length of a returned character field |
90 |
# Test the length of a returned character field |
90 |
my $bookseller = $builder->build({ source => 'Aqbookseller' }); |
91 |
my $bookseller = $builder->build({ source => 'Aqbookseller' }); |
Lines 96-101
subtest 'Test length of some generated fields' => sub {
Link Here
|
96 |
|
97 |
|
97 |
my $item = $builder->build({ source => 'Item' }); |
98 |
my $item = $builder->build({ source => 'Item' }); |
98 |
is( $item->{replacementprice}, sprintf("%.2f", $item->{replacementprice}), "The number of decimals for floats should not be more than 2" ); |
99 |
is( $item->{replacementprice}, sprintf("%.2f", $item->{replacementprice}), "The number of decimals for floats should not be more than 2" ); |
|
|
100 |
|
101 |
subtest '_gen_real formatting' => sub { |
102 |
plan tests => 4; |
103 |
|
104 |
my $module = Test::MockModule->new('t::lib::TestBuilder'); |
105 |
$module->mock(_gen_real => sub { |
106 |
return '10.10'; |
107 |
}); |
108 |
$builder = t::lib::TestBuilder->new; |
109 |
|
110 |
my $accountline = $builder->build({ source => 'Accountline' }); |
111 |
is( $accountline->{amountoutstanding}, |
112 |
sprintf("%.6f", $accountline->{amountoutstanding}), |
113 |
"There can be more decimals when the column size allows it." ); |
114 |
|
115 |
my $rs = $schema->source('Accountline')->resultset; |
116 |
my $accountline_dbix = $rs->find($accountline->{accountlines_id}); |
117 |
is( $accountline->{amountoutstanding}, |
118 |
$accountline_dbix->amountoutstanding, |
119 |
"decimal - Builder builds same format as DBIx returns." ); |
120 |
|
121 |
my $aqorder = $builder->build({ source => 'Aqorder' }); |
122 |
$rs = $schema->source('Aqorder')->resultset; |
123 |
my $aqorder_dbix = $rs->find($aqorder->{ordernumber}); |
124 |
is( $aqorder->{discount}, $aqorder_dbix->discount, |
125 |
"float - Builder builds same precision as DBIx returns." ); |
126 |
|
127 |
my $statistic = $builder->build({ source => 'Statistic' }); |
128 |
$rs = $schema->source('Statistic')->resultset; |
129 |
my $statistic_dbix = $rs->search({ |
130 |
datetime => $statistic->{datetime} })->next; |
131 |
is( $statistic->{value}, $statistic_dbix->value, |
132 |
"double - Builder builds same precision as DBIx returns." ); |
133 |
|
134 |
$module->unmock('_gen_real'); |
135 |
$builder = t::lib::TestBuilder->new; |
136 |
}; |
99 |
}; |
137 |
}; |
100 |
|
138 |
|
101 |
|
139 |
|
102 |
- |
|
|