diff --git a/.travis.yml b/.travis.yml index cc986f0..9a08353 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,13 +32,9 @@ script: - $WPCLI plugin install wp-publications --activate # there is no need to create a post, because one activation task of wp-publications is to create a fake post #- $WPCLI post create --post_title=test --post_content='[wp-publications bib="sample.bib" all=true]' + - cp bibtexbrowser.php ./wp-content/plugins/wp-publications/ - $WPCLI rest post list --slug=wp-publications-example --field=content | tee before.txt # do we still have the reference output? (useful for detecting changes in Wordpress or WP-CLI) (diff exits with 1 if there is a difference) - diff reference-output-wp-publications.txt before.txt - # now we take the newer version and we render again - - cp bibtexbrowser.php ./wp-content/plugins/wp-publications/ - - $WPCLI rest post list --slug=wp-publications-example --field=content | tee after.txt - # just to be sure, is there a difference with the previous version? - - diff before.txt after.txt sudo: false diff --git a/bibtexbrowser-test.php b/bibtexbrowser-test.php index 1f6b84e..4484dbb 100755 --- a/bibtexbrowser-test.php +++ b/bibtexbrowser-test.php @@ -746,6 +746,25 @@ class BTBTest extends PHPUnit_Framework_TestCase { $this->assertContains('[citations]', $entry->toHTML()); } + + function test_before() { + $bibtex = "@article{doe2000,title={An article},author={Jane Doe},journal={The Wordpress Journal},year=2000}@book{doo2001,title={A book},author={Jane Doe},year=2001}"; + $test_data = fopen('php://memory','x+'); + fwrite($test_data, $bibtex); + fseek($test_data,0); + $db = new BibDataBase(); + $_GET[Q_FILE] = 'sample.bib'; + $db->update_internal("inline", $test_data); + + $d = new SimpleDisplay(); + $d->setDB($db); + ob_start(); + $d->display(); + $output = ob_get_clean(); + $res = eval("return ".file_get_contents('reference-output-wp-publications.txt').";"); + $this->assertEquals(strip_tags($res['rendered']), "[wp-publications bib=sample.bib all=1] gives:\n".strip_tags($output)."\n"); + } + function test80() { // entries without year are at the top $bibtex = "@article{keyWithoutYear,title={First article},author = {Martin}},@article{key2,title={Second article},author = {Martin}, year=2007}"; @@ -782,6 +801,27 @@ class BTBTest extends PHPUnit_Framework_TestCase { } + function test_multiple_table() { + ob_start(); + + $btb = new BibDataBase(); + $btb->load('bibacid-utf8.bib'); + + $display = new SimpleDisplay($btb, array(Q_YEAR => '1997')); + $display->display(); + + $display = new SimpleDisplay($btb, array(Q_YEAR => '2010')); + $display->display(); + + $output = ob_get_clean(); + + // assertion: we have two tables in the output + $xml = new SimpleXMLElement("".$output.""); + $result = $xml->xpath('//table'); + $this->assertEquals(2,count($result)); + + } + } // end class diff --git a/bibtexbrowser.php b/bibtexbrowser.php index 0ed2f63..2bdb013 100755 --- a/bibtexbrowser.php +++ b/bibtexbrowser.php @@ -3122,6 +3122,12 @@ class SimpleDisplay { var $entries = array(); var $headingLevel = BIBTEXBROWSER_HTMLHEADINGLEVEL; + + function __construct($db = NULL, $query = NULL) { + if ($db == NULL) return; + $this->setEntries($db->multisearch($query)); + } + function incHeadingLevel ($by=1) { $this->headingLevel += $by; } @@ -3220,15 +3226,15 @@ class SimpleDisplay { echo 'Options: '.@implode(',',$this->options).'
'; } - if ($this->headingLevel == BIBTEXBROWSER_HTMLHEADINGLEVEL) { - echo "\n".''; - if (count($this->entries) == 1) { - echo count ($this->entries).' '.__('result'); - } else if (count($this->entries) != 0) { - echo count ($this->entries).' '.__('results'); - } - echo "\n"; - } +// if ($this->headingLevel == BIBTEXBROWSER_HTMLHEADINGLEVEL) { +// echo "\n".''; +// if (count($this->entries) == 1) { +// echo count ($this->entries).' '.__('result'); +// } else if (count($this->entries) != 0) { +// echo count ($this->entries).' '.__('results'); +// } +// echo "\n"; +// } print_header_layout(); $pred = NULL; diff --git a/reference-output-wp-publications.txt b/reference-output-wp-publications.txt index a8e3fd4..a1dfc38 100644 --- a/reference-output-wp-publications.txt +++ b/reference-output-wp-publications.txt @@ -1,7 +1,5 @@ array ( 'rendered' => '

[wp-publications bib=sample.bib all=1] gives:
- -2 results
2001
[2]A book (), . [bibtex]