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

(-)a/C4/Bookseller.pm (-2 / +1 lines)
Lines 269-276 sub DelBookseller { Link Here
269
    my $id  = shift;
269
    my $id  = shift;
270
    my $dbh = C4::Context->dbh;
270
    my $dbh = C4::Context->dbh;
271
    my $sth = $dbh->prepare('DELETE FROM aqbooksellers WHERE id=?');
271
    my $sth = $dbh->prepare('DELETE FROM aqbooksellers WHERE id=?');
272
    $sth->execute($id);
272
    return $sth->execute($id);
273
    return;
274
}
273
}
275
274
276
1;
275
1;
(-)a/t/db_dependent/Bookseller.t (-1 / +114 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
use Modern::Perl;
4
5
use Test::More tests => 7;
6
use C4::Context;
7
use Koha::DateUtils;
8
use DateTime::Duration;
9
use C4::Acquisition;
10
use C4::Serials;
11
use C4::Budgets;
12
use C4::Biblio;
13
14
BEGIN {
15
    use_ok('C4::Bookseller');
16
}
17
18
can_ok(
19
20
    'C4::Bookseller', qw(
21
      AddBookseller
22
      DelBookseller
23
      GetBookSeller
24
      GetBookSellerFromId
25
      GetBooksellersWithLateOrders
26
      ModBookseller )
27
);
28
29
#Start transaction
30
my $dbh = C4::Context->dbh;
31
$dbh->{RaiseError} = 1;
32
$dbh->{AutoCommit} = 0;
33
34
#Start tests
35
$dbh->do(q|DELETE FROM aqorders|);
36
$dbh->do(q|DELETE FROM aqbasket|);
37
$dbh->do(q|DELETE FROM aqbooksellers|);
38
39
#Test AddBookseller
40
my $count            = scalar( C4::Bookseller::GetBookSeller('') );
41
my $sample_supplier1 = {
42
    name          => 'Name1',
43
    address1      => 'address1_1',
44
    address2      => 'address1-2',
45
    address3      => 'address1_2',
46
    address4      => 'address1_2',
47
    postal        => 'postal1',
48
    phone         => 'phone1',
49
    accountnumber => 'accountnumber1',
50
    fax           => 'fax1',
51
    url           => 'url1',
52
    contact       => 'contact1',
53
    contpos       => 'contpos1',
54
    contphone     => 'contphone1',
55
    contfax       => 'contefax1',
56
    contaltphone  => 'contaltphone1',
57
    contemail     => 'contemail1',
58
    contnotes     => 'contnotes1',
59
    active        => 1,
60
    gstreg        => 1,
61
    listincgst    => 1,
62
    invoiceincgst => 1,
63
    gstrate       => '1.0000',
64
    discount      => '1.0000',
65
    notes         => 'notes1',
66
    deliverytime  => undef
67
};
68
my $sample_supplier2 = {
69
    name          => 'Name2',
70
    address1      => 'address1_2',
71
    address2      => 'address2-2',
72
    address3      => 'address3_2',
73
    address4      => 'address4_2',
74
    postal        => 'postal2',
75
    phone         => 'phone2',
76
    accountnumber => 'accountnumber2',
77
    fax           => 'fax2',
78
    url           => 'url2',
79
    contact       => 'contact2',
80
    contpos       => 'contpos2',
81
    contphone     => 'contphone2',
82
    contfax       => 'contefax2',
83
    contaltphone  => 'contaltphone2',
84
    contemail     => 'contemail2',
85
    contnotes     => 'contnotes2',
86
    active        => 1,
87
    gstreg        => 1,
88
    listincgst    => 1,
89
    invoiceincgst => 1,
90
    gstrate       => '2.0000',
91
    discount      => '2.0000',
92
    notes         => 'notes2',
93
    deliverytime  => 2,
94
};
95
96
my $id_supplier1 = C4::Bookseller::AddBookseller($sample_supplier1);
97
my $id_supplier2 = C4::Bookseller::AddBookseller($sample_supplier2);
98
99
#my $id_bookseller3 = C4::Bookseller::AddBookseller();# NOTE : Doesn't work because the field name cannot be null
100
101
like( $id_supplier1, '/^\d+$/', "AddBookseller for supplier1 return an id" );
102
like( $id_supplier2, '/^\d+$/', "AddBookseller for supplier2 return an id" );
103
is( scalar( C4::Bookseller::GetBookSeller('') ),
104
    $count + 2, "Supplier1 and Supplier2 have been added" );
105
106
#Test DelBookseller
107
my $del = C4::Bookseller::DelBookseller($id_supplier1);
108
is( $del, 1, "DelBookseller returns 1 - 1 supplier has been deleted " );
109
is( C4::Bookseller::GetBookSellerFromId($id_supplier1),
110
    undef, "Supplier1  has been deleted - id_supplier1 doesnt exist anymore" );
111
112
#End transaction
113
$dbh->rollback;
114

Return to bug 10630