CitationTest
extends TestCase
in package
Uses
ViewTrait
CitationBuilder Test Class
Tags
Table of Contents
- $citations : array<string|int, mixed>
- Sample citations -- each element of this array contains three elements -- the raw input data and the expected apa/mla output citations.
- testCitations() : void
- Test citation generation
- getPathForTheme() : string
- Get the directory for a given theme.
- getPhpRenderer() : PhpRenderer
- Get a working renderer.
- getSearchMemoryViewHelper() : SearchMemory
- Get mock SearchMemory view helper
Properties
$citations
Sample citations -- each element of this array contains three elements -- the raw input data and the expected apa/mla output citations.
protected
array<string|int, mixed>
$citations
= [
// @codingStandardsIgnoreStart
['raw' => ['SecondaryAuthors' => ['Shafer, Kathleen Newton'], 'ShortTitle' => 'Medical-surgical nursing', 'Subtitle' => '', 'Edition' => '', 'PlacesOfPublication' => ['St. Louis'], 'Publishers' => ['Mosby'], 'PublicationDates' => ['1958']], 'apa' => 'Shafer, K. N. (1958). <i>Medical-surgical nursing</i>. Mosby.', 'mla' => 'Shafer, Kathleen Newton. <i>Medical-surgical Nursing</i>. Mosby, 1958.', 'chicago' => 'Shafer, Kathleen Newton. <i>Medical-surgical Nursing</i>. St. Louis: Mosby, 1958.'],
['raw' => ['SecondaryAuthors' => ['Lewis, S.M.'], 'ShortTitle' => 'Medical-surgical nursing', 'Subtitle' => 'assessment and management of clinical problems.', 'Edition' => '7th ed. /', 'PlacesOfPublication' => ['St. Louis, Mo.'], 'Publishers' => ['Mosby Elsevier'], 'PublicationDates' => ['2007']], 'apa' => 'Lewis, S. (2007). <i>Medical-surgical nursing: Assessment and management of clinical problems</i> (7th ed.). Mosby Elsevier.', 'mla' => 'Lewis, S.M. <i>Medical-surgical Nursing: Assessment and Management of Clinical Problems</i>. 7th ed. Mosby Elsevier, 2007.', 'chicago' => 'Lewis, S.M. <i>Medical-surgical Nursing: Assessment and Management of Clinical Problems</i>. 7th ed. St. Louis, Mo: Mosby Elsevier, 2007.'],
[
// subtitle embedded in title, with multi-word uncapped phrase, quoted word, and DOI added
'raw' => ['SecondaryAuthors' => ['Lewis, S.M.'], 'Title' => 'Even if you "test" Medical-surgical nursing: assessment and management of clinical problems on top of crazy capitalization.', 'Edition' => '7th ed. /', 'PlacesOfPublication' => ['St. Louis, Mo.'], 'Publishers' => ['Mosby Elsevier'], 'PublicationDates' => ['2007'], 'CleanDOI' => 'myDOI'],
'apa' => 'Lewis, S. (2007). <i>Even if you "test" Medical-surgical nursing: Assessment and management of clinical problems on top of crazy capitalization</i> (7th ed.). Mosby Elsevier. https://doi.org/myDOI',
'mla' => 'Lewis, S.M. <i>Even if You "Test" Medical-surgical Nursing: Assessment and Management of Clinical Problems on top of Crazy Capitalization</i>. 7th ed. Mosby Elsevier, 2007. https://doi.org/myDOI.',
'chicago' => 'Lewis, S.M. <i>Even if You "Test" Medical-surgical Nursing: Assessment and Management of Clinical Problems on top of Crazy Capitalization</i>. 7th ed. St. Louis, Mo: Mosby Elsevier, 2007. https://doi.org/myDOI.',
],
['raw' => ['SecondaryAuthors' => ['Lewis, S.M.'], 'ShortTitle' => 'Medical-surgical nursing', 'Subtitle' => 'assessment and management of clinical problems.', 'Edition' => '1st ed.', 'PlacesOfPublication' => ['St. Louis, Mo.'], 'Publishers' => ['Mosby Elsevier'], 'PublicationDates' => ['2007']], 'apa' => 'Lewis, S. (2007). <i>Medical-surgical nursing: Assessment and management of clinical problems</i>. Mosby Elsevier.', 'mla' => 'Lewis, S.M. <i>Medical-surgical Nursing: Assessment and Management of Clinical Problems</i>. Mosby Elsevier, 2007.', 'chicago' => 'Lewis, S.M. <i>Medical-surgical Nursing: Assessment and Management of Clinical Problems</i>. St. Louis, Mo: Mosby Elsevier, 2007.'],
['raw' => ['SecondaryAuthors' => ['Lewis, S.M., Weirdlynamed'], 'ShortTitle' => 'Medical-surgical nursing', 'Subtitle' => 'why?', 'Edition' => '7th ed.', 'PlacesOfPublication' => ['St. Louis, Mo.'], 'Publishers' => ['Mosby Elsevier'], 'PublicationDates' => ['2007']], 'apa' => 'Lewis, S. (2007). <i>Medical-surgical nursing: Why?</i> (7th ed.). Mosby Elsevier.', 'mla' => 'Lewis, S.M. <i>Medical-surgical Nursing: Why?</i> 7th ed. Mosby Elsevier, 2007.', 'chicago' => 'Lewis, S.M. <i>Medical-surgical Nursing: Why?</i> 7th ed. St. Louis, Mo: Mosby Elsevier, 2007.'],
['raw' => ['SecondaryAuthors' => ['Lewis, S.M., IV'], 'ShortTitle' => 'Medical-surgical nursing', 'Subtitle' => 'why?', 'Edition' => '1st ed.', 'PlacesOfPublication' => ['St. Louis, Mo.'], 'Publishers' => ['Mosby Elsevier'], 'PublicationDates' => ['2007']], 'apa' => 'Lewis, S., IV. (2007). <i>Medical-surgical nursing: Why?</i> Mosby Elsevier.', 'mla' => 'Lewis, S.M., IV. <i>Medical-surgical Nursing: Why?</i> Mosby Elsevier, 2007.', 'chicago' => 'Lewis, S.M., IV. <i>Medical-surgical Nursing: Why?</i> St. Louis, Mo: Mosby Elsevier, 2007.'],
['raw' => ['SecondaryAuthors' => ['Burch, Philip H., Jr.'], 'ShortTitle' => 'The New Deal to the Carter administration', 'Subtitle' => '', 'Edition' => '', 'PlacesOfPublication' => ['New York :'], 'Publishers' => ['Holmes & Meier,'], 'PublicationDates' => ['1980.']], 'apa' => 'Burch, P. H., Jr. (1980). <i>The New Deal to the Carter administration</i>. Holmes & Meier.', 'mla' => 'Burch, Philip H., Jr. <i>The New Deal to the Carter Administration</i>. Holmes & Meier, 1980.', 'chicago' => 'Burch, Philip H., Jr. <i>The New Deal to the Carter Administration</i>. New York: Holmes & Meier, 1980.'],
['raw' => ['SecondaryAuthors' => ['Burch, Philip H., Jr.', 'Coauthor, Fictional', 'Fakeperson, Third, III'], 'ShortTitle' => 'The New Deal to the Carter administration', 'Subtitle' => '', 'Edition' => '', 'PlacesOfPublication' => ['New York :'], 'Publishers' => ['Holmes & Meier,'], 'PublicationDates' => ['1980.']], 'apa' => 'Burch, P. H., Jr., Coauthor, F., & Fakeperson, T., III. (1980). <i>The New Deal to the Carter administration</i>. Holmes & Meier.', 'mla' => 'Burch, Philip H., Jr., et al. <i>The New Deal to the Carter Administration</i>. Holmes & Meier, 1980.', 'chicago' => 'Burch, Philip H., Jr., Fictional Coauthor, and Third Fakeperson, III. <i>The New Deal to the Carter Administration</i>. New York: Holmes & Meier, 1980.'],
['raw' => ['SecondaryAuthors' => ['Burch, Philip H., Jr.', 'Coauthor, Fictional', 'Fakeperson, Third, III', 'Mob, Writing', 'Manypeople, Letsmakeup'], 'ShortTitle' => 'The New Deal to the Carter administration', 'Subtitle' => '', 'Edition' => '', 'PlacesOfPublication' => '', 'Publishers' => '', 'PublicationDates' => ''], 'apa' => 'Burch, P. H., Jr., Coauthor, F., Fakeperson, T., III, Mob, W., & Manypeople, L. <i>The New Deal to the Carter administration</i>.', 'mla' => 'Burch, Philip H., Jr., et al. <i>The New Deal to the Carter Administration</i>.', 'chicago' => 'Burch, Philip H., Jr., Fictional Coauthor, Third Fakeperson, III, Writing Mob, and Letsmakeup Manypeople. <i>The New Deal to the Carter Administration</i>.'],
['raw' => ['SecondaryAuthors' => ['Burch, Philip H., Jr.', 'Anonymous, 1971-1973', 'Elseperson, Firstnamery, 1971-1973'], 'ShortTitle' => 'The New Deal to the Carter administration', 'Subtitle' => '', 'Edition' => '', 'PlacesOfPublication' => ['New York'], 'Publishers' => ['Holmes & Meier']], 'apa' => 'Burch, P. H., Jr., Anonymous, & Elseperson, F. <i>The New Deal to the Carter administration</i>. Holmes & Meier.', 'mla' => 'Burch, Philip H., Jr., et al. <i>The New Deal to the Carter Administration</i>. Holmes & Meier.', 'chicago' => 'Burch, Philip H., Jr., Anonymous, and Firstnamery Elseperson. <i>The New Deal to the Carter Administration</i>. New York: Holmes & Meier.'],
[
// eight authors, with a blend of formatting and extra punctuation/malformed dates
'raw' => ['SecondaryAuthors' => ['One, Person.', 'Person Two', 'Three, Person', 'Person Four.', 'Five, Person, 1900-1950', 'Six, Person 1910-1963', 'Person Seven', 'Person Eight 1900-1999'], 'ShortTitle' => 'Test Article', 'ContainerTitle' => 'Test Journal', 'ContainerVolume' => 1, 'ContainerIssue' => 7, 'PublicationDates' => ['1999'], 'ContainerStartPage' => 19, 'ContainerEndPage' => 21],
'apa' => 'One, P., Two, P., Three, P., Four, P., Five, P., Six, P., . . . Eight, P. (1999). Test Article. <i>Test Journal, 1</i>(7), 19-21.',
'mla' => 'One, Person, et al. "Test Article." <i>Test Journal</i>, vol. 1, no. 7, 1999, pp. 19-21.',
'chicago' => 'One, Person, Person Two, Person Three, Person Four, Person Five, Person Six, Person Seven, and Person Eight. "Test Article." <i>Test Journal</i> 1, no. 7 (1999): 19-21.',
],
[
// eight authors
'raw' => ['SecondaryAuthors' => ['One, Person', 'Two, Person', 'Three, Person', 'Four, Person', 'Five, Person', 'Six, Person', 'Seven, Person', 'Eight, Person'], 'ShortTitle' => 'Test Article', 'ContainerTitle' => 'Test Journal', 'ContainerVolume' => 1, 'ContainerIssue' => 7, 'PublicationDates' => ['1999'], 'ContainerStartPage' => 19, 'ContainerEndPage' => 21],
'apa' => 'One, P., Two, P., Three, P., Four, P., Five, P., Six, P., . . . Eight, P. (1999). Test Article. <i>Test Journal, 1</i>(7), 19-21.',
'mla' => 'One, Person, et al. "Test Article." <i>Test Journal</i>, vol. 1, no. 7, 1999, pp. 19-21.',
'chicago' => 'One, Person, Person Two, Person Three, Person Four, Person Five, Person Six, Person Seven, and Person Eight. "Test Article." <i>Test Journal</i> 1, no. 7 (1999): 19-21.',
],
[
// seven authors
'raw' => ['SecondaryAuthors' => ['One, Person', 'Two, Person', 'Three, Person', 'Four, Person', 'Five, Person', 'Six, Person', 'Seven, Person'], 'ShortTitle' => 'Test Article', 'ContainerTitle' => 'Test Journal', 'ContainerVolume' => 1, 'ContainerIssue' => 7, 'PublicationDates' => ['1999'], 'ContainerStartPage' => 19, 'ContainerEndPage' => 21],
'apa' => 'One, P., Two, P., Three, P., Four, P., Five, P., Six, P., & Seven, P. (1999). Test Article. <i>Test Journal, 1</i>(7), 19-21.',
'mla' => 'One, Person, et al. "Test Article." <i>Test Journal</i>, vol. 1, no. 7, 1999, pp. 19-21.',
'chicago' => 'One, Person, Person Two, Person Three, Person Four, Person Five, Person Six, and Person Seven. "Test Article." <i>Test Journal</i> 1, no. 7 (1999): 19-21.',
],
[
// six authors
'raw' => ['SecondaryAuthors' => ['One, Person', 'Two, Person', 'Three, Person', 'Four, Person', 'Five, Person', 'Six, Person'], 'ShortTitle' => 'Test Article', 'ContainerTitle' => 'Test Journal', 'ContainerVolume' => 1, 'ContainerIssue' => 7, 'PublicationDates' => ['1999'], 'ContainerStartPage' => 19, 'ContainerEndPage' => 21],
'apa' => 'One, P., Two, P., Three, P., Four, P., Five, P., & Six, P. (1999). Test Article. <i>Test Journal, 1</i>(7), 19-21.',
'mla' => 'One, Person, et al. "Test Article." <i>Test Journal</i>, vol. 1, no. 7, 1999, pp. 19-21.',
'chicago' => 'One, Person, Person Two, Person Three, Person Four, Person Five, and Person Six. "Test Article." <i>Test Journal</i> 1, no. 7 (1999): 19-21.',
],
[
// three authors, including one with a random trailing comma
'raw' => ['SecondaryAuthors' => ['One, Person,', 'Two, Person', 'Three, Person'], 'ShortTitle' => 'Test Article', 'ContainerTitle' => 'Test Journal', 'ContainerVolume' => 1, 'ContainerIssue' => 7, 'PublicationDates' => ['1999'], 'ContainerStartPage' => 19, 'ContainerEndPage' => 21],
'apa' => 'One, P., Two, P., & Three, P. (1999). Test Article. <i>Test Journal, 1</i>(7), 19-21.',
'mla' => 'One, Person, et al. "Test Article." <i>Test Journal</i>, vol. 1, no. 7, 1999, pp. 19-21.',
'chicago' => 'One, Person, Person Two, and Person Three. "Test Article." <i>Test Journal</i> 1, no. 7 (1999): 19-21.',
],
[
// two authors with birth dates in different formats, single-page article
'raw' => ['SecondaryAuthors' => ['One, Person, b. 1960', 'Two, Person, 1970-'], 'ShortTitle' => 'Test Article', 'ContainerTitle' => 'Test Journal', 'ContainerVolume' => 1, 'ContainerIssue' => 7, 'PublicationDates' => ['1999'], 'ContainerStartPage' => 19, 'ContainerEndPage' => 19],
'apa' => 'One, P., & Two, P. (1999). Test Article. <i>Test Journal, 1</i>(7), 19.',
'mla' => 'One, Person, and Person Two. "Test Article." <i>Test Journal</i>, vol. 1, no. 7, 1999, p. 19.',
'chicago' => 'One, Person, and Person Two. "Test Article." <i>Test Journal</i> 1, no. 7 (1999): 19.',
],
[
// two authors with no comma in first author's name (test no comma before and)
// and parenthetical note on second author (test it is removed)
'raw' => ['SecondaryAuthors' => ['IBM', 'Two, Person (Director), 1970-'], 'ShortTitle' => 'Test Article', 'ContainerTitle' => 'Test Journal', 'ContainerVolume' => 1, 'ContainerIssue' => 7, 'PublicationDates' => ['1999'], 'ContainerStartPage' => 19, 'ContainerEndPage' => 19],
'apa' => 'IBM & Two, P. (1999). Test Article. <i>Test Journal, 1</i>(7), 19.',
'mla' => 'IBM and Person Two. "Test Article." <i>Test Journal</i>, vol. 1, no. 7, 1999, p. 19.',
'chicago' => 'IBM and Person Two. "Test Article." <i>Test Journal</i> 1, no. 7 (1999): 19.',
],
[
// one author
'raw' => ['SecondaryAuthors' => ['One, Person'], 'ShortTitle' => 'Test Article', 'ContainerTitle' => 'Test Journal', 'ContainerVolume' => 1, 'ContainerIssue' => 7, 'PublicationDates' => ['1999'], 'ContainerStartPage' => 19, 'ContainerEndPage' => 21],
'apa' => 'One, P. (1999). Test Article. <i>Test Journal, 1</i>(7), 19-21.',
'mla' => 'One, Person. "Test Article." <i>Test Journal</i>, vol. 1, no. 7, 1999, pp. 19-21.',
'chicago' => 'One, Person. "Test Article." <i>Test Journal</i> 1, no. 7 (1999): 19-21.',
],
[
// eight authors in "first name first" format.
'raw' => ['SecondaryAuthors' => ['Person One b. 1960', 'Person Two 1869-', 'Person Three', 'Person Four', 'Person Five', 'Person Six', 'Person Seven', 'Person Eight'], 'ShortTitle' => 'Test Article', 'ContainerTitle' => 'Test Journal', 'ContainerVolume' => 1, 'ContainerIssue' => 7, 'PublicationDates' => ['1999'], 'ContainerStartPage' => 19, 'ContainerEndPage' => 21],
'apa' => 'One, P., Two, P., Three, P., Four, P., Five, P., Six, P., . . . Eight, P. (1999). Test Article. <i>Test Journal, 1</i>(7), 19-21.',
'mla' => 'One, Person, et al. "Test Article." <i>Test Journal</i>, vol. 1, no. 7, 1999, pp. 19-21.',
'chicago' => 'One, Person, Person Two, Person Three, Person Four, Person Five, Person Six, Person Seven, and Person Eight. "Test Article." <i>Test Journal</i> 1, no. 7 (1999): 19-21.',
],
[
// ten authors in "first name first" format.
'raw' => ['SecondaryAuthors' => ['Person One', 'Person Two', 'Person Three', 'Person Four', 'Person Five', 'Person Six', 'Person Seven', 'Person Eight', 'Person Nine', 'Person Ten'], 'ShortTitle' => 'Test Article', 'ContainerTitle' => 'Test Journal', 'ContainerVolume' => 1, 'ContainerIssue' => 7, 'PublicationDates' => ['1999'], 'ContainerStartPage' => 19, 'ContainerEndPage' => 21],
'apa' => 'One, P., Two, P., Three, P., Four, P., Five, P., Six, P., . . . Ten, P. (1999). Test Article. <i>Test Journal, 1</i>(7), 19-21.',
'mla' => 'One, Person, et al. "Test Article." <i>Test Journal</i>, vol. 1, no. 7, 1999, pp. 19-21.',
'chicago' => 'One, Person, et al. "Test Article." <i>Test Journal</i> 1, no. 7 (1999): 19-21.',
],
[
// DOI
'raw' => ['SecondaryAuthors' => ['One, Person'], 'ShortTitle' => 'Test Article', 'ContainerTitle' => 'Test Journal', 'ContainerVolume' => 1, 'ContainerIssue' => 7, 'PublicationDates' => ['1999'], 'ContainerStartPage' => 19, 'ContainerEndPage' => 21, 'CleanDOI' => 'testDOI'],
'apa' => 'One, P. (1999). Test Article. <i>Test Journal, 1</i>(7), 19-21. https://doi.org/testDOI',
'mla' => 'One, Person. "Test Article." <i>Test Journal</i>, vol. 1, no. 7, 1999, pp. 19-21, https://doi.org/testDOI.',
'chicago' => 'One, Person. "Test Article." <i>Test Journal</i> 1, no. 7 (1999): 19-21. https://doi.org/testDOI.',
],
]
Methods
testCitations()
Test citation generation
public
testCitations() : void
Return values
void —getPathForTheme()
Get the directory for a given theme.
protected
getPathForTheme(string $theme) : string
Parameters
- $theme : string
-
Theme directory name
Return values
string —getPhpRenderer()
Get a working renderer.
protected
getPhpRenderer([array<string|int, mixed> $plugins = [] ][, string $theme = 'bootstrap3' ]) : PhpRenderer
Parameters
- $plugins : array<string|int, mixed> = []
-
Custom VuFind plug-ins to register
- $theme : string = 'bootstrap3'
-
Theme directory to load from
Return values
PhpRenderer —getSearchMemoryViewHelper()
Get mock SearchMemory view helper
protected
getSearchMemoryViewHelper([Memory|null $memory = null ]) : SearchMemory
Parameters
- $memory : Memory|null = null
-
Optional search memory