From ece267fe94b8ab84fdae5ba72c100f80aa13511e Mon Sep 17 00:00:00 2001 From: Martin Monperrus Date: Wed, 28 Jun 2017 19:08:49 +0200 Subject: [PATCH] fix travis issue --- bibacid-utf8.bib | 5 +++++ bibtexbrowser-test.php | 18 +++++++++++++++++- bibtexbrowser.php | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/bibacid-utf8.bib b/bibacid-utf8.bib index 313e3a1..1c04146 100755 --- a/bibacid-utf8.bib +++ b/bibacid-utf8.bib @@ -224,3 +224,8 @@ MRREVIEWER = {Jean-Fran{\c{c}}ois Clouet}, year = 2015 } +@article{kjsdf 8, + title = "Entry with + in the key", + author = "Foo Bar", + year = 2017 +} diff --git a/bibtexbrowser-test.php b/bibtexbrowser-test.php index dd89e1c..2d7c72d 100755 --- a/bibtexbrowser-test.php +++ b/bibtexbrowser-test.php @@ -10,6 +10,11 @@ $ phpunit --coverage-html ./coverage btb-test.php (be sure that xdebug is enabled: /etc/php5/cli/conf.d# ln -s ../../mods-available/xdebug.ini) */ +// backward compatibility +if (!class_exists('PHPUnit_Framework_TestCase')) { + class_alias('\PHPUnit\Framework\TestCase', 'PHPUnit_Framework_TestCase'); +} + function exception_error_handler($severity, $message, $file, $line) { if ($severity != E_ERROR) { //trigger_error($message); @@ -93,6 +98,7 @@ class BTBTest extends PHPUnit_Framework_TestCase { $this->assertEquals("2",$first_entry->getPages()[1]); // default style + bibtexbrowser_configure('BIBLIOGRAPHYSTYLE','DefaultBibliographyStyle'); $this->assertEquals("An Article (Foo Bar and Jane Doe), In New Results, volume 5, 2009. [bibtex]",strip_tags($first_entry->toHTML())); $this->assertEquals('An Article ( and ), In New Results, volume 5, . [bibtex]',$first_entry->toHTML()); @@ -268,6 +274,7 @@ class BTBTest extends PHPUnit_Framework_TestCase { } function test_link_configuration() { + bibtexbrowser_configure('BIBTEXBROWSER_LINKS_TARGET','_self'); $test_data = fopen('php://memory','x+'); fwrite($test_data, "@book{aKey,pdf={myarticle.pdf}}\n" ); @@ -283,6 +290,7 @@ class BTBTest extends PHPUnit_Framework_TestCase { // see https://github.com/monperrus/bibtexbrowser/pull/14 function test_zotero() { + bibtexbrowser_configure('BIBTEXBROWSER_LINKS_TARGET','_self'); $test_data = fopen('php://memory','x+'); fwrite($test_data, "@book{aKey,file={myarticle.pdf}}\n" ); @@ -295,7 +303,8 @@ class BTBTest extends PHPUnit_Framework_TestCase { // https://github.com/monperrus/bibtexbrowser/issues/40 function test_doi_url() { - $test_data = fopen('php://memory','x+'); + bibtexbrowser_configure('BIBTEXBROWSER_LINKS_TARGET','_self'); + $test_data = fopen('php://memory','x+'); fwrite($test_data, "@Article{Baldwin2014Quantum,Doi={10.1103/PhysRevA.90.012110},Url={http://link.aps.org/doi/10.1103/PhysRevA.90.012110}}" ); fseek($test_data,0); @@ -375,6 +384,7 @@ class BTBTest extends PHPUnit_Framework_TestCase { # https://github.com/monperrus/bibtexbrowser/pull/51 function test_emptyGetPdfLink() { + bibtexbrowser_configure('BIBTEXBROWSER_LINKS_TARGET','_self'); $bibtex = " @article{aKey, title={\`a Book}, @@ -460,6 +470,9 @@ class BTBTest extends PHPUnit_Framework_TestCase { function test_parsing_author_list() { // specify parsing of author list + bibtexbrowser_configure('USE_COMMA_AS_NAME_SEPARATOR_IN_OUTPUT', false); + bibtexbrowser_configure('USE_FIRST_THEN_LAST', false); + // default case: one authors $bibtex = "@article{aKey61,title={An article Book},author = {Meyer, Heribert}}\n"; $test_data = fopen('php://memory','x+'); @@ -512,6 +525,8 @@ class BTBTest extends PHPUnit_Framework_TestCase { } function test_homepage_link() { + bibtexbrowser_configure('USE_COMMA_AS_NAME_SEPARATOR_IN_OUTPUT', false); + bibtexbrowser_configure('USE_FIRST_THEN_LAST', false); $bibtex = "@string{hp_MartinMonperrus={http://www.monperrus.net/martin},hp_FooAcé={http://example.net/}},@article{aKey61,title={An article Book},author = {Martin Monperrus and Foo Acé and Monperrus, Martin}}\n"; $test_data = fopen('php://memory','x+'); fwrite($test_data, $bibtex); @@ -612,6 +627,7 @@ class BTBTest extends PHPUnit_Framework_TestCase { } function testscholarlink() { + bibtexbrowser_configure('BIBTEXBROWSER_LINKS_TARGET','_self'); bibtexbrowser_configure('BIBTEXBROWSER_BIBTEX_VIEW', 'original'); $bibtex = "@article{key,title={An article Book},gsid={1234},author = {Martin Monperrus and Foo Ac\'e and Monperrus, Martin}}"; $test_data = fopen('php://memory','x+'); diff --git a/bibtexbrowser.php b/bibtexbrowser.php index 74ce4ad..7ddaefa 100755 --- a/bibtexbrowser.php +++ b/bibtexbrowser.php @@ -2469,7 +2469,7 @@ function VancouverBibliographyStyle(&$bibentry) { } // Ensure punctuation mark at title's end - if (strpos(":.;,?!", substr(rtrim($title), -1)) > 0) { + if (strlen(rtrim($title))>0 && strpos(":.;,?!", substr(rtrim($title), -1)) > 0) { $title = $title . ' '; } else { $title = $title . '. ';