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

(-)a/t/db_dependent/Category.t (-11 / +16 lines)
Lines 3-24 Link Here
3
# This Koha test module is a stub!
3
# This Koha test module is a stub!
4
# Add more tests here!!!
4
# Add more tests here!!!
5
5
6
use strict;
6
use Modern::Perl;
7
use warnings;
8
7
9
use Test::More tests => 2;
8
use Test::More tests => 3;
9
10
use_ok('C4::Category');
10
11
11
BEGIN {
12
        use_ok('C4::Category');
13
}
14
use C4::Context;
12
use C4::Context;
15
my $dbh = C4::Context->dbh;
13
my $dbh = C4::Context->dbh;
16
$dbh->{RaiseError} = 1;
14
$dbh->{RaiseError} = 1;
17
$dbh->{AutoCommit} = 0;
15
$dbh->{AutoCommit} = 0;
18
16
19
my $sth=$dbh->prepare("INSERT INTO categories  (categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,
17
my $sth=$dbh->prepare('
20
enrolmentfee,reservefee,hidelostitems,overduenoticerequired,category_type) values (?,?,?,?,?,?,?,?,?,?,?)");
18
    INSERT INTO categories( categorycode, description, enrolmentperiod, enrolmentperioddate, upperagelimit, dateofbirthrequired, enrolmentfee, reservefee, hidelostitems, overduenoticerequired, category_type )
21
$sth->execute("test", "Desc", 12, "2014-01-02", 99, 1, 1.5, 2.5, 0, 0, "A") || die $sth->errstr;
19
    VALUES (?,?,?,?,?,?,?,?,?,?,?)
22
ok( my @categories = C4::Category->all);
20
');
21
22
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;
24
my @categories = C4::Category->all;
25
ok( @categories, 'all returns categories' );
26
27
my $match = grep {$_->{categorycode} eq $nonexistent_categorycode } @categories;
28
is( $match, 1, 'all returns the inserted category');
23
29
24
$dbh->rollback;
30
$dbh->rollback;
25
- 

Return to bug 11543