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

(-)a/t/db_dependent/Acquisition/GetBasketAsCSV.t (-1 / +9 lines)
Lines 4-16 use Modern::Perl; Link Here
4
4
5
use CGI;
5
use CGI;
6
6
7
use Test::More tests => 4;
7
use Test::More tests => 5;
8
8
9
use C4::Acquisition qw( NewBasket GetBasket GetBasketAsCSV );
9
use C4::Acquisition qw( NewBasket GetBasket GetBasketAsCSV );
10
use C4::Biblio qw( AddBiblio );
10
use C4::Biblio qw( AddBiblio );
11
use Koha::Database;
11
use Koha::Database;
12
use Koha::CsvProfiles;
12
use Koha::CsvProfiles;
13
use Koha::Acquisition::Orders;
13
use Koha::Acquisition::Orders;
14
use Koha::Biblios;
14
15
15
use t::lib::Mocks;
16
use t::lib::Mocks;
16
use Try::Tiny;
17
use Try::Tiny;
Lines 92-95 try { Link Here
92
    ok($_->isa("Koha::Exceptions::ObjectNotFound"), "Using non-existant profile should throw ObjectNotFound exception");
93
    ok($_->isa("Koha::Exceptions::ObjectNotFound"), "Using non-existant profile should throw ObjectNotFound exception");
93
};
94
};
94
95
96
Koha::Biblios->find($biblionumber)->delete;
97
my $basket_csv4 = C4::Acquisition::GetBasketAsCSV($basketno, $query);
98
is($basket_csv4, 'Contract name,Order number,Entry date,ISBN,Author,Title,Publication year,Publisher,Collection title,Note for vendor,Quantity,RRP,Delivery place,Billing place
99
"",' . $order->ordernumber . ',2016-01-02,,"","",,"","","",3,,"",""
100
', 'CSV should not fail if biblio does not exist');
101
102
95
$schema->storage->txn_rollback();
103
$schema->storage->txn_rollback();
(-)a/t/db_dependent/Acquisition/GetBasketGroupAsCSV.t (-1 / +73 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
use Modern::Perl;
4
5
use CGI;
6
7
use Test::More tests => 2;
8
9
use C4::Acquisition qw( NewBasket NewBasketgroup GetBasketGroupAsCSV );
10
use C4::Biblio qw( AddBiblio );
11
use Koha::Database;
12
use Koha::CsvProfiles;
13
use Koha::Acquisition::Orders;
14
use Koha::Biblios;
15
16
use t::lib::Mocks;
17
use Try::Tiny;
18
19
my $schema = Koha::Database->new()->schema();
20
$schema->storage->txn_begin();
21
22
my $query = CGI->new();
23
24
my $vendor = Koha::Acquisition::Bookseller->new({
25
    name => 'my vendor',
26
    address1 => 'vendor address',
27
    active => 1,
28
    deliverytime => 5,
29
})->store;
30
31
my $budget_id = C4::Budgets::AddBudget({
32
    budget_code => 'my_budget_code',
33
    budget_name => 'My budget name',
34
});
35
my $budget = C4::Budgets::GetBudget( $budget_id );
36
37
my $basketno = C4::Acquisition::NewBasket($vendor->id, 1);
38
39
my $basketgroupid = C4::Acquisition::NewBasketgroup(
40
    {
41
        booksellerid  => $vendor->id,
42
        basketlist    => [ $basketno ],
43
    }
44
);
45
46
my $biblio = MARC::Record->new();
47
$biblio->append_fields(
48
    MARC::Field->new( '100', ' ', ' ', a => 'King, Stephen' ),
49
    MARC::Field->new( '245', ' ', ' ', a => 'Test Record' ),
50
);
51
my ($biblionumber, $biblioitemnumber) = AddBiblio($biblio, '');
52
53
my $order = Koha::Acquisition::Order->new({
54
    basketno => $basketno,
55
    quantity => 3,
56
    biblionumber => $biblionumber,
57
    budget_id => $budget_id,
58
    entrydate => '2016-01-02',
59
})->store;
60
61
my $basketgroup_csv1 = C4::Acquisition::GetBasketGroupAsCSV($basketgroupid, $query);
62
is($basketgroup_csv1, 'Account number,Basket name,Order number,Author,Title,Publisher,Publication year,Collection title,ISBN,Quantity,RRP tax included,RRP tax excluded,Discount,Estimated cost tax included,Estimated cost tax excluded,Note for vendor,Entry date,Bookseller name,Bookseller physical address,Bookseller postal address,Contract number,Contract name,Basket group delivery place,Basket group billing place,Basket delivery place,Basket billing place
63
,"",' . $order->ordernumber  . ',"King, Stephen","Test Record","",,"",,3,0.00,0.00,,0.00,0.00,"",2016-01-02,"my vendor","vendor address","",,"","","","",""
64
', 'CSV should be generated');
65
66
Koha::Biblios->find($biblionumber)->delete;
67
my $basketgroup_csv2 = C4::Acquisition::GetBasketGroupAsCSV($basketgroupid, $query);
68
is($basketgroup_csv2, 'Account number,Basket name,Order number,Author,Title,Publisher,Publication year,Collection title,ISBN,Quantity,RRP tax included,RRP tax excluded,Discount,Estimated cost tax included,Estimated cost tax excluded,Note for vendor,Entry date,Bookseller name,Bookseller physical address,Bookseller postal address,Contract number,Contract name,Basket group delivery place,Basket group billing place,Basket delivery place,Basket billing place
69
,"",' . $order->ordernumber  . ',"","","",,"",,3,0.00,0.00,,0.00,0.00,"",2016-01-02,"my vendor","vendor address","",,"","","","",""
70
', 'CSV should not fail if biblio does not exist');
71
72
73
$schema->storage->txn_rollback();

Return to bug 31649