Bugzilla – Attachment 60074 Details for
Bug 17932
Koha::Object should provide a TO_JSON method
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17932: Unit tests
Bug-17932-Unit-tests.patch (text/plain), 2.35 KB, created by
Marcel de Rooy
on 2017-02-09 14:02:22 UTC
(
hide
)
Description:
Bug 17932: Unit tests
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2017-02-09 14:02:22 UTC
Size:
2.35 KB
patch
obsolete
>From 002c9a54da2e90f75295ed5c5c8b1e6234990c28 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 24 Jan 2017 10:41:00 -0300 >Subject: [PATCH] Bug 17932: Unit tests >Content-Type: text/plain; charset=utf-8 > >This patch adds unit tests for the Koha::Object::TO_JSON function. >It tests on top of Koha::Patron as Koha::Object needs to be >instantiated. > >To test: >- Apply the patch >- Run: > $ prove -v t/db_dependent/Koha/Object.t >=> SUCCESS: New tests for TO_JSON are run and return green. >- Sign off :-D > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > t/db_dependent/Koha/Object.t | 30 +++++++++++++++++++++++++++++- > 1 file changed, 29 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Object.t b/t/db_dependent/Koha/Object.t >index 9ea5e8c..fd5d89b 100755 >--- a/t/db_dependent/Koha/Object.t >+++ b/t/db_dependent/Koha/Object.t >@@ -17,13 +17,15 @@ > > use Modern::Perl; > >-use Test::More tests => 7; >+use Test::More tests => 8; > use Test::Warn; > > use C4::Context; > use Koha::Database; > use Koha::DateUtils qw( dt_from_string ); > >+use Scalar::Util qw( isvstring ); >+ > use t::lib::TestBuilder; > > BEGIN { >@@ -34,6 +36,8 @@ BEGIN { > my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; > >+my $builder = t::lib::TestBuilder->new(); >+ > my $categorycode = $schema->resultset('Category')->first()->categorycode(); > my $branchcode = $schema->resultset('Branch')->first()->branchcode(); > >@@ -107,4 +111,28 @@ subtest 'discard_changes' => sub { > ); > }; > >+subtest 'TO_JSON tests' => sub { >+ >+ plan tests => 5; >+ >+ my $borrowernumber = $builder->build( >+ { source => 'Borrower', >+ value => { lost => 1, >+ gonenoaddress => 0 } })->{borrowernumber}; >+ >+ my $patron = Koha::Patrons->find($borrowernumber); >+ my $lost = $patron->TO_JSON()->{lost}; >+ my $gonenoaddress = $patron->TO_JSON->{gonenoaddress}; >+ >+ ok( $lost->isa('Mojo::JSON::_Bool'), 'Boolean attribute type is correct' ); >+ is( $lost, 1, 'Boolean attribute value is correct (true)' ); >+ >+ ok( $gonenoaddress->isa('Mojo::JSON::_Bool'), 'Boolean attribute type is correct' ); >+ is( $gonenoaddress, 0, 'Boolean attribute value is correct (false)' ); >+ >+ ok( !isvstring($patron->borrowernumber), 'Integer values are not coded as strings' ); >+}; >+ >+ >+ > 1; >-- >2.1.4
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 17932
:
59431
|
59432
|
59498
|
59499
|
59500
|
59501
|
59696
|
59697
|
59698
|
59699
|
60072
|
60073
| 60074 |
60075