|
| 1 | +<?php |
| 2 | + |
| 3 | +use Scriptotek\Marc\Record; |
| 4 | +use Scriptotek\Marc\Fields\Title; |
| 5 | + |
| 6 | +class TitleFieldTest extends \PHPUnit_Framework_TestCase |
| 7 | +{ |
| 8 | + /* |
| 9 | + In records formulated according to ISBD principles, subfield $b contains |
| 10 | + all the data following the first mark of ISBD punctuation and up to and |
| 11 | + including the mark of ISBD punctuation that introduces the first author |
| 12 | + statement (i.e., the first slash (/)) or precedes either the number |
| 13 | + (subfield $n) or the name (subfield $p) of a part/section of a work. Note |
| 14 | + that subfield $b is not repeated when more than one parallel title, |
| 15 | + subsequent title, and/or other title information are given in the field. |
| 16 | +
|
| 17 | + 1. Title and statement of responsibility area: |
| 18 | +
|
| 19 | + = Parallel title R |
| 20 | + : Other title information R |
| 21 | + Statement of responsibility: |
| 22 | + / First statement MA |
| 23 | + ; Subsequent statement R |
| 24 | + ; Subsequent title by same author, etc. MA R |
| 25 | + . Subsequent title by different author, etc. MA R |
| 26 | + */ |
| 27 | + |
| 28 | + public function testIsbdUsStyle() |
| 29 | + { |
| 30 | + // ISBD style: US |
| 31 | + // Title components: [Main title, Other title information, Other title information] |
| 32 | + $field = new File_MARC_Data_Field('245', array( |
| 33 | + new File_MARC_Subfield('a', 'Eternal darkness :'), |
| 34 | + new File_MARC_Subfield('b', 'sanity\'s requiem : Prima\'s official strategy guide /'), |
| 35 | + new File_MARC_Subfield('c', 'the Stratton Bros.'), |
| 36 | + )); |
| 37 | + $title = new Title($field); |
| 38 | + $this->assertEquals('Eternal darkness : sanity\'s requiem : Prima\'s official strategy guide', strval($title)); |
| 39 | + } |
| 40 | + |
| 41 | + public function testIsbdUkStyle() |
| 42 | + { |
| 43 | + // ISBD style: UK |
| 44 | + // Title components: [Main title, Other title information, Other title information] |
| 45 | + $field = new File_MARC_Data_Field('245', array( |
| 46 | + new File_MARC_Subfield('a', 'Eternal darkness'), |
| 47 | + new File_MARC_Subfield('b', 'sanity\'s requiem : Prima\'s official strategy guide'), |
| 48 | + new File_MARC_Subfield('c', 'the Stratton Bros.'), |
| 49 | + )); |
| 50 | + $title = new Title($field); |
| 51 | + $this->assertEquals('Eternal darkness : sanity\'s requiem : Prima\'s official strategy guide', strval($title)); |
| 52 | + } |
| 53 | + |
| 54 | + public function testParallelTitleUs() |
| 55 | + { |
| 56 | + // ISBD style: US |
| 57 | + // Title components: Main title, Parallel title |
| 58 | + $field = new File_MARC_Data_Field('245', array( |
| 59 | + new File_MARC_Subfield('a', 'Lageru ='), |
| 60 | + new File_MARC_Subfield('b', 'The land of eternal darkness /'), |
| 61 | + new File_MARC_Subfield('c', 'Kwak Pyŏng-gyu chŏ.'), |
| 62 | + )); |
| 63 | + $title = new Title($field); |
| 64 | + $this->assertEquals('Lageru = The land of eternal darkness', strval($title)); |
| 65 | + } |
| 66 | + |
| 67 | + public function testParallelTitleUk() |
| 68 | + { |
| 69 | + // ISBD style: UK (note: = mark still included) |
| 70 | + // Components: Main title, Parallel title |
| 71 | + $field = new File_MARC_Data_Field('245', array( |
| 72 | + new File_MARC_Subfield('a', 'Byggekunst ='), |
| 73 | + new File_MARC_Subfield('b', 'The Norwegian review of architecture'), |
| 74 | + new File_MARC_Subfield('c', 'Norske arkitekters landsforbund'), |
| 75 | + )); |
| 76 | + $title = new Title($field); |
| 77 | + $this->assertEquals('Byggekunst = The Norwegian review of architecture', strval($title)); |
| 78 | + } |
| 79 | + |
| 80 | + public function testIsbdSymbolsInTitle() |
| 81 | + { |
| 82 | + # http://lccn.loc.gov/2006589502 |
| 83 | + # Here, the = does not indicate the start of a parallel title, but is part of the title. |
| 84 | + # How can we know?? Because it don't have a space in front? |
| 85 | + $field = new File_MARC_Data_Field('245', array( |
| 86 | + new File_MARC_Subfield('a', '2 + 2 = 5 :'), |
| 87 | + new File_MARC_Subfield('b', 'innovative ways of organising people in the Australian Public Service.'), |
| 88 | + )); |
| 89 | + $title = new Title($field); |
| 90 | + $this->assertEquals('2 + 2 = 5 : innovative ways of organising people in the Australian Public Service.', strval($title)); |
| 91 | + } |
| 92 | + |
| 93 | + public function testMultipleTitles() |
| 94 | + { |
| 95 | + # http://lccn.loc.gov/2006589502 |
| 96 | + # An example of where we really shouldn't strip of the final dot(s) |
| 97 | + $field = new File_MARC_Data_Field('245', array( |
| 98 | + new File_MARC_Subfield('a', 'Hamlet ;'), |
| 99 | + new File_MARC_Subfield('b', 'Romeo and Juliette ; Othello ...'), |
| 100 | + )); |
| 101 | + $title = new Title($field); |
| 102 | + $this->assertEquals('Hamlet ; Romeo and Juliette ; Othello ...', strval($title)); |
| 103 | + } |
| 104 | + |
| 105 | + public function testTitleWithPart() |
| 106 | + { |
| 107 | + $field = new File_MARC_Data_Field('245', array( |
| 108 | + new File_MARC_Subfield('a', 'Love from Joy :'), |
| 109 | + new File_MARC_Subfield('b', 'letters from a farmer’s wife.'), |
| 110 | + new File_MARC_Subfield('n', 'Part III,'), |
| 111 | + new File_MARC_Subfield('p', '1987-1995, At the bungalow.'), |
| 112 | + )); |
| 113 | + $title = new Title($field); |
| 114 | + $this->assertEquals('Love from Joy : letters from a farmer’s wife. Part III, 1987-1995, At the bungalow.', strval($title)); |
| 115 | + } |
| 116 | + |
| 117 | + public function testTitleWithMultiplePartSubfields() |
| 118 | + { |
| 119 | + $field = new File_MARC_Data_Field('245', array( |
| 120 | + new File_MARC_Subfield('a', 'Zentralblatt für Bakteriologie.'), |
| 121 | + new File_MARC_Subfield('n', '1. Abt. Originale.'), |
| 122 | + new File_MARC_Subfield('n', 'Reihe B,'), |
| 123 | + new File_MARC_Subfield('p', 'Hygiene, Krankenhaushygiene, Betriebshygiene, präventive Medizin.'), |
| 124 | + )); |
| 125 | + $title = new Title($field); |
| 126 | + $this->assertEquals('Zentralblatt für Bakteriologie. 1. Abt. Originale. Reihe B, Hygiene, Krankenhaushygiene, Betriebshygiene, präventive Medizin.', strval($title)); |
| 127 | + } |
| 128 | + |
| 129 | +} |
0 commit comments