Lines 30-41
my $builder = t::lib::TestBuilder->new;
Link Here
|
30 |
|
30 |
|
31 |
subtest 'request() tests' => sub { |
31 |
subtest 'request() tests' => sub { |
32 |
|
32 |
|
33 |
plan tests => 3; |
33 |
plan tests => 11; |
34 |
|
34 |
|
35 |
$schema->storage->txn_begin; |
35 |
$schema->storage->txn_begin; |
36 |
|
36 |
|
|
|
37 |
my $amount = 0; |
38 |
|
39 |
my $patron_mock = Test::MockModule->new('Koha::Patron'); |
40 |
$patron_mock->mock( 'article_request_fee', sub { return $amount; } ); |
41 |
|
37 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
42 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
38 |
my $biblio = $builder->build_sample_biblio; |
43 |
my $item = $builder->build_sample_item; |
39 |
|
44 |
|
40 |
my $ar_mock = Test::MockModule->new('Koha::ArticleRequest'); |
45 |
my $ar_mock = Test::MockModule->new('Koha::ArticleRequest'); |
41 |
$ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } ); |
46 |
$ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } ); |
Lines 43-57
subtest 'request() tests' => sub {
Link Here
|
43 |
my $ar = Koha::ArticleRequest->new( |
48 |
my $ar = Koha::ArticleRequest->new( |
44 |
{ |
49 |
{ |
45 |
borrowernumber => $patron->id, |
50 |
borrowernumber => $patron->id, |
46 |
biblionumber => $biblio->id, |
51 |
biblionumber => $item->biblionumber, |
|
|
52 |
} |
53 |
); |
54 |
|
55 |
$ar->request()->discard_changes; |
56 |
|
57 |
is( $ar->status, Koha::ArticleRequest::Status::Requested ); |
58 |
ok( defined $ar->created_on, 'created_on is set' ); |
59 |
|
60 |
is( $ar->debit_id, undef, 'No fee linked' ); |
61 |
is( $patron->account->balance, 0, 'No outstanding fees' ); |
62 |
|
63 |
# set a fee amount |
64 |
$amount = 10; |
65 |
|
66 |
$ar = Koha::ArticleRequest->new( |
67 |
{ |
68 |
borrowernumber => $patron->id, |
69 |
biblionumber => $item->biblionumber, |
70 |
itemnumber => $item->id, |
47 |
} |
71 |
} |
48 |
); |
72 |
); |
49 |
|
73 |
|
50 |
$ar->request()->discard_changes; |
74 |
$ar->request()->discard_changes; |
51 |
|
75 |
|
52 |
is( $ar->status, Koha::ArticleRequest::Status::Requested ); |
76 |
is( $ar->status, Koha::ArticleRequest::Status::Requested ); |
|
|
77 |
is( $ar->itemnumber, $item->id, 'itemnumber set' ); |
53 |
ok( defined $ar->created_on, 'created_on is set' ); |
78 |
ok( defined $ar->created_on, 'created_on is set' ); |
54 |
|
79 |
|
|
|
80 |
ok( defined $ar->debit_id, 'Fee linked' ); |
81 |
is( $patron->account->balance, $amount, 'Outstanding fees with the right value' ); |
82 |
|
55 |
$schema->storage->txn_rollback; |
83 |
$schema->storage->txn_rollback; |
56 |
}; |
84 |
}; |
57 |
|
85 |
|
58 |
- |
|
|