bug 1825
[bioperl-live.git] / t / BiblioReferences.t
blobf2b5d56ce3787ed91c3355254bbc5bb606126151
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id$
4 use strict;
6 our @modules;
8 BEGIN {
9     use lib 't/lib';
10     use BioperlTest;
11     
12     test_begin(-tests => 537);
13         
14         @modules = qw(
15                 Bio::Biblio::Article
16                 Bio::Biblio::Book
17                 Bio::Biblio::BookArticle
18                 Bio::Biblio::Journal
19                 Bio::Biblio::JournalArticle
20                 Bio::Biblio::MedlineArticle
21                 Bio::Biblio::MedlineBook
22                 Bio::Biblio::MedlineBookArticle
23                 Bio::Biblio::MedlineJournal
24                 Bio::Biblio::MedlineJournalArticle
25                 Bio::Biblio::Organisation
26                 Bio::Biblio::Patent
27                 Bio::Biblio::Person
28                 Bio::Biblio::Proceeding
29                 Bio::Biblio::Provider
30                 Bio::Biblio::Ref
31                 Bio::Biblio::Service
32                 Bio::Biblio::TechReport
33                 Bio::Biblio::Thesis
34                 Bio::Biblio::WebResource
35                 Bio::Biblio::PubmedArticle
36                 Bio::Biblio::PubmedBookArticle
37                 Bio::Biblio::PubmedJournalArticle);
38         
39         foreach my $module (@modules) {
40                 use_ok($module);
41         }
44 my $verbose = test_debug();
46 my ($biblio, $count, $str, @args);
47 my ($citation, $provider);
49 print "Testing 'Bio::Biblio::->new() ...'\n" if $verbose;
50 foreach my $object (@modules) {
51         ok defined ($biblio = $object->new());
54 my @scalar_methods_for_ref =
55     qw(
56      abstract
57      abstract_language
58      abstract_type
59      author_list_complete
60      cross_references_list_complete
61      date
62      date_completed
63      date_created
64      date_revised
65      format
66      identifier
67      language
68      last_modified_date
69      repository_subset
70      rights
71      spatial_location
72      subject_headings_source
73      temporal_period
74      title
75      toc
76      toc_type
77      type
78      );
79 my @other_methods_for_ref =
80     qw(
81      authors
82      cross_references
83      codes
84      contributors
85      keywords
86      publisher
87      subject_headings
88     );
90 my @scalar_methods_for_book =
91     qw(
92      edition
93      isbn
94      series
95      volume
96      );
97 my @other_methods_for_book =
98     qw(
99      editor
100      );
102 my @scalar_methods_for_bookarticle =
103     qw(
104      );
105 my @other_methods_for_bookarticle =
106     qw(
107      book
108      );
110 my @scalar_methods_for_article =
111     qw(
112      first_page
113      last_page
114      );
115 my @other_methods_for_article =
116     qw(
117      );
119 my @scalar_methods_for_journalarticle =
120     qw(
121      issue
122      issue_supplement
123      volume
124      );
125 my @other_methods_for_journalarticle =
126     qw(
127      journal
128      );
130 my @scalar_methods_for_medlinearticle =
131     qw(
132      affiliation
133      citation_owner
134      date_of_electronic_publication
135      gene_symbols
136      grant_list_complete
137      medline_date
138      medline_id
139      medline_page
140      number_of_references
141      other_languages
142      pmid
143      season
144      status
145      vernacular_title
146      );
148 my @other_methods_for_medlinearticle =
149     qw(
150      chemicals
151      comment_ins
152      comment_ons
153      erratum_fors
154      erratum_ins
155      general_notes
156      grants
157      mesh_headings
158      original_report_ins
159      other_abstracts
160      other_ids
161      republished_froms
162      republished_ins
163      retraction_ins
164      retraction_ofs
165      summary_for_patients_ins
166      update_ins
167      update_ofs
168      );
170 my @scalar_methods_for_medlinejournalarticle =
171     qw(
172      );
173 my @other_methods_for_medlinejournalarticle =
174     qw(
175      journal
176      );
178 my @scalar_methods_for_medlinebookarticle =
179     qw(
180      );
181 my @other_methods_for_medlinebookarticle =
182     qw(
183      book
184      );
186 my @scalar_methods_for_medlinebook =
187     qw(
188      );
189 my @other_methods_for_medlinebook =
190     qw(
191      );
193 my @scalar_methods_for_pubmedarticle =
194     qw(
195      pubmed_status
196      pubmed_provider_id
197      );
198 my @other_methods_for_pubmedarticle =
199     qw(
200      pubmed_history_list
201      pubmed_article_id_list
202      pubmed_url_list
203      );
205 my @scalar_methods_for_journal =
206     qw(
207      abbreviation
208      issn
209      name
210      );
211 my @other_methods_for_journal =
212     qw(
213      );
215 my @scalar_methods_for_medlinejournal =
216     qw(
217      coden
218      country
219      medline_code
220      medline_ta
221      nlm_unique_id
222      );
223 my @other_methods_for_medlinejournal =
224     qw(
225      );
227 my @scalar_methods_for_patent =
228     qw(
229      doc_number
230      doc_office
231      doc_type
232      );
233 my @other_methods_for_patent =
234     qw(
235      applicants
236      );
238 my @scalar_methods_for_webresource =
239     qw(
240      url
241      estimated_size
242      cost
243      );
244 my @other_methods_for_webresource =
245     qw(
246      );
248 my @scalar_methods_for_provider =
249     qw(
250      type
251      );
253 my @scalar_methods_for_person =
254     qw(
255      affiliation
256      email
257      firstname
258      forename
259      initials
260      lastname
261      middlename
262      postal_address
263      suffix
264      );
266 my @scalar_methods_for_organisation =
267     qw(
268      name
269      );
271 my @scalar_methods_for_service =
272     qw(
273      name
274      );
277 # Bio::Biblio::MedlineJournalArticle
279 print "Testing Bio::Biblio::MedlineJournalArticle ...\n" if $verbose;
280 $citation = Bio::Biblio::MedlineJournalArticle->new();
281 @args = ();
282 $count = 1;
283 foreach my $method (@scalar_methods_for_ref,
284                     @scalar_methods_for_article,
285                     @scalar_methods_for_journalarticle,
286                     @scalar_methods_for_medlinearticle,
287                     @scalar_methods_for_medlinejournalarticle) {
288     $str = 'string' . ($count++);
289         is $citation->$method ($str), $str, "set '$method'";
290         is $citation->$method(), $str, "get '$method'";
291     push (@args, ("-$method" => $str));
294 ok defined ($biblio = Bio::Biblio::MedlineJournalArticle->new(@args));
295 for (my $i = 0; $i < @args; $i += 2) {
296     my $method = substr ($args[$i], 1);
297         is $citation->$method(), $args[$i+1], $method;
299 foreach my $method (@other_methods_for_ref,
300                     @other_methods_for_article,
301                     @other_methods_for_journalarticle,
302                     @other_methods_for_medlinearticle,
303                     @other_methods_for_medlinejournalarticle) {
304         is $citation->$method(), undef, "get '$method'";
306 my ($me) = Bio::Biblio::Person->new(-lastname => 'me');
307 my ($you) = Bio::Biblio::Person->new(-lastname => 'you');
308 ok $citation->add_author ($me), "add_author 1";
309 ok $citation->add_author ($you), "add_author 2";
310 is ${ $citation->authors }[1]->lastname, 'you', "get authors";
312 ok $citation->add_contributor ($me), "add_contributor 1";
313 ok $citation->add_contributor ($you), "add_contributor 2";
314 is ${ $citation->contributors }[1]->lastname, 'you', "get contributors";
316 use Bio::Annotation::DBLink;
317 my $link1 = Bio::Annotation::DBLink->new(-database => 'here',
318                                         -primary_id => '001'
319                                         );
320 my $link2 = Bio::Annotation::DBLink->new(-database => 'there',
321                                         -primary_id => '002'
322                                         );
324 ok $citation->add_cross_reference ($link1), "add_cross_reference 1";
325 ok $citation->add_cross_reference ($link2), "add_cross_reference 2";
326 is ${ $citation->cross_references }[0]->database, 'here', "get cross_references";
327 is ${ $citation->cross_references }[1]->primary_id, '002', "get cross_references";
331 # Bio::Biblio::MedlineBookArticle
333 print "Testing Bio::Biblio::MedlineBookArticle ...\n" if $verbose;
334 $citation = Bio::Biblio::MedlineBookArticle->new();
335 @args = ();
336 $count = 1;
337 foreach my $method (@scalar_methods_for_ref,
338                     @scalar_methods_for_article,
339                     @scalar_methods_for_bookarticle,
340                     @scalar_methods_for_medlinearticle,
341                     @scalar_methods_for_medlinebookarticle) {
342     $str = 'string' . ($count++);
343         is $citation->$method ($str), $str, "set '$method'";
344         is $citation->$method(), $str, "get '$method'";
345     push (@args, ("-$method" => $str));
348 ok defined ($biblio = Bio::Biblio::MedlineBookArticle->new(@args));
349 for (my $i = 0; $i < @args; $i += 2) {
350     my $method = substr ($args[$i], 1);
351         is $citation->$method(), $args[$i+1], $method;
353 foreach my $method (@other_methods_for_ref,
354                     @other_methods_for_article,
355                     @other_methods_for_bookarticle,
356                     @other_methods_for_medlinearticle,
357                     @other_methods_for_medlinebookarticle) {
358         is $citation->$method(), undef, "get '$method'";
363 # Bio::Biblio::MedlineBook
365 print "Testing Bio::Biblio::MedlineBook ...\n" if $verbose;
366 $citation = Bio::Biblio::MedlineBook->new();
367 @args = ();
368 $count = 1;
369 foreach my $method (@scalar_methods_for_ref,
370                     @scalar_methods_for_book,
371                     @scalar_methods_for_medlinebook) {
372     $str = 'string' . ($count++);
373         is $citation->$method ($str), $str, "set '$method'";
374         is $citation->$method(), $str, "get '$method'";
375     push (@args, ("-$method" => $str));
378 ok defined ($biblio = Bio::Biblio::MedlineBook->new(@args));
379 for (my $i = 0; $i < @args; $i += 2) {
380     my $method = substr ($args[$i], 1);
381         is $citation->$method(), $args[$i+1], $method;
383 foreach my $method (@other_methods_for_ref,
384                     @other_methods_for_book,
385                     @other_methods_for_medlinebook) {
386         is $citation->$method(), undef, "get '$method'";
390 # Bio::Biblio::MedlineJournal
392 print "Testing Bio::Biblio::MedlineJournal ...\n" if $verbose;
393 $citation = Bio::Biblio::MedlineJournal->new();
394 @args = ();
395 $count = 1;
396 foreach my $method (@scalar_methods_for_journal,
397                     @scalar_methods_for_medlinejournal) {
398     $str = 'string' . ($count++);
399         is $citation->$method ($str), $str, "set '$method'";
400         is $citation->$method(), $str, "get '$method'";
401     push (@args, ("-$method" => $str));
404 ok defined ($biblio = Bio::Biblio::MedlineJournal->new(@args));
405 for (my $i = 0; $i < @args; $i += 2) {
406     my $method = substr ($args[$i], 1);
407         is $citation->$method(), $args[$i+1], $method;
409 foreach my $method (@other_methods_for_journal,
410                     @other_methods_for_medlinejournal) {
411         is $citation->$method(), undef, "get '$method'";
415 # Bio::Biblio::Patent
417 print "Testing Bio::Biblio::Patent ...\n" if $verbose;
418 $citation = Bio::Biblio::Patent->new();
419 @args = ();
420 $count = 1;
421 foreach my $method (@scalar_methods_for_patent) {
422     $str = 'string' . ($count++);
423         is $citation->$method ($str), $str, "set '$method'";
424         is $citation->$method(), $str, "get '$method'";
425     push (@args, ("-$method" => $str));
428 ok defined ($biblio = Bio::Biblio::Patent->new(@args));
429 for (my $i = 0; $i < @args; $i += 2) {
430     my $method = substr ($args[$i], 1);
431         is $citation->$method(), $args[$i+1], $method;
433 foreach my $method (@other_methods_for_patent) {
434         is $citation->$method(), undef, "get '$method'";
438 # Bio::Biblio::WebResource
440 print "Testing Bio::Biblio::WebResource ...\n" if $verbose;
441 $citation = Bio::Biblio::WebResource->new();
442 @args = ();
443 $count = 1;
444 foreach my $method (@scalar_methods_for_webresource) {
445     $str = 'string' . ($count++);
446         is $citation->$method ($str), $str, "set '$method'";
447         is $citation->$method(), $str, "get '$method'";
448     push (@args, ("-$method" => $str));
451 ok defined ($biblio = Bio::Biblio::WebResource->new(@args));
452 for (my $i = 0; $i < @args; $i += 2) {
453     my $method = substr ($args[$i], 1);
454         is $citation->$method(), $args[$i+1], $method;
456 foreach my $method (@other_methods_for_webresource) {
457         is $citation->$method(), undef, "get '$method'";
462 # Bio::Biblio::Person
464 print "Testing Bio::Biblio::Person ...\n" if $verbose;
465 $provider = Bio::Biblio::Person->new();
466 @args = ();
467 $count = 1;
468 foreach my $method (@scalar_methods_for_provider,
469                     @scalar_methods_for_person) {
470     $str = 'string' . ($count++);
471         is $provider->$method ($str), $str, "set '$method'";
472         is $provider->$method(), $str, "get '$method'";
473     push (@args, ("-$method" => $str));
476 ok defined ($biblio = Bio::Biblio::Person->new(@args));
477 for (my $i = 0; $i < @args; $i += 2) {
478     my $method = substr ($args[$i], 1);
479         is $provider->$method(), $args[$i+1], $method;
483 # Bio::Biblio::Organisation
485 print "Testing Bio::Biblio::Organisation ...\n" if $verbose;
486 $provider = Bio::Biblio::Organisation->new();
487 @args = ();
488 $count = 1;
489 foreach my $method (@scalar_methods_for_provider,
490                     @scalar_methods_for_organisation) {
491     $str = 'string' . ($count++);
492         is $provider->$method ($str), $str, "set '$method'";
493         is $provider->$method(), $str, "get '$method'";
494     push (@args, ("-$method" => $str));
497 ok defined ($biblio = Bio::Biblio::Organisation->new(@args));
498 for (my $i = 0; $i < @args; $i += 2) {
499     my $method = substr ($args[$i], 1);
500         is $provider->$method(), $args[$i+1], $method;
504 # Bio::Biblio::Service
506 print "Testing Bio::Biblio::Service ...\n" if $verbose;
507 $provider = Bio::Biblio::Service->new();
508 @args = ();
509 $count = 1;
510 foreach my $method (@scalar_methods_for_provider,
511                     @scalar_methods_for_organisation) {
512     $str = 'string' . ($count++);
513         is $provider->$method ($str), $str, "set '$method'";
514         is $provider->$method(), $str, "get '$method'";
515     push (@args, ("-$method" => $str));
518 ok defined ($biblio = Bio::Biblio::Service->new(@args));
519 for (my $i = 0; $i < @args; $i += 2) {
520     my $method = substr ($args[$i], 1);
521         is $provider->$method(), $args[$i+1], $method;
525 # Bio::Biblio::PubmedJournalArticle
527 print "Testing Bio::Biblio::PubmedJournalArticle ...\n" if $verbose;
528 $citation = Bio::Biblio::PubmedJournalArticle->new();
529 @args = ();
530 $count = 1;
531 foreach my $method (@scalar_methods_for_pubmedarticle) {
532     $str = 'string' . ($count++);
533         is $citation->$method ($str), $str, "set '$method'";
534         is $citation->$method(), $str, "get '$method'";
535     push (@args, ("-$method" => $str));
538 ok defined ($biblio = Bio::Biblio::PubmedJournalArticle->new(@args));
539 for (my $i = 0; $i < @args; $i += 2) {
540     my $method = substr ($args[$i], 1);
541         is $citation->$method(), $args[$i+1], $method;
543 foreach my $method (@other_methods_for_pubmedarticle) {
544         is $citation->$method(), undef, "get '$method'";