|
Lines 40-45
use t::lib::TestObjects::Acquisition::Bookseller::ContactFactory;
Link Here
|
| 40 |
use Koha::Acquisition::Bookseller::Contacts; |
40 |
use Koha::Acquisition::Bookseller::Contacts; |
| 41 |
use t::lib::TestObjects::Acquisition::BooksellerFactory; |
41 |
use t::lib::TestObjects::Acquisition::BooksellerFactory; |
| 42 |
use Koha::Acquisition::Booksellers; |
42 |
use Koha::Acquisition::Booksellers; |
|
|
43 |
use t::lib::TestObjects::FileFactory; |
| 44 |
use File::Slurp; |
| 45 |
use File::Fu::File; |
| 43 |
use t::lib::TestObjects::Serial::SubscriptionFactory; |
46 |
use t::lib::TestObjects::Serial::SubscriptionFactory; |
| 44 |
use Koha::Serial::Subscriptions; |
47 |
use Koha::Serial::Subscriptions; |
| 45 |
use Koha::Serial::Subscription::Frequencies; |
48 |
use Koha::Serial::Subscription::Frequencies; |
|
Lines 53-76
my $testContext = {}; #Gather all created Objects here so we can finally remove
Link Here
|
| 53 |
|
56 |
|
| 54 |
|
57 |
|
| 55 |
|
58 |
|
|
|
59 |
########## FileFactory subtests ########## |
| 60 |
subtest 't::lib::TestObjects::FileFactory' => \&testFileFactory; |
| 61 |
sub testFileFactory { |
| 62 |
my ($files); |
| 63 |
my $subtestContext = {}; |
| 64 |
|
| 65 |
$files = t::lib::TestObjects::FileFactory->createTestGroup([ |
| 66 |
{'filepath' => 'atomicupdate', |
| 67 |
'filename' => '#30-RabiesIsMyDog.pl', |
| 68 |
'content' => 'print "Mermaids are my only love\nI never let them down";', |
| 69 |
}, |
| 70 |
{'filepath' => 'atomicupdate', |
| 71 |
'filename' => '#31-FrogsArePeopleToo.pl', |
| 72 |
'content' => 'print "Listen to the Maker!";', |
| 73 |
}, |
| 74 |
{'filepath' => 'atomicupdate', |
| 75 |
'filename' => '#32-AnimalLover.pl', |
| 76 |
'content' => "print 'Do not hurt them!;", |
| 77 |
}, |
| 78 |
], undef, $subtestContext); |
| 79 |
|
| 80 |
my $file30content = File::Slurp::read_file( $files->{'#30-RabiesIsMyDog.pl'}->absolutely ); |
| 81 |
ok($file30content =~ m/Mermaids are my only love/, |
| 82 |
"'#30-RabiesIsMyDog.pl' created and content matches"); |
| 83 |
my $file31content = File::Slurp::read_file( $files->{'#31-FrogsArePeopleToo.pl'}->absolutely ); |
| 84 |
ok($file31content =~ m/Listen to the Maker!/, |
| 85 |
"'#31-FrogsArePeopleToo.pl' created and content matches"); |
| 86 |
my $file32content = File::Slurp::read_file( $files->{'#32-AnimalLover.pl'}->absolutely ); |
| 87 |
ok($file32content =~ m/Do not hurt them!/, |
| 88 |
"'#32-AnimalLover.pl' created and content matches"); |
| 89 |
|
| 90 |
##addToContext() test, create new file |
| 91 |
my $dir = $files->{'#32-AnimalLover.pl'}->dirname(); |
| 92 |
my $file = File::Fu::File->new("$dir/addToContext.txt"); |
| 93 |
$file->touch; |
| 94 |
t::lib::TestObjects::FileFactory->addToContext($file, undef, $subtestContext); |
| 95 |
ok($file->e, |
| 96 |
"'addToContext.txt' created"); |
| 97 |
|
| 98 |
t::lib::TestObjects::ObjectFactory->tearDownTestContext($subtestContext); |
| 99 |
|
| 100 |
ok(not(-e $files->{'#30-RabiesIsMyDog.pl'}->absolutely), |
| 101 |
"'#30-RabiesIsMyDog.pl' deleted"); |
| 102 |
ok(not(-e $files->{'#31-FrogsArePeopleToo.pl'}->absolutely), |
| 103 |
"'#31-FrogsArePeopleToo.pl' deleted"); |
| 104 |
ok(not(-e $files->{'#32-AnimalLover.pl'}->absolutely), |
| 105 |
"'#32-AnimalLover.pl' deleted"); |
| 106 |
ok(not(-e $file->absolutely), |
| 107 |
"'addToContext.txt' deleted"); |
| 108 |
}; |
| 109 |
|
| 110 |
|
| 111 |
|
| 56 |
########## Serial subtests ########## |
112 |
########## Serial subtests ########## |
| 57 |
subtest 't::lib::TestObjects::Serial' => sub { |
113 |
subtest 't::lib::TestObjects::Serial' => \&testSerialFactory; |
| 58 |
my ($subscriptions, $subscription, $frequency, $numberpattern, $biblio, $borrower, $bookseller, $items, $serials); |
114 |
sub testSerialFactory { |
|
|
115 |
my ($subscriptions, $subscription, $frequency, $numberpattern, $biblio, $sameBiblio, $borrower, $bookseller, $items, $serials); |
| 59 |
my $subtestContext = {}; |
116 |
my $subtestContext = {}; |
| 60 |
my $dontDeleteTestContext = {}; |
117 |
my $dontDeleteTestContext = {}; |
| 61 |
##Create and delete |
118 |
##Create and delete |
| 62 |
$subscriptions = t::lib::TestObjects::Serial::SubscriptionFactory->createTestGroup([ |
119 |
$subscriptions = t::lib::TestObjects::Serial::SubscriptionFactory->createTestGroup([ |
| 63 |
{internalnotes => 'TESTDEFAULTS', |
120 |
{internalnotes => 'TESTDEFAULTS', |
| 64 |
receiveSerials => 3}, |
121 |
receiveSerials => 3}, |
|
|
122 |
{internalnotes => 'SAMEBIBLIO',}, |
| 65 |
], undef, $subtestContext); |
123 |
], undef, $subtestContext); |
| 66 |
$subscription = Koha::Serial::Subscriptions->find( $subscriptions->{'TESTDEFAULTS'}->subscriptionid ); |
124 |
$subscription = Koha::Serial::Subscriptions->find( $subscriptions->{'TESTDEFAULTS'}->subscriptionid ); |
| 67 |
$frequency = $subscription->periodicity(); |
125 |
$frequency = $subscription->periodicity(); |
| 68 |
$numberpattern = $subscription->numberpattern(); |
126 |
$numberpattern = $subscription->numberpattern(); |
| 69 |
$biblio = $subscription->biblio(); |
127 |
$biblio = $subscription->biblio(); |
|
|
128 |
$sameBiblio = $subscriptions->{SAMEBIBLIO}->biblio; |
| 70 |
$borrower = $subscription->borrower(); |
129 |
$borrower = $subscription->borrower(); |
| 71 |
$bookseller = $subscription->bookseller(); |
130 |
$bookseller = $subscription->bookseller(); |
| 72 |
$items = $subscription->items(); |
131 |
$items = $subscription->items(); |
| 73 |
$serials = $subscription->serials(); |
132 |
$serials = $subscription->serials(); |
|
|
133 |
is($biblio->biblionumber, |
| 134 |
$sameBiblio->biblionumber, |
| 135 |
"Default Subscriptions use the same default Biblio"); |
| 74 |
ok(($subscriptions->{'TESTDEFAULTS'}->callnumber eq $subscription->callnumber && |
136 |
ok(($subscriptions->{'TESTDEFAULTS'}->callnumber eq $subscription->callnumber && |
| 75 |
$subscriptions->{'TESTDEFAULTS'}->subscriptionid eq $subscription->subscriptionid), |
137 |
$subscriptions->{'TESTDEFAULTS'}->subscriptionid eq $subscription->subscriptionid), |
| 76 |
"Default Subscription created."); |
138 |
"Default Subscription created."); |
|
Lines 163-169
subtest 't::lib::TestObjects::Serial' => sub {
Link Here
|
| 163 |
|
225 |
|
| 164 |
|
226 |
|
| 165 |
########## Acquisition subtests ########## |
227 |
########## Acquisition subtests ########## |
| 166 |
subtest 't::lib::TestObjects::Acquisition' => sub { |
228 |
subtest 't::lib::TestObjects::Acquisition' => \&testAcquisitionFactories; |
|
|
229 |
sub testAcquisitionFactories { |
| 167 |
my ($booksellers, $bookseller, $contacts, $contact); |
230 |
my ($booksellers, $bookseller, $contacts, $contact); |
| 168 |
my $subtestContext = {}; |
231 |
my $subtestContext = {}; |
| 169 |
##Create and delete |
232 |
##Create and delete |
|
Lines 198-204
subtest 't::lib::TestObjects::Acquisition' => sub {
Link Here
|
| 198 |
|
261 |
|
| 199 |
|
262 |
|
| 200 |
########## BorrowerFactory subtests ########## |
263 |
########## BorrowerFactory subtests ########## |
| 201 |
subtest 't::lib::TestObjects::BorrowerFactory' => sub { |
264 |
subtest 't::lib::TestObjects::BorrowerFactory' => \&testBorrowerFactory; |
|
|
265 |
sub testBorrowerFactory { |
| 202 |
my $subtestContext = {}; |
266 |
my $subtestContext = {}; |
| 203 |
##Create and Delete. Add one |
267 |
##Create and Delete. Add one |
| 204 |
my $f = t::lib::TestObjects::BorrowerFactory->new(); |
268 |
my $f = t::lib::TestObjects::BorrowerFactory->new(); |
|
Lines 223-232
subtest 't::lib::TestObjects::BorrowerFactory' => sub {
Link Here
|
| 223 |
|
287 |
|
| 224 |
##Delete objects |
288 |
##Delete objects |
| 225 |
t::lib::TestObjects::ObjectFactory->tearDownTestContext($subtestContext); |
289 |
t::lib::TestObjects::ObjectFactory->tearDownTestContext($subtestContext); |
| 226 |
my $object11A001 = Koha::Borrowers->find({cardnumber => '11A001'}); |
290 |
foreach my $cn (('11A001', '11A002')) { |
| 227 |
ok (not($object11A001), "Borrower '11A001' deleted"); |
291 |
ok (not(Koha::Borrowers->find({cardnumber => $cn})), |
| 228 |
my $object11A002 = Koha::Borrowers->find({cardnumber => '11A002'}); |
292 |
"Borrower '11A001' deleted"); |
| 229 |
ok (not($object11A002), "Borrower '11A002' deleted"); |
293 |
} |
| 230 |
|
294 |
|
| 231 |
#Prepare for global autoremoval. |
295 |
#Prepare for global autoremoval. |
| 232 |
$objects = $f->createTestGroup([ |
296 |
$objects = $f->createTestGroup([ |
|
Lines 246-252
subtest 't::lib::TestObjects::BorrowerFactory' => sub {
Link Here
|
| 246 |
|
310 |
|
| 247 |
|
311 |
|
| 248 |
########## BiblioFactory and ItemFactory subtests ########## |
312 |
########## BiblioFactory and ItemFactory subtests ########## |
| 249 |
subtest 't::lib::TestObjects::BiblioFactory and ::ItemFactory' => sub { |
313 |
subtest 't::lib::TestObjects::BiblioFactory and ::ItemFactory' => \&testBiblioItemFactories; |
|
|
314 |
sub testBiblioItemFactories { |
| 250 |
my $subtestContext = {}; |
315 |
my $subtestContext = {}; |
| 251 |
##Create and Delete. Add one |
316 |
##Create and Delete. Add one |
| 252 |
my $biblios = t::lib::TestObjects::BiblioFactory->createTestGroup([ |
317 |
my $biblios = t::lib::TestObjects::BiblioFactory->createTestGroup([ |
|
Lines 302-308
subtest 't::lib::TestObjects::BiblioFactory and ::ItemFactory' => sub {
Link Here
|
| 302 |
|
367 |
|
| 303 |
|
368 |
|
| 304 |
########## CheckoutFactory subtests ########## |
369 |
########## CheckoutFactory subtests ########## |
| 305 |
subtest 't::lib::TestObjects::CheckoutFactory' => sub { |
370 |
subtest 't::lib::TestObjects::CheckoutFactory' => \&testCheckoutFactory; |
|
|
371 |
sub testCheckoutFactory { |
| 306 |
my $subtestContext = {}; |
372 |
my $subtestContext = {}; |
| 307 |
##Create and Delete using dependencies in the $testContext instantiated in previous subtests. |
373 |
##Create and Delete using dependencies in the $testContext instantiated in previous subtests. |
| 308 |
my $biblios = t::lib::TestObjects::BiblioFactory->createTestGroup([ |
374 |
my $biblios = t::lib::TestObjects::BiblioFactory->createTestGroup([ |
|
Lines 376-382
subtest 't::lib::TestObjects::CheckoutFactory' => sub {
Link Here
|
| 376 |
|
442 |
|
| 377 |
|
443 |
|
| 378 |
########## LetterTemplateFactory subtests ########## |
444 |
########## LetterTemplateFactory subtests ########## |
| 379 |
subtest 't::lib::TestObjects::LetterTemplateFactory' => sub { |
445 |
subtest 't::lib::TestObjects::LetterTemplateFactory' => \&testLetterTemplateFactory; |
|
|
446 |
sub testLetterTemplateFactory { |
| 380 |
my $subtestContext = {}; |
447 |
my $subtestContext = {}; |
| 381 |
##Create and Delete using dependencies in the $testContext instantiated in previous subtests. |
448 |
##Create and Delete using dependencies in the $testContext instantiated in previous subtests. |
| 382 |
my $f = t::lib::TestObjects::LetterTemplateFactory->new(); |
449 |
my $f = t::lib::TestObjects::LetterTemplateFactory->new(); |
|
Lines 406-412
subtest 't::lib::TestObjects::LetterTemplateFactory' => sub {
Link Here
|
| 406 |
|
473 |
|
| 407 |
|
474 |
|
| 408 |
########## SystemPreferenceFactory subtests ########## |
475 |
########## SystemPreferenceFactory subtests ########## |
| 409 |
subtest 't::lib::TestObjects::SystemPreferenceFactory' => sub { |
476 |
subtest 't::lib::TestObjects::SystemPreferenceFactory' => \&testSystemPreferenceFactory; |
|
|
477 |
sub testSystemPreferenceFactory { |
| 410 |
my $subtestContext = {}; |
478 |
my $subtestContext = {}; |
| 411 |
|
479 |
|
| 412 |
# take syspref 'opacuserlogin' and save its current value |
480 |
# take syspref 'opacuserlogin' and save its current value |
|
Lines 443-449
subtest 't::lib::TestObjects::SystemPreferenceFactory' => sub {
Link Here
|
| 443 |
|
511 |
|
| 444 |
|
512 |
|
| 445 |
########## Global test context subtests ########## |
513 |
########## Global test context subtests ########## |
| 446 |
subtest 't::lib::TestObjects::ObjectFactory clearing global test context' => sub { |
514 |
subtest 't::lib::TestObjects::ObjectFactory clearing global test context' => \&testGlobalSubtestContext; |
|
|
515 |
sub testGlobalSubtestContext { |
| 447 |
my $object11A001 = Koha::Borrowers->find({cardnumber => '11A001'}); |
516 |
my $object11A001 = Koha::Borrowers->find({cardnumber => '11A001'}); |
| 448 |
ok ($object11A001, "Global Borrower '11A001' exists"); |
517 |
ok ($object11A001, "Global Borrower '11A001' exists"); |
| 449 |
my $object11A002 = Koha::Borrowers->find({cardnumber => '11A002'}); |
518 |
my $object11A002 = Koha::Borrowers->find({cardnumber => '11A002'}); |
| 450 |
- |
|
|