getpdfurl fallback return + test case

This commit is contained in:
Federico Poloni
2016-07-31 15:06:52 +02:00
parent 1a289d262b
commit 0a59f63524
2 changed files with 33 additions and 0 deletions
+32
View File
@@ -297,6 +297,38 @@ class BTBTest extends PHPUnit_Framework_TestCase {
$dis = $db->getEntryByKey('aKey'); $dis = $db->getEntryByKey('aKey');
$this->assertEquals(2,count($dis->getKeywords())); $this->assertEquals(2,count($dis->getKeywords()));
} }
# https://github.com/monperrus/bibtexbrowser/pull/51
function test_emptyGetPdfLink() {
$bibtex = "
@article{aKey,
title={\`a Book},
author={Martin Monperrus},
publisher={Springer},
year=2009,
pages={42--4242},
number=1
}
@article{bKey,
url={magic},
}
@article{cKey,
pdf={magic2},
url={magic3}
}";
bibtexbrowser_configure('BIBTEXBROWSER_USE_LATEX2HTML', true);
$test_data = fopen('php://memory','x+');
fwrite($test_data, $bibtex);
fseek($test_data,0);
$db = new BibDataBase();
$db->update_internal("inline", $test_data);
$dis = $db->getEntryByKey('aKey');
$this->assertEquals("",$dis->GetPdfLink());
$dis = $db->getEntryByKey('bKey');
$this->assertEquals('<a href="magic">[pdf]</a>',$dis->GetPdfLink());
$dis = $db->getEntryByKey('cKey');
$this->assertEquals('<a href="magic2">[pdf]</a>',$dis->GetPdfLink());
}
} // end class } // end class
?> ?>
+1
View File
@@ -1213,6 +1213,7 @@ class BibEntry {
if ($this->hasField('file')) { if ($this->hasField('file')) {
return $this->getLink('file', $iconurl, $label); return $this->getLink('file', $iconurl, $label);
} }
return "";
} }