Bugzilla – Attachment 69259 Details for
Bug 19410
Add a helper function for generating object searches for the API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19410: Unit tests
Bug-19410-Unit-tests.patch (text/plain), 3.04 KB, created by
Julian Maurice
on 2017-11-21 19:31:56 UTC
(
hide
)
Description:
Bug 19410: Unit tests
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2017-11-21 19:31:56 UTC
Size:
3.04 KB
patch
obsolete
>From 163bb8cbd7b74028b009eadbb8189b7f92e6a07c Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 6 Oct 2017 12:49:27 -0300 >Subject: [PATCH] Bug 19410: Unit tests > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> >--- > t/db_dependent/Koha/Objects.t | 68 +++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 66 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Koha/Objects.t b/t/db_dependent/Koha/Objects.t >index 71b7abb28e..cf261b2e2d 100644 >--- a/t/db_dependent/Koha/Objects.t >+++ b/t/db_dependent/Koha/Objects.t >@@ -19,7 +19,8 @@ > > use Modern::Perl; > >-use Test::More tests => 15; >+use Test::More tests => 16; >+use Test::Exception; > use Test::Warn; > > use Koha::Authority::Types; >@@ -237,4 +238,67 @@ subtest '->is_paged and ->pager tests' => sub { > 'Koha::Objects->pager returns a valid DBIx::Class object' ); > > $schema->storage->txn_rollback; >-} >+}; >+ >+subtest '_build_query_params_from_api' => sub { >+ >+ plan tests => 5; >+ >+ my $filtered_params = { >+ title => "Ender", >+ author => "Orson" >+ }; >+ >+ subtest '_match => contains' => sub { >+ plan tests => 2; >+ my $reserved_params = { _match => 'contains' }; >+ my $params = Koha::Objects::_build_query_params_from_api( $filtered_params, $reserved_params ); >+ >+ is_deeply( $params->{author}, { like => '%Orson%' } ); >+ is_deeply( $params->{title}, { like => '%Ender%' } ); >+ }; >+ >+ subtest '_match => starts_with' => sub { >+ plan tests => 2; >+ my $reserved_params = { _match => 'starts_with' }; >+ my $params = Koha::Objects::_build_query_params_from_api( $filtered_params, $reserved_params ); >+ >+ is_deeply( $params->{author}, { like => 'Orson%' } ); >+ is_deeply( $params->{title}, { like => 'Ender%' } ); >+ }; >+ >+ subtest '_match => ends_with' => sub { >+ plan tests => 2; >+ my $reserved_params = { _match => 'ends_with' }; >+ my $params = Koha::Objects::_build_query_params_from_api( $filtered_params, $reserved_params ); >+ >+ is_deeply( $params->{author}, { like => '%Orson' } ); >+ is_deeply( $params->{title}, { like => '%Ender' } ); >+ }; >+ >+ subtest '_match => exact' => sub { >+ plan tests => 2; >+ my $reserved_params = { _match => 'exact' }; >+ my $params = Koha::Objects::_build_query_params_from_api( $filtered_params, $reserved_params ); >+ >+ is( $params->{author}, 'Orson' ); >+ is( $params->{title}, 'Ender' ); >+ }; >+ >+ subtest '_match => blah' => sub { >+ plan tests => 2; >+ >+ my $reserved_params = { _match => 'blah' }; >+ throws_ok { >+ Koha::Objects::_build_query_params_from_api( $filtered_params, >+ $reserved_params ); >+ } >+ 'Koha::Exceptions::WrongParameter', >+ 'Exception thrown on invalid _match parameter'; >+ >+ is( $@, >+ 'Invalid value for _match param (blah)', >+ 'Exception carries the right message' >+ ); >+ }; >+}; >-- >2.11.0
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 19410
:
67613
|
67731
|
67732
|
67750
|
67751
|
67795
|
67798
|
69248
|
69253
|
69254
|
69255
|
69256
|
69257
|
69258
|
69259
|
69260
|
69261
|
69262
|
69282
|
69283
|
69284
|
69286
|
69287
|
69385
|
69386
|
69387
|
69388
|
69389
|
69397
|
69398
|
69399
|
69400
|
69401
|
69545
|
69703