|
Lines 21-27
use Modern::Perl;
Link Here
|
| 21 |
use C4::Context; |
21 |
use C4::Context; |
| 22 |
use C4::Bookseller; |
22 |
use C4::Bookseller; |
| 23 |
|
23 |
|
| 24 |
use Test::More tests => 40; |
24 |
use Test::More tests => 43; |
| 25 |
|
25 |
|
| 26 |
BEGIN { |
26 |
BEGIN { |
| 27 |
use_ok('C4::Contract'); |
27 |
use_ok('C4::Contract'); |
|
Lines 42-47
my $bookseller_id2 = C4::Bookseller::AddBookseller( { name => 'My second booksel
Link Here
|
| 42 |
isnt( $bookseller_id2, undef, 'AddBookseller does not return undef' ); |
42 |
isnt( $bookseller_id2, undef, 'AddBookseller does not return undef' ); |
| 43 |
my $contracts = GetContracts(); |
43 |
my $contracts = GetContracts(); |
| 44 |
is( @$contracts, 0, 'GetContracts returns the correct number of contracts' ); |
44 |
is( @$contracts, 0, 'GetContracts returns the correct number of contracts' ); |
|
|
45 |
my $contract = GetContract(); |
| 46 |
is( $contract, undef, 'GetContract without argument returns undef' ); |
| 47 |
|
| 45 |
|
48 |
|
| 46 |
my $my_contract1 = { |
49 |
my $my_contract1 = { |
| 47 |
contractstartdate => '2014-06-01', |
50 |
contractstartdate => '2014-06-01', |
|
Lines 50-60
my $my_contract1 = {
Link Here
|
| 50 |
contractdescription => 'My contract description', |
53 |
contractdescription => 'My contract description', |
| 51 |
booksellerid => $bookseller_id1, |
54 |
booksellerid => $bookseller_id1, |
| 52 |
}; |
55 |
}; |
| 53 |
my $my_contract_id1 = AddContract($my_contract1); |
56 |
my $my_contract_id1 = AddContract(); |
|
|
57 |
is( $my_contract_id1, undef, 'AddContract without argument returns undef' ); |
| 58 |
$my_contract_id1 = AddContract($my_contract1); |
| 54 |
isnt( $my_contract_id1, undef, 'AddContract does not return undef' ); |
59 |
isnt( $my_contract_id1, undef, 'AddContract does not return undef' ); |
|
|
60 |
|
| 55 |
$contracts = GetContracts(); |
61 |
$contracts = GetContracts(); |
| 56 |
is( @$contracts, 1, 'AddContract adds a contract' ); |
62 |
is( @$contracts, 1, 'AddContract adds a contract' ); |
| 57 |
my $contract = GetContract( { contractnumber => $my_contract_id1 } ); |
63 |
|
|
|
64 |
$contract = GetContract(); |
| 65 |
is( $contract, undef, 'GetContract without argument returns undef' ); |
| 66 |
$contract = GetContract( { contractnumber => $my_contract_id1 } ); |
| 58 |
is( $contract->{contractstartdate}, $my_contract1->{contractstartdate}, 'AddContract stores the contract start date correctly.' ); |
67 |
is( $contract->{contractstartdate}, $my_contract1->{contractstartdate}, 'AddContract stores the contract start date correctly.' ); |
| 59 |
is( $contract->{contractenddate}, $my_contract1->{contractenddate}, 'AddContract stores the contract end date correctly.' ); |
68 |
is( $contract->{contractenddate}, $my_contract1->{contractenddate}, 'AddContract stores the contract end date correctly.' ); |
| 60 |
is( $contract->{contractname}, $my_contract1->{contractname}, 'AddContract stores the contract name correctly.' ); |
69 |
is( $contract->{contractname}, $my_contract1->{contractname}, 'AddContract stores the contract name correctly.' ); |
|
Lines 70-76
$my_contract1 = {
Link Here
|
| 70 |
booksellerid => $bookseller_id2, |
79 |
booksellerid => $bookseller_id2, |
| 71 |
}; |
80 |
}; |
| 72 |
my $mod_status = ModContract($my_contract1); |
81 |
my $mod_status = ModContract($my_contract1); |
| 73 |
is( $mod_status, '0E0', 'ModContract without the contract number returns 0E0' ); |
82 |
is( $mod_status, undef, 'ModContract without the contract number returns 0E0' ); |
| 74 |
|
83 |
|
| 75 |
$my_contract1->{contractnumber} = $my_contract_id1; |
84 |
$my_contract1->{contractnumber} = $my_contract_id1; |
| 76 |
$mod_status = ModContract($my_contract1); |
85 |
$mod_status = ModContract($my_contract1); |
|
Lines 96-105
my $my_contract_id2 = AddContract($my_contract2);
Link Here
|
| 96 |
$contracts = GetContracts( { booksellerid => $bookseller_id1 } ); |
105 |
$contracts = GetContracts( { booksellerid => $bookseller_id1 } ); |
| 97 |
is( @$contracts, 1, 'GetContracts returns the correct number of contracts' ); |
106 |
is( @$contracts, 1, 'GetContracts returns the correct number of contracts' ); |
| 98 |
$contracts = GetContracts({ |
107 |
$contracts = GetContracts({ |
| 99 |
booksellerid => $bookseller_id1, |
|
|
| 100 |
activeonly => 1 |
108 |
activeonly => 1 |
| 101 |
}); |
109 |
}); |
| 102 |
is( @$contracts, 0, 'GetContracts with active only returns only current contracts' ); |
110 |
is( @$contracts, 1, 'GetContracts with active only returns only current contracts' ); |
| 103 |
$contracts = GetContracts( { booksellerid => $bookseller_id2 } ); |
111 |
$contracts = GetContracts( { booksellerid => $bookseller_id2 } ); |
| 104 |
is( @$contracts, 1, 'GetContracts returns the correct number of contracts' ); |
112 |
is( @$contracts, 1, 'GetContracts returns the correct number of contracts' ); |
| 105 |
$contracts = GetContracts(); |
113 |
$contracts = GetContracts(); |
| 106 |
- |
|
|