Bugzilla – Attachment 151939 Details for
Bug 17499
Koha objects for messaging preferences
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17499: Replace test subroutines with build_object
Bug-17499-Replace-test-subroutines-with-buildobjec.patch (text/plain), 14.50 KB, created by
Sam Lau
on 2023-06-01 16:03:52 UTC
(
hide
)
Description:
Bug 17499: Replace test subroutines with build_object
Filename:
MIME Type:
Creator:
Sam Lau
Created:
2023-06-01 16:03:52 UTC
Size:
14.50 KB
patch
obsolete
>From e777b57f197d0a1eaec636249e03261e46d55ca6 Mon Sep 17 00:00:00 2001 >From: Emmi Takkinen <emmi.takkinen@outlook.com> >Date: Wed, 26 Feb 2020 12:04:08 +0200 >Subject: [PATCH] Bug 17499: Replace test subroutines with build_object > >This patch replaces subroutines used to build test >objects with call to $builder->build_object. > >To test prove that tests are still running with: >prove t/db_dependent/Koha/Patron/Message/* > >Sponsored-by: Koha-Suomi Oy >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> > >Signed-off-by: Michal Denar <black23@gmail.com> >Signed-off-by: Sam Lau <samalau@gmail.com> >--- > .../Koha/Patron/Message/Preferences.t | 69 ++++++------------- > .../Patron/Message/Transport/Preferences.t | 51 ++------------ > .../Koha/Patron/Message/Transports.t | 29 +------- > 3 files changed, 27 insertions(+), 122 deletions(-) > >diff --git a/t/db_dependent/Koha/Patron/Message/Preferences.t b/t/db_dependent/Koha/Patron/Message/Preferences.t >index fc289b8ee9..89273ea234 100644 >--- a/t/db_dependent/Koha/Patron/Message/Preferences.t >+++ b/t/db_dependent/Koha/Patron/Message/Preferences.t >@@ -51,9 +51,9 @@ subtest 'Test Koha::Patron::Message::Preferences' => sub { > > $schema->storage->txn_begin; > >- my $attribute = build_a_test_attribute(); >+ my $attribute = $builder->build_object({ class => 'Koha::Patron::Message::Attributes' }); > my $letter = build_a_test_letter(); >- my $mtt = build_a_test_transport_type(); >+ my $mtt = $builder->build_object({ class => 'Koha::Patron::Message::Transport::Types' }); > Koha::Patron::Message::Transport->new({ > message_attribute_id => $attribute->message_attribute_id, > message_transport_type => $mtt->message_transport_type, >@@ -65,7 +65,7 @@ subtest 'Test Koha::Patron::Message::Preferences' => sub { > subtest 'Test for a patron' => sub { > plan tests => 3; > >- my $patron = build_a_test_patron(); >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); > Koha::Patron::Message::Preference->new({ > borrowernumber => $patron->borrowernumber, > message_attribute_id => $attribute->message_attribute_id, >@@ -99,7 +99,7 @@ subtest 'Test Koha::Patron::Message::Preferences' => sub { > }; > > subtest 'Test for a category' => sub { >- my $category = build_a_test_category(); >+ my $category = $builder->build_object({ class => 'Koha::Patron::Categories' }); > Koha::Patron::Message::Preference->new({ > categorycode => $category->categorycode, > message_attribute_id => $attribute->message_attribute_id, >@@ -167,7 +167,7 @@ subtest 'Add preferences from defaults' => sub { > > $schema->storage->txn_begin; > >- my $patron = build_a_test_patron(); >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); > my ($default, $mtt1, $mtt2) = build_a_test_category_preference({ > patron => $patron, > }); >@@ -198,7 +198,7 @@ subtest 'Test Koha::Patron::Message::Preference->message_transport_types' => sub > > $schema->storage->txn_begin; > >- my $patron = build_a_test_patron(); >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); > my ($preference, $mtt1, $mtt2) = build_a_test_complete_preference({ > patron => $patron > }); >@@ -261,7 +261,7 @@ HERE > my $transports = $pref->message_transport_types; > is($appender, undef, 'Nothing in buffer yet'); > >- my $mtt_new = build_a_test_transport_type(); >+ my $mtt_new = $builder->build_object({ class => 'Koha::Patron::Message::Transport::Types' }); > Koha::Patron::Message::Transport::Preference->new({ > borrower_message_preference_id => > $pref->borrower_message_preference_id, >@@ -286,7 +286,7 @@ HERE > > $schema->storage->txn_begin; > >- my $patron = build_a_test_patron(); >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); > my ($preference, $mtt1, $mtt2) = build_a_test_complete_preference({ > patron => $patron > }); >@@ -386,10 +386,10 @@ HERE > > $schema->storage->txn_begin; > >- my $patron = build_a_test_patron(); >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); > my $letter = build_a_test_letter(); >- my $attribute = build_a_test_attribute(); >- my $mtt = build_a_test_transport_type(); >+ my $attribute = $builder->build_object({ class => 'Koha::Patron::Message::Attributes' }); >+ my $mtt = $builder->build_object({ class => 'Koha::Patron::Message::Transport::Types' }); > Koha::Patron::Message::Transport->new({ > message_attribute_id => $attribute->message_attribute_id, > message_transport_type => $mtt->message_transport_type, >@@ -421,8 +421,8 @@ subtest 'Test Koha::Patron::Message::Preference->message_name' => sub { > > $schema->storage->txn_begin; > >- my $patron = build_a_test_patron(); >- my $attribute = build_a_test_attribute(); >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $attribute = $builder->build_object({ class => 'Koha::Patron::Message::Attributes' }); > my ($preference, $mtt1, $mtt2) = build_a_test_complete_preference({ > patron => $patron, > attr => $attribute, >@@ -453,7 +453,7 @@ subtest 'Test adding a new preference with invalid parameters' => sub { > > $schema->storage->txn_begin; > >- my $patron = build_a_test_patron(); >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); > eval { Koha::Patron::Message::Preference->new({ > borrowernumber => $patron->borrowernumber, > categorycode => $patron->categorycode, >@@ -489,7 +489,7 @@ subtest 'Test adding a new preference with invalid parameters' => sub { > .' was the categorycode.'); > > my $attribute = build_a_test_attribute({ takes_days => 0 }); >- my $patron = build_a_test_patron(); >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); > eval { Koha::Patron::Message::Preference->new({ > borrowernumber => $patron->borrowernumber, > message_attribute_id => $attribute->message_attribute_id, >@@ -523,7 +523,7 @@ subtest 'Test adding a new preference with invalid parameters' => sub { > is ($@->parameter, 'message_transport_types', 'The previous exception ' > .'tells us it was the message_transport_types.'); > >- my $mtt_new = build_a_test_transport_type(); >+ my $mtt_new = $builder->build_object({ class => 'Koha::Patron::Message::Transport::Types' }); > eval { > Koha::Patron::Message::Preference->new({ > borrowernumber => $patron->borrowernumber, >@@ -591,9 +591,9 @@ subtest 'Test adding a new preference with invalid parameters' => sub { > > $schema->storage->txn_begin; > >- my $attribute = build_a_test_attribute(); >+ my $attribute = $builder->build_object({ class => 'Koha::Patron::Message::Attributes' }); > my $letter = build_a_test_letter(); >- my $mtt = build_a_test_transport_type(); >+ my $mtt = $builder->build_object({ class => 'Koha::Patron::Message::Transport::Types' }); > Koha::Patron::Message::Transport->new({ > message_attribute_id => $attribute->message_attribute_id, > message_transport_type => $mtt->message_transport_type, >@@ -601,7 +601,7 @@ subtest 'Test adding a new preference with invalid parameters' => sub { > letter_module => $letter->module, > letter_code => $letter->code, > })->store; >- my $patron = build_a_test_patron(); >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); > my $preference = Koha::Patron::Message::Preference->new({ > borrowernumber => $patron->borrowernumber, > message_attribute_id => $attribute->message_attribute_id, >@@ -640,13 +640,6 @@ sub build_a_test_attribute { > ); > } > >-sub build_a_test_category { >- my $categorycode = $builder->build({ >- source => 'Category' })->{categorycode}; >- >- return Koha::Patron::Categories->find($categorycode); >-} >- > sub build_a_test_letter { > my ($params) = @_; > >@@ -669,26 +662,6 @@ sub build_a_test_letter { > }); > } > >-sub build_a_test_patron { >- my $categorycode = $builder->build({ >- source => 'Category' })->{categorycode}; >- my $branchcode = $builder->build({ >- source => 'Branch' })->{branchcode}; >- my $borrowernumber = $builder->build({ >- source => 'Borrower' })->{borrowernumber}; >- >- return Koha::Patrons->find($borrowernumber); >-} >- >-sub build_a_test_transport_type { >- my $mtt = $builder->build({ >- source => 'MessageTransportType' }); >- >- return Koha::Patron::Message::Transport::Types->find( >- $mtt->{message_transport_type} >- ); >-} >- > sub build_a_test_category_preference { > my ($params) = @_; > >@@ -698,8 +671,8 @@ sub build_a_test_category_preference { > : build_a_test_attribute($params->{days_in_advance}); > > my $letter = $params->{letter} ? $params->{letter} : build_a_test_letter(); >- my $mtt1 = $params->{mtt1} ? $params->{mtt1} : build_a_test_transport_type(); >- my $mtt2 = $params->{mtt2} ? $params->{mtt2} : build_a_test_transport_type(); >+ my $mtt1 = $params->{mtt1} ? $params->{mtt1} : $builder->build_object({ class => 'Koha::Patron::Message::Transport::Types' }); >+ my $mtt2 = $params->{mtt2} ? $params->{mtt2} : $builder->build_object({ class => 'Koha::Patron::Message::Transport::Types' }); > > Koha::Patron::Message::Transport->new({ > message_attribute_id => $attr->message_attribute_id, >diff --git a/t/db_dependent/Koha/Patron/Message/Transport/Preferences.t b/t/db_dependent/Koha/Patron/Message/Transport/Preferences.t >index 0cdf8095a4..3e6c8a8876 100644 >--- a/t/db_dependent/Koha/Patron/Message/Transport/Preferences.t >+++ b/t/db_dependent/Koha/Patron/Message/Transport/Preferences.t >@@ -47,8 +47,8 @@ subtest 'Test Koha::Patron::Message::Transport::Preferences' => sub { > > $schema->storage->txn_begin; > >- my $attribute = build_a_test_attribute(); >- my $mtt = build_a_test_transport_type(); >+ my $attribute = $builder->build_object({ class => 'Koha::Patron::Message::Attributes' }); >+ my $mtt = $builder->build_object({ class => 'Koha::Patron::Message::Transport::Types' }); > my $letter = build_a_test_letter({ > mtt => $mtt->message_transport_type > }); >@@ -61,7 +61,7 @@ subtest 'Test Koha::Patron::Message::Transport::Preferences' => sub { > })->store; > > subtest 'For a patron' => sub { >- my $patron = build_a_test_patron(); >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); > my $preference = Koha::Patron::Message::Preference->new({ > borrowernumber => $patron->borrowernumber, > message_attribute_id => $attribute->message_attribute_id, >@@ -85,7 +85,7 @@ subtest 'Test Koha::Patron::Message::Transport::Preferences' => sub { > }; > > subtest 'For a category' => sub { >- my $category = build_a_test_category(); >+ my $category = $builder->build_object({ class => 'Koha::Patron::Categories' }); > my $preference = Koha::Patron::Message::Preference->new({ > categorycode => $category->categorycode, > message_attribute_id => $attribute->message_attribute_id, >@@ -111,29 +111,6 @@ subtest 'Test Koha::Patron::Message::Transport::Preferences' => sub { > $schema->storage->txn_rollback; > }; > >-sub build_a_test_attribute { >- my ($params) = @_; >- >- $params->{takes_days} = $params->{takes_days} && $params->{takes_days} > 0 >- ? 1 : 0; >- >- my $attribute = $builder->build({ >- source => 'MessageAttribute', >- value => $params, >- }); >- >- return Koha::Patron::Message::Attributes->find( >- $attribute->{message_attribute_id} >- ); >-} >- >-sub build_a_test_category { >- my $categorycode = $builder->build({ >- source => 'Category' })->{categorycode}; >- >- return Koha::Patron::Categories->find($categorycode); >-} >- > sub build_a_test_letter { > my ($params) = @_; > >@@ -156,24 +133,4 @@ sub build_a_test_letter { > }); > } > >-sub build_a_test_patron { >- my $categorycode = $builder->build({ >- source => 'Category' })->{categorycode}; >- my $branchcode = $builder->build({ >- source => 'Branch' })->{branchcode}; >- my $borrowernumber = $builder->build({ >- source => 'Borrower' })->{borrowernumber}; >- >- return Koha::Patrons->find($borrowernumber); >-} >- >-sub build_a_test_transport_type { >- my $mtt = $builder->build({ >- source => 'MessageTransportType' }); >- >- return Koha::Patron::Message::Transport::Types->find( >- $mtt->{message_transport_type} >- ); >-} >- > 1; >diff --git a/t/db_dependent/Koha/Patron/Message/Transports.t b/t/db_dependent/Koha/Patron/Message/Transports.t >index b9296fd3c1..f6c50a6e0d 100644 >--- a/t/db_dependent/Koha/Patron/Message/Transports.t >+++ b/t/db_dependent/Koha/Patron/Message/Transports.t >@@ -42,8 +42,8 @@ subtest 'Test Koha::Patron::Message::Transports' => sub { > > $schema->storage->txn_begin; > >- my $attribute = build_a_test_attribute(); >- my $mtt = build_a_test_transport_type(); >+ my $attribute = $builder->build_object({ class => 'Koha::Patron::Message::Attributes' }); >+ my $mtt = $builder->build_object({ class => 'Koha::Patron::Message::Transport::Types' }); > my $letter = build_a_test_letter({ > mtt => $mtt->message_transport_type > }); >@@ -69,22 +69,6 @@ subtest 'Test Koha::Patron::Message::Transports' => sub { > $schema->storage->txn_rollback; > }; > >-sub build_a_test_attribute { >- my ($params) = @_; >- >- $params->{takes_days} = $params->{takes_days} && $params->{takes_days} > 0 >- ? 1 : 0; >- >- my $attribute = $builder->build({ >- source => 'MessageAttribute', >- value => $params, >- }); >- >- return Koha::Patron::Message::Attributes->find( >- $attribute->{message_attribute_id} >- ); >-} >- > sub build_a_test_letter { > my ($params) = @_; > >@@ -107,13 +91,4 @@ sub build_a_test_letter { > }); > } > >-sub build_a_test_transport_type { >- my $mtt = $builder->build({ >- source => 'MessageTransportType' }); >- >- return Koha::Patron::Message::Transport::Types->find( >- $mtt->{message_transport_type} >- ); >-} >- > 1; >-- >2.30.2
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 17499
:
63427
|
63428
|
63429
|
63430
|
63431
|
63432
|
63433
|
63434
|
63786
|
63787
|
63788
|
63789
|
63790
|
63791
|
63792
|
63793
|
63801
|
63802
|
63803
|
63804
|
63805
|
63806
|
63807
|
63808
|
63809
|
63810
|
63811
|
63812
|
63878
|
63895
|
64035
|
64036
|
64037
|
64038
|
64039
|
64040
|
64041
|
64042
|
64043
|
64044
|
64795
|
66686
|
69434
|
69435
|
69458
|
91864
|
93863
|
93865
|
93872
|
94748
|
99479
|
99634
|
99668
|
99669
|
99670
|
103441
|
103442
|
103443
|
106653
|
106654
|
106655
|
106656
|
106657
|
107612
|
107613
|
107614
|
107615
|
107616
|
113010
|
113011
|
113127
|
113129
|
113686
|
113687
|
113765
|
113766
|
113767
|
113768
|
118452
|
118453
|
119470
|
119471
|
119472
|
119473
|
119474
|
119475
|
119476
|
119477
|
119478
|
119479
|
119480
|
119481
|
119482
|
119483
|
119484
|
119485
|
119486
|
119487
|
119488
|
119489
|
119490
|
119491
|
141408
|
141409
|
141410
|
141411
|
141412
|
141413
|
141414
|
141415
|
141416
|
141417
|
141418
|
146529
|
146530
|
146531
|
146532
|
146533
|
146534
|
146535
|
146536
|
146537
|
146538
|
146539
|
146540
|
151900
|
151901
|
151902
|
151903
|
151904
|
151905
|
151906
|
151907
|
151908
|
151909
|
151910
|
151911
|
151937
|
151938
|
151939
|
151940
|
151941
|
151942
|
151943
|
151944
|
151945
|
151946
|
151947
|
151948
|
155365
|
155366
|
155367
|
155368
|
155369
|
155370
|
155371
|
155372
|
155373
|
155374
|
155375
|
155376