View | Details | Raw Unified | Return to bug 10762
Collapse All | Expand All

(-)a/t/db_dependent/Labels/t_Layout.t (-25 / +31 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 40;
22
use Test::More tests => 58;
23
use C4::Context;
23
use C4::Context;
24
24
25
BEGIN {
25
BEGIN {
Lines 59-79 foreach my $key (keys %{$default_layout}) { Link Here
59
59
60
# Testing Layout->set_attr()
60
# Testing Layout->set_attr()
61
my $new_attr = {
61
my $new_attr = {
62
        creator         =>      'Labels',
62
    barcode_type  => 'CODE39',
63
        layout_xml      =>      '',
63
    callnum_split => 1,
64
        units           =>      'POINT',
64
    creator       => 'Labels',
65
        start_label     =>      1,
65
    font          => 'TR',
66
        barcode_type    =>      'CODE39',
66
    font_size     => 10,
67
        printing_type   =>      'BIBBAR',
67
    format_string => 'callnumber, title, author, barcode',
68
        layout_name     =>      'TEST',
68
    guidebox      => 1,
69
        guidebox        =>      1,
69
    layout_name   => 'TEST',
70
        oblique_title   =>      0,
70
    layout_xml    => '',
71
        font            =>      'TR',
71
    oblique_title => 0,
72
        font_size       =>      10,
72
    printing_type => 'BIBBAR',
73
        callnum_split   =>      1,
73
    scale_height  => 0.02,
74
        text_justify    =>      'L',
74
    scale_width   => 0.9,
75
        format_string   =>      'callnumber, title, author, barcode',
75
    start_label   => 1,
76
    };
76
    text_justify  => 'L',
77
    units         => 'POINT',
78
};
77
79
78
foreach my $key (keys %{$new_attr}) {
80
foreach my $key (keys %{$new_attr}) {
79
    $layout->set_attr($key => $new_attr->{$key});
81
    $layout->set_attr($key => $new_attr->{$key});
Lines 81-99 foreach my $key (keys %{$new_attr}) { Link Here
81
        "Layout->set_attr() success on attribute $key.");
83
        "Layout->set_attr() success on attribute $key.");
82
}
84
}
83
85
84
85
# Testing Layout->save() method with a new object
86
# Testing Layout->save() method with a new object
86
my $sav_results = $layout->save();
87
my $sav_results = $layout->save();
87
ok($sav_results ne -1, "Layout->save() success");
88
ok($sav_results ne -1, "Layout->save() success");
88
89
89
my $saved_layout;
90
my $saved_layout;
90
if ($sav_results ne -1) {
91
# Testing Layout->retrieve()
91
    # Testing Layout->retrieve()
92
$new_attr->{'layout_id'} = $sav_results;
92
    $new_attr->{'layout_id'} = $sav_results;
93
ok($saved_layout = C4::Labels::Layout->retrieve(layout_id => $sav_results),
93
    ok($saved_layout = C4::Labels::Layout->retrieve(layout_id => $sav_results),
94
    "Layout->retrieve() success");
94
        "Layout->retrieve() success");
95
95
    is_deeply($saved_layout, $new_attr,
96
foreach my $key ( keys %{$new_attr} ) {
96
        "Retrieved layout object is the expected");
97
    if ( $key eq 'scale_height' || $key eq 'scale_width' ) {
98
        # workaround for is_deeply failing to compare scale_height and scale_width
99
        is( $saved_layout->{$key} + 0.00, $new_attr->{$key} );
100
    }
101
    else {
102
        is( $saved_layout->{$key}, $new_attr->{$key} );
103
    }
97
}
104
}
98
105
99
# Testing Layout->save() method with an updated object
106
# Testing Layout->save() method with an updated object
100
- 

Return to bug 10762