Lines 1-30
Link Here
|
1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
|
|
2 |
|
3 |
# This file is part of Koha. |
4 |
# |
5 |
# Copyright 2014 - Koha Team |
6 |
# |
7 |
# Koha is free software; you can redistribute it and/or modify it |
8 |
# under the terms of the GNU General Public License as published by |
9 |
# the Free Software Foundation; either version 3 of the License, or |
10 |
# (at your option) any later version. |
2 |
# |
11 |
# |
3 |
# This Koha test module is a stub! |
12 |
# Koha is distributed in the hope that it will be useful, but |
4 |
# Add more tests here!!! |
13 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
# GNU General Public License for more details. |
16 |
# |
17 |
# You should have received a copy of the GNU General Public License |
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
5 |
|
19 |
|
6 |
use Modern::Perl; |
20 |
use Modern::Perl; |
7 |
|
21 |
use t::lib::TestBuilder; |
8 |
use Test::More tests => 3; |
22 |
use Test::More tests => 3; |
9 |
|
23 |
|
10 |
use_ok('C4::Category'); |
24 |
BEGIN { |
11 |
|
25 |
use_ok('C4::Category'); |
12 |
use C4::Context; |
26 |
} |
13 |
my $dbh = C4::Context->dbh; |
|
|
14 |
$dbh->{RaiseError} = 1; |
15 |
$dbh->{AutoCommit} = 0; |
16 |
|
17 |
my $sth=$dbh->prepare(' |
18 |
INSERT INTO categories( categorycode, description, enrolmentperiod, enrolmentperioddate, upperagelimit, dateofbirthrequired, enrolmentfee, reservefee, hidelostitems, overduenoticerequired, category_type ) |
19 |
VALUES (?,?,?,?,?,?,?,?,?,?,?) |
20 |
'); |
21 |
|
27 |
|
|
|
28 |
my $builder = t::lib::TestBuilder->new(); |
22 |
my $nonexistent_categorycode = 'NONEXISTEN'; |
29 |
my $nonexistent_categorycode = 'NONEXISTEN'; |
23 |
$sth->execute($nonexistent_categorycode, "Desc", 12, "2014-01-02", 99, 1, 1.5, 2.5, 0, 0, "A") || die $sth->errstr; |
30 |
$builder->build({ |
|
|
31 |
source => 'Category', |
32 |
value => { |
33 |
categorycode => $nonexistent_categorycode, |
34 |
description => 'Desc', |
35 |
enrolmentperiod => 12, |
36 |
enrolementperioddate => '2014-01-02', |
37 |
upperagelimit => 99, |
38 |
dateofbirthrequired => 1, |
39 |
enrolmentfee => 1.5, |
40 |
reservefee => 2.5, |
41 |
hidelostitems => 0, |
42 |
overduenoticerequired => 0, |
43 |
category_type => 'A', |
44 |
}, |
45 |
}); |
46 |
|
24 |
my @categories = C4::Category->all; |
47 |
my @categories = C4::Category->all; |
25 |
ok( @categories, 'all returns categories' ); |
48 |
ok( @categories, 'all returns categories' ); |
26 |
|
49 |
|
27 |
my $match = grep {$_->{categorycode} eq $nonexistent_categorycode } @categories; |
50 |
my $match = grep {$_->{categorycode} eq $nonexistent_categorycode } @categories; |
28 |
is( $match, 1, 'all returns the inserted category'); |
51 |
is( $match, 1, 'all returns the inserted category'); |
29 |
|
|
|
30 |
$dbh->rollback; |
31 |
- |