From 3be64ff9b9eaf38e2c3d17e2bb595582cbecee97 Mon Sep 17 00:00:00 2001 From: Martin Monperrus Date: Sun, 14 Aug 2016 22:38:10 +0200 Subject: [PATCH] adds tests for pages --- bibtexbrowser-test.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bibtexbrowser-test.php b/bibtexbrowser-test.php index ac19d6c..83e56fa 100755 --- a/bibtexbrowser-test.php +++ b/bibtexbrowser-test.php @@ -30,7 +30,7 @@ class BTBTest extends PHPUnit_Framework_TestCase { $test_data = fopen('php://memory','x+'); fwrite($test_data, "@book{aKey,title={A Book},author={Martin Monperrus},publisher={Springer},year=2009}\n" ."@book{aKey/withSlash,title={Slash Dangerous for web servers},author={Ap Ache},publisher={Springer},year=2009}\n" - ."@article{aKeyA,title={An Article},author={Foo Bar and Jane Doe},volume=5,journal=\"New Results\",year=2009}\n" + ."@article{aKeyA,title={An Article},author={Foo Bar and Jane Doe},volume=5,journal=\"New Results\",year=2009,pages={1-2}}\n" ); fseek($test_data,0); $btb = new BibDataBase(); @@ -63,6 +63,9 @@ class BTBTest extends PHPUnit_Framework_TestCase { function test_bibentry_to_html_article() { $btb = $this->createDB(); $first_entry=$btb->getEntryByKey('aKeyA'); + $this->assertEquals("1-2",$first_entry->getField("pages")); + $this->assertEquals("1",$first_entry->getPages()[0]); + $this->assertEquals("2",$first_entry->getPages()[1]); // default style $this->assertEquals("An Article (Foo Bar and Jane Doe), In New Results, volume 5, 2009. [bibtex]",strip_tags($first_entry->toHTML())); @@ -70,11 +73,11 @@ class BTBTest extends PHPUnit_Framework_TestCase { // IEEE style bibtexbrowser_configure('BIBLIOGRAPHYSTYLE','JanosBibliographyStyle'); - $this->assertEquals("Foo Bar and Jane Doe, \"An Article\", In New Results, vol. 5, 2009.\n [bibtex]",strip_tags($first_entry->toHTML())); + $this->assertEquals("Foo Bar and Jane Doe, \"An Article\", In New Results, vol. 5, pp. 1-2, 2009.\n [bibtex]",strip_tags($first_entry->toHTML())); // Vancouver style bibtexbrowser_configure('BIBLIOGRAPHYSTYLE','VancouverBibliographyStyle'); - $this->assertEquals("Foo Bar and Jane Doe. An Article. New Results. 2009;5.\n [bibtex]",strip_tags($first_entry->toHTML())); + $this->assertEquals("Foo Bar and Jane Doe. An Article. New Results. 2009;5:1-2.\n [bibtex]",strip_tags($first_entry->toHTML())); } function testMultiSearch() {