Bugzilla – Attachment 66349 Details for
Bug 19130
K::A::Booksellers->search broken for attribute 'name'
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19130: (followup) Add t/db_dependent/Koha/Acquisition/Booksellers.t
Bug-19130-followup-Add-tdbdependentKohaAcquisition.patch (text/plain), 7.47 KB, created by
Tomás Cohen Arazi (tcohen)
on 2017-08-22 15:17:42 UTC
(
hide
)
Description:
Bug 19130: (followup) Add t/db_dependent/Koha/Acquisition/Booksellers.t
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2017-08-22 15:17:42 UTC
Size:
7.47 KB
patch
obsolete
>From e46180813f1feec77df07bae651ff01868e431c0 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 22 Aug 2017 12:03:37 -0300 >Subject: [PATCH] Bug 19130: (followup) Add > t/db_dependent/Koha/Acquisition/Booksellers.t > >This followup patch adds a proper file in which add tests for >Koha::Acquisition::Bookseller(s) methods. > >All current methods are covered. > >To test: >- Run: > $ sudo koha-shell kohadev > k$ cd kohaclone > k$ prove t/db_dependent/Koha/Acquisition/Booksellers.t > => SUCCESS: Test pass! > - Sign off :-D >--- > t/db_dependent/Koha/Acquisition/Booksellers.t | 187 ++++++++++++++++++++++++++ > 1 file changed, 187 insertions(+) > create mode 100644 t/db_dependent/Koha/Acquisition/Booksellers.t > >diff --git a/t/db_dependent/Koha/Acquisition/Booksellers.t b/t/db_dependent/Koha/Acquisition/Booksellers.t >new file mode 100644 >index 0000000000..21140e8919 >--- /dev/null >+++ b/t/db_dependent/Koha/Acquisition/Booksellers.t >@@ -0,0 +1,187 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 3; >+ >+use t::lib::TestBuilder; >+ >+use C4::Acquisition; >+use C4::Biblio; >+use C4::Budgets; >+use C4::Serials; >+ >+use Koha::Acquisition::Booksellers; >+use Koha::Database; >+use Koha::DateUtils; >+ >+my $schema = Koha::Database->schema(); >+my $builder = t::lib::TestBuilder->new; >+ >+subtest '->baskets() tests' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin(); >+ >+ # Delete existing data >+ $schema->resultset('Aqorder')->delete(); >+ $schema->resultset('Aqbasket')->delete(); >+ Koha::Acquisition::Booksellers->delete(); >+ $schema->resultset('Subscription')->delete(); >+ >+ my $vendor = $builder->build_object( { class => 'Koha::Acquisition::Booksellers' } ); >+ >+ is( $vendor->baskets, 0, 'Vendor has no baskets' ); >+ >+ # Add two baskets >+ my $basket_1_id = C4::Acquisition::NewBasket( $vendor->id, 'authorizedby1', 'basketname1' ); >+ my $basket_2_id = C4::Acquisition::NewBasket( $vendor->id, 'authorizedby2', 'basketname2' ); >+ >+ # Re-fetch vendor >+ $vendor = Koha::Acquisition::Booksellers->find( $vendor->id ); >+ is( $vendor->baskets, 2, 'Vendor has two baskets' ); >+ >+ $schema->storage->txn_rollback(); >+}; >+ >+subtest '->subscriptions() tests' => sub { >+ >+ plan tests => 5; >+ >+ $schema->storage->txn_begin(); >+ >+ # Delete existing data >+ $schema->resultset('Aqorder')->delete(); >+ $schema->resultset('Aqbasket')->delete(); >+ Koha::Acquisition::Booksellers->delete(); >+ $schema->resultset('Subscription')->delete(); >+ >+ my $vendor = $builder->build_object( { class => 'Koha::Acquisition::Booksellers' } ); >+ is( $vendor->subscriptions->count, 0, 'Vendor has no subscriptions' ); >+ >+ my $dt_today = dt_from_string; >+ my $today = output_pref( >+ { dt => $dt_today, dateformat => 'iso', timeformat => '24hr', dateonly => 1 } ); >+ >+ my $dt_today1 = dt_from_string; >+ my $dur5 = DateTime::Duration->new( days => -5 ); >+ $dt_today1->add_duration($dur5); >+ my $daysago5 = output_pref( >+ { dt => $dt_today1, dateformat => 'iso', timeformat => '24hr', dateonly => 1 } ); >+ >+ my $budgetperiod = C4::Budgets::AddBudgetPeriod( >+ { budget_period_startdate => $daysago5, >+ budget_period_enddate => $today, >+ budget_period_description => "budget desc" >+ } >+ ); >+ my $id_budget = AddBudget( >+ { budget_code => "CODE", >+ budget_amount => "123.132", >+ budget_name => "Budgetname", >+ budget_notes => "This is a note", >+ budget_period_id => $budgetperiod >+ } >+ ); >+ my $bib = MARC::Record->new(); >+ $bib->append_fields( >+ MARC::Field->new( '245', ' ', ' ', a => 'Journal of ethnology' ), >+ MARC::Field->new( '500', ' ', ' ', a => 'bib notes' ), >+ ); >+ my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $bib, '' ); >+ >+ # Add two subscriptions >+ my $subscription_1_id = NewSubscription( >+ undef, 'BRANCH2', $vendor->id, undef, >+ $id_budget, $biblionumber, '01-01-2013', undef, >+ undef, undef, undef, undef, >+ undef, undef, undef, undef, >+ undef, 1, "subscription notes", undef, >+ '01-01-2013', undef, undef, undef, >+ 'CALL ABC', 0, "intnotes", 0, >+ undef, undef, 0, undef, >+ '2013-11-30', 0 >+ ); >+ >+ my @subscriptions = SearchSubscriptions( { biblionumber => $biblionumber } ); >+ is( $subscriptions[0]->{publicnotes}, >+ 'subscription notes', >+ 'subscription search results include public notes (bug 10689)' >+ ); >+ >+ my $id_subscription2 = NewSubscription( >+ undef, 'BRANCH2', $vendor->id, undef, >+ $id_budget, $biblionumber, '01-01-2013', undef, >+ undef, undef, undef, undef, >+ undef, undef, undef, undef, >+ undef, 1, "subscription notes", undef, >+ '01-01-2013', undef, undef, undef, >+ 'CALL DEF', 0, "intnotes", 0, >+ undef, undef, 0, undef, >+ '2013-07-31', 0 >+ ); >+ >+ # Re-fetch vendor >+ $vendor = Koha::Acquisition::Booksellers->find( $vendor->id ); >+ is( $vendor->subscriptions->count, 2, 'Vendor has two subscriptions' ); >+ foreach my $subscription ( $vendor->subscriptions ) { >+ is( ref($subscription), 'Koha::Subscription', 'Type is correct' ); >+ } >+ >+ $schema->storage->txn_rollback(); >+}; >+ >+subtest '->contacts() tests' => sub { >+ >+ plan tests => 4; >+ >+ $schema->storage->txn_begin(); >+ >+ # Delete existing data >+ $schema->resultset('Aqorder')->delete(); >+ $schema->resultset('Aqbasket')->delete(); >+ Koha::Acquisition::Booksellers->delete(); >+ $schema->resultset('Subscription')->delete(); >+ >+ my $vendor = $builder->build_object( { class => 'Koha::Acquisition::Booksellers' } ); >+ >+ is( $vendor->contacts->count, 0, 'Vendor has no contacts' ); >+ >+ # Add two contacts >+ my $contact_1 = $builder->build_object( >+ { class => 'Koha::Acquisition::Bookseller::Contacts', >+ value => { booksellerid => $vendor->id } >+ } >+ ); >+ my $contact_2 = $builder->build_object( >+ { class => 'Koha::Acquisition::Bookseller::Contacts', >+ value => { booksellerid => $vendor->id } >+ } >+ ); >+ >+ # Re-fetch vendor >+ $vendor = Koha::Acquisition::Booksellers->find( $vendor->id ); >+ is( $vendor->contacts->count, 2, 'Vendor has two contacts' ); >+ foreach my $contact ( $vendor->contacts ) { >+ is( ref($contact), 'Koha::Acquisition::Bookseller::Contact', 'Type is correct' ); >+ } >+ >+ $schema->storage->txn_rollback(); >+}; >+ >-- >2.14.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 19130
:
66348
|
66349
|
66350
|
66352
|
66365
|
66366
|
66367
|
66368
|
66480
|
66481
|
66482
|
66483