Bugzilla – Attachment 185276 Details for
Bug 38931
Add endpoints for individual credits and debits
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38931: Unit tests
Bug-38931-Unit-tests.patch (text/plain), 4.52 KB, created by
Tomás Cohen Arazi (tcohen)
on 2025-08-08 12:37:42 UTC
(
hide
)
Description:
Bug 38931: Unit tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2025-08-08 12:37:42 UTC
Size:
4.52 KB
patch
obsolete
>From 2d68cac9872c7f22295b1c12b5ef7e6926b78de8 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 20 Jan 2025 16:46:18 -0300 >Subject: [PATCH] Bug 38931: Unit tests > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: David Nind <david@davidnind.com> >--- > t/db_dependent/api/v1/patrons_accounts.t | 95 +++++++++++++++++++++++- > 1 file changed, 93 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/api/v1/patrons_accounts.t b/t/db_dependent/api/v1/patrons_accounts.t >index 316d99774f7..05df2a93b51 100755 >--- a/t/db_dependent/api/v1/patrons_accounts.t >+++ b/t/db_dependent/api/v1/patrons_accounts.t >@@ -18,7 +18,7 @@ > use Modern::Perl; > > use Test::NoWarnings; >-use Test::More tests => 6; >+use Test::More tests => 8; > > use Test::Mojo; > >@@ -30,7 +30,8 @@ use Koha::Account::Lines; > my $schema = Koha::Database->new->schema; > my $builder = t::lib::TestBuilder->new; > >-t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); >+t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); >+t::lib::Mocks::mock_preference( 'NotifyPasswordChange', 1 ); > > my $t = Test::Mojo->new('Koha::REST::V1'); > >@@ -300,6 +301,51 @@ subtest 'add_credit() tests' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'get_credit() tests' => sub { >+ >+ plan tests => 12; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { flags => 1 } >+ } >+ ); >+ my $userid = $patron->userid; >+ my $password = 'thePassword123'; >+ $patron->set_password( { password => $password, skip_validation => 1 } ); >+ >+ my $patron_id = $patron->id; >+ my $credit = $patron->account->add_credit( >+ { >+ amount => 100, >+ description => "A description", >+ type => "NEW_CARD", >+ interface => 'test', >+ } >+ ); >+ my $credit_id = $credit->id; >+ >+ $t->get_ok("//$userid:$password@/api/v1/patrons/$patron_id/account/credits/$credit_id")->status_is(200) >+ ->json_is( '/account_line_id' => $credit_id )->json_is( '/patron_id' => $patron_id ); >+ >+ $credit->delete(); >+ >+ $t->get_ok("//$userid:$password@/api/v1/patrons/$patron_id/account/credits/$credit_id")->status_is(404) >+ ->json_is( '/error_code' => 'not_found' )->json_is( '/error' => 'Credit not found' ); >+ >+ my $deleted_patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $deleted_patron_id = $deleted_patron->id; >+ $deleted_patron->delete(); >+ >+ $t->get_ok("//$userid:$password@/api/v1/patrons/$deleted_patron_id/account/credits/$credit_id")->status_is(404) >+ ->json_is( '/error_code' => 'not_found' )->json_is( '/error' => 'Patron not found' ); >+ >+ $schema->storage->txn_rollback; >+}; >+ > subtest 'list_credits() test' => sub { > plan tests => 3; > >@@ -340,6 +386,51 @@ subtest 'list_credits() test' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'get_debit() tests' => sub { >+ >+ plan tests => 12; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { flags => 1 } >+ } >+ ); >+ my $userid = $patron->userid; >+ my $password = 'thePassword123'; >+ $patron->set_password( { password => $password, skip_validation => 1 } ); >+ >+ my $patron_id = $patron->id; >+ my $debit = $patron->account->add_debit( >+ { >+ amount => 100, >+ description => "A description", >+ type => "NEW_CARD", >+ interface => 'test', >+ } >+ ); >+ my $debit_id = $debit->id; >+ >+ $t->get_ok("//$userid:$password@/api/v1/patrons/$patron_id/account/debits/$debit_id")->status_is(200) >+ ->json_is( '/account_line_id' => $debit_id )->json_is( '/patron_id' => $patron_id ); >+ >+ $debit->delete(); >+ >+ $t->get_ok("//$userid:$password@/api/v1/patrons/$patron_id/account/debits/$debit_id")->status_is(404) >+ ->json_is( '/error_code' => 'not_found' )->json_is( '/error' => 'Debit not found' ); >+ >+ my $deleted_patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $deleted_patron_id = $deleted_patron->id; >+ $deleted_patron->delete(); >+ >+ $t->get_ok("//$userid:$password@/api/v1/patrons/$deleted_patron_id/account/debits/$debit_id")->status_is(404) >+ ->json_is( '/error_code' => 'not_found' )->json_is( '/error' => 'Patron not found' ); >+ >+ $schema->storage->txn_rollback; >+}; >+ > subtest 'list_debits() test' => sub { > plan tests => 3; > >-- >2.50.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 38931
:
176840
|
176841
|
176892
|
176893
| 185276 |
185277