Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 10; |
20 |
use Test::More tests => 18; |
21 |
use Test::Mojo; |
21 |
use Test::Mojo; |
22 |
use t::lib::TestBuilder; |
22 |
use t::lib::TestBuilder; |
23 |
|
23 |
|
Lines 41-46
my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode };
Link Here
|
41 |
$t->get_ok('/api/v1/accountlines') |
41 |
$t->get_ok('/api/v1/accountlines') |
42 |
->status_is(403); |
42 |
->status_is(403); |
43 |
|
43 |
|
|
|
44 |
$t->put_ok("/api/v1/accountlines/11224409" => json => {'amount' => -5}) |
45 |
->status_is(403); |
46 |
|
44 |
my $loggedinuser = $builder->build({ |
47 |
my $loggedinuser = $builder->build({ |
45 |
source => 'Borrower', |
48 |
source => 'Borrower', |
46 |
value => { |
49 |
value => { |
Lines 101-104
$json = $t->tx->res->json;
Link Here
|
101 |
ok(ref $json eq 'ARRAY', 'response is a JSON array'); |
104 |
ok(ref $json eq 'ARRAY', 'response is a JSON array'); |
102 |
ok(scalar @$json == 4, 'response array contains 3 elements'); |
105 |
ok(scalar @$json == 4, 'response array contains 3 elements'); |
103 |
|
106 |
|
|
|
107 |
# Editing accountlines tests |
108 |
my $put_data = { |
109 |
'amount' => -19, |
110 |
'amountoutstanding' => -19 |
111 |
}; |
112 |
|
113 |
|
114 |
$tx = $t->ua->build_tx( |
115 |
PUT => "/api/v1/accountlines/11224409" |
116 |
=> {Accept => '*/*'} |
117 |
=> json => $put_data); |
118 |
$tx->req->cookies({name => 'CGISESSID', value => $session->id}); |
119 |
$tx->req->env({REMOTE_ADDR => '127.0.0.1'}); |
120 |
$t->request_ok($tx) |
121 |
->status_is(404); |
122 |
|
123 |
my $accountline_to_edit = Koha::Accountlines->search({'borrowernumber' => $borrowernumber2})->unblessed()->[0]; |
124 |
|
125 |
$tx = $t->ua->build_tx( |
126 |
PUT => "/api/v1/accountlines/$accountline_to_edit->{accountlines_id}" |
127 |
=> {Accept => '*/*'} |
128 |
=> json => $put_data); |
129 |
$tx->req->cookies({name => 'CGISESSID', value => $session->id}); |
130 |
$tx->req->env({REMOTE_ADDR => '127.0.0.1'}); |
131 |
$t->request_ok($tx) |
132 |
->status_is(200); |
133 |
|
134 |
my $accountline_edited = Koha::Accountlines->search({'borrowernumber' => $borrowernumber2})->unblessed()->[0]; |
135 |
|
136 |
is($accountline_edited->{amount}, '-19.000000'); |
137 |
is($accountline_edited->{amountoutstanding}, '-19.000000'); |
138 |
|
139 |
|
140 |
# Payment tests |
141 |
|
104 |
$dbh->rollback; |
142 |
$dbh->rollback; |
105 |
- |
|
|