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

(-)a/t/db_dependent/Koha/Template/Plugin/Registers.t (-6 / +15 lines)
Lines 70-75 subtest 'all() tests' => sub { Link Here
70
70
71
    $schema->storage->txn_begin;
71
    $schema->storage->txn_begin;
72
72
73
    my $count = Koha::Cash::Registers->search({ archived => 0 })->count;
74
    my $max_register = Koha::Cash::Registers->search( {},
75
        { order_by => { '-desc' => 'id' }, rows => 1 } )->single;
76
    my $max_id = $max_register ? $max_register->id : 0;
77
73
    my $library1 = $builder->build_object(
78
    my $library1 = $builder->build_object(
74
        {
79
        {
75
            class => 'Koha::Libraries'
80
            class => 'Koha::Libraries'
Lines 80-86 subtest 'all() tests' => sub { Link Here
80
            class => 'Koha::Cash::Registers',
85
            class => 'Koha::Cash::Registers',
81
            value => {
86
            value => {
82
                branch         => $library1->branchcode,
87
                branch         => $library1->branchcode,
83
                branch_default => 0
88
                branch_default => 0,
89
                archived       => 0
84
            }
90
            }
85
        }
91
        }
86
    );
92
    );
Lines 89-95 subtest 'all() tests' => sub { Link Here
89
            class => 'Koha::Cash::Registers',
95
            class => 'Koha::Cash::Registers',
90
            value => {
96
            value => {
91
                branch         => $library1->branchcode,
97
                branch         => $library1->branchcode,
92
                branch_default => 1
98
                branch_default => 1,
99
                archived       => 0
93
            }
100
            }
94
        }
101
        }
95
    );
102
    );
Lines 103-109 subtest 'all() tests' => sub { Link Here
103
        {
110
        {
104
            class => 'Koha::Cash::Registers',
111
            class => 'Koha::Cash::Registers',
105
            value => {
112
            value => {
106
                branch => $library2->branchcode
113
                branch => $library2->branchcode,
114
                archived       => 0
107
            }
115
            }
108
        }
116
        }
109
    );
117
    );
Lines 114-121 subtest 'all() tests' => sub { Link Here
114
    my $result = $plugin->all;
122
    my $result = $plugin->all;
115
    is( ref($result), 'ARRAY', "Return arrayref (no userenv, no filters)" );
123
    is( ref($result), 'ARRAY', "Return arrayref (no userenv, no filters)" );
116
    is( scalar( @{$result} ),
124
    is( scalar( @{$result} ),
117
        3, "Array contains all 3 registers (no userenv, no filters)" );
125
        3 + $count, "Array contains all test registers (no userenv, no filters)" );
118
    for my $register ( @{$result} ) {
126
    for my $register ( @{$result} ) {
127
        next if $register->{id} <= $max_id;
119
        is( $register->{selected}, 0, "Register is not selected (no userenv)" );
128
        is( $register->{selected}, 0, "Register is not selected (no userenv)" );
120
    }
129
    }
121
130
Lines 128-135 subtest 'all() tests' => sub { Link Here
128
    is( ref($result), 'ARRAY',
137
    is( ref($result), 'ARRAY',
129
        "Return arrayref (userenv: branchcode, no filters)" );
138
        "Return arrayref (userenv: branchcode, no filters)" );
130
    is( scalar( @{$result} ),
139
    is( scalar( @{$result} ),
131
        3, "Array contains all 3 registers (userenv: branchcode, no filters)" );
140
        3 + $count, "Array contains all test registers (userenv: branchcode, no filters)" );
132
    for my $register ( @{$result} ) {
141
    for my $register ( @{$result} ) {
142
        next if $register->{id} <= $max_id;
133
        is( $register->{selected}, 0,
143
        is( $register->{selected}, 0,
134
            "Register is not selected (userenv: branchcode, no filters)" );
144
            "Register is not selected (userenv: branchcode, no filters)" );
135
    }
145
    }
136
- 

Return to bug 24786