Lines 19-27
use Modern::Perl;
Link Here
|
19 |
|
19 |
|
20 |
use C4::Context; |
20 |
use C4::Context; |
21 |
|
21 |
|
22 |
use Test::More tests => 3; |
22 |
use Test::More tests => 4; |
|
|
23 |
use Test::MockModule; |
23 |
|
24 |
|
24 |
use C4::Context; |
25 |
use C4::Context; |
|
|
26 |
use C4::Biblio qw( AddBiblio ); |
27 |
use C4::Circulation; |
25 |
use Koha::AuthUtils; |
28 |
use Koha::AuthUtils; |
26 |
use t::lib::Selenium; |
29 |
use t::lib::Selenium; |
27 |
use t::lib::TestBuilder; |
30 |
use t::lib::TestBuilder; |
Lines 113-120
subtest 'Play sound on the circulation page' => sub {
Link Here
|
113 |
push @cleanup, $patron, $patron->category, $patron->library; |
116 |
push @cleanup, $patron, $patron->category, $patron->library; |
114 |
}; |
117 |
}; |
115 |
|
118 |
|
|
|
119 |
subtest 'Display circulation table correctly' => sub { |
120 |
plan tests => 1; |
121 |
|
122 |
my $builder = t::lib::TestBuilder->new; |
123 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
124 |
my $patron = $builder->build_object( |
125 |
{ |
126 |
class => 'Koha::Patrons', |
127 |
value => { branchcode => $library->branchcode, flags => 0 } |
128 |
} |
129 |
); |
130 |
|
131 |
my ( $biblionumber, $biblioitemnumber ) = add_biblio(); |
132 |
my $item = $builder->build_object( |
133 |
{ |
134 |
class => 'Koha::Items', |
135 |
value => { |
136 |
biblionumber => $biblionumber, |
137 |
homebranch => $library->branchcode, |
138 |
holdingbranch => $library->branchcode, |
139 |
notforloan => 0, |
140 |
itemlost => 0, |
141 |
withdrawn => 0, |
142 |
} |
143 |
} |
144 |
); |
145 |
my $context = Test::MockModule->new('C4::Context'); |
146 |
$context->mock( |
147 |
'userenv', |
148 |
sub { |
149 |
return { branch => $library->branchcode }; |
150 |
} |
151 |
); |
152 |
|
153 |
C4::Circulation::AddIssue( $patron->unblessed, $item->barcode ); |
154 |
|
155 |
my $mainpage = $s->base_url . q|mainpage.pl|; |
156 |
$driver->get($mainpage . q|?logout.x=1|); |
157 |
$s->auth; |
158 |
|
159 |
$driver->get( $base_url |
160 |
. "/circ/circulation.pl?borrowernumber=" |
161 |
. $patron->borrowernumber ); |
162 |
|
163 |
# Display the table clicking on the "Show checkouts" button |
164 |
$driver->find_element('//a[@id="issues-table-load-now-button"]')->click; |
165 |
|
166 |
my @thead_th = $driver->find_elements('//table[@id="issues-table"]/thead/tr/th'); |
167 |
my $thead_length = 0; |
168 |
$thead_length += $_->get_attribute('colspan') || 0 for @thead_th; |
169 |
|
170 |
my @tfoot_td = $driver->find_elements('//table[@id="issues-table"]/tfoot/tr/td'); |
171 |
my $tfoot_length = 0; |
172 |
$tfoot_length += $_->get_attribute('colspan') || 0 for @tfoot_td; |
173 |
|
174 |
my @tbody_td = $driver->find_elements('//table[@id="issues-table"]/tbody/tr/td'); |
175 |
my $tbody_length = 0; |
176 |
$tbody_length += $_->get_attribute('colspan') || 0 for @tbody_td; |
177 |
|
178 |
is( $thead_length == $tfoot_length && $tfoot_length == $tbody_length, |
179 |
1, "Checkouts table must be correctly aligned" ) |
180 |
or diag( |
181 |
"thead: $thead_length ; tfoot: $tfoot_length ; tbody: $tbody_length"); |
182 |
|
183 |
push @cleanup, $patron->checkouts, $item->biblio, $item, $patron, |
184 |
$patron->category, $library; |
185 |
}; |
186 |
|
116 |
END { |
187 |
END { |
117 |
C4::Context->preference('SearchEngine', $SearchEngine_value); |
188 |
C4::Context->preference('SearchEngine', $SearchEngine_value); |
118 |
C4::Context->preference('AudioAlerts', $AudioAlerts_value); |
189 |
C4::Context->preference('AudioAlerts', $AudioAlerts_value); |
119 |
$_->delete for @cleanup; |
190 |
$_->delete for @cleanup; |
120 |
}; |
191 |
}; |
121 |
- |
192 |
|
|
|
193 |
sub add_biblio { |
194 |
my ($title, $author) = @_; |
195 |
|
196 |
my $marcflavour = C4::Context->preference('marcflavour'); |
197 |
|
198 |
my $biblio = MARC::Record->new(); |
199 |
my ( $tag, $code ); |
200 |
$tag = $marcflavour eq 'UNIMARC' ? '200' : '245'; |
201 |
$biblio->append_fields( |
202 |
MARC::Field->new($tag, ' ', ' ', a => $title || 'a title'), |
203 |
); |
204 |
|
205 |
($tag, $code) = $marcflavour eq 'UNIMARC' ? (200, 'f') : (100, 'a'); |
206 |
$biblio->append_fields( |
207 |
MARC::Field->new($tag, ' ', ' ', $code => $author || 'an author'), |
208 |
); |
209 |
|
210 |
return C4::Biblio::AddBiblio($biblio, ''); |
211 |
} |
212 |
|