From d14042b81b4e0e72b1e7f7b8df0f02af74cb8df8 Mon Sep 17 00:00:00 2001 From: Martin Monperrus Date: Sun, 26 Nov 2017 00:13:41 +0100 Subject: [PATCH] fix travis PHP7 --- .travis.yml | 2 ++ bibtexbrowser-test.php | 48 +++++++++++++++++++++++++----------------- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index e802053..8fb8394 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,8 @@ php: - '5.4' - '5.5' - '5.6' + - '7.0' + - '7.1' script: - curl -L -o reflectivedoc.php https://www.monperrus.net/martin/reflectivedoc.php.txt diff --git a/bibtexbrowser-test.php b/bibtexbrowser-test.php index 6c2f558..ce10a2a 100755 --- a/bibtexbrowser-test.php +++ b/bibtexbrowser-test.php @@ -24,25 +24,30 @@ function exception_error_handler($severity, $message, $file, $line) { } error_reporting(E_ALL); +// setup @copy('bibtexbrowser.local.php','bibtexbrowser.local.php.bak'); @unlink('bibtexbrowser.local.php'); -if(is_file('reflectivedoc.php')) { - set_error_handler("exception_error_handler"); - require('reflectivedoc.php'); - $_GET['library'] = 1; - foreach(getAllSnippetsInFile('bibtexbrowser.php') as $snippet) { - //echo $snippet; +class Nothing { + function main() {} +} +define('BIBTEXBROWSER_MAIN','Nothing'); +//require_once('bibtexbrowser.php'); + +set_error_handler("exception_error_handler"); +require('reflectivedoc.php'); +$nsnippet=0; +foreach(getAllSnippetsInFile('bibtexbrowser.php') as $snippet) { ob_start(); eval($snippet); ob_get_clean(); unset($_GET['bib']); - } - restore_error_handler(); -} else { - $_GET['library']=1; - require_once ('bibtexbrowser.php'); + $nsnippet++; } +if ($nsnippet!=19) { + die('oops '.$nsnippet); +} +restore_error_handler(); class SimpleDisplayExt extends SimpleDisplay { function setIndices() { @@ -53,6 +58,13 @@ class SimpleDisplayExt extends SimpleDisplay { class BTBTest extends PHPUnit_Framework_TestCase { + protected function setUp() + { + // resetting the default link style + bibtexbrowser_configure('BIBTEXBROWSER_LINK_STYLE','bib2links_default'); + bibtexbrowser_configure('ABBRV_TYPE','index'); + } + function test_checkdoc() { if(!is_file('gakowiki-syntax.php')) { return; } if (!function_exists('gk_wiki2html')) { include('gakowiki-syntax.php'); } @@ -150,9 +162,6 @@ class BTBTest extends PHPUnit_Framework_TestCase { bibtexbrowser_configure('ABBRV_TYPE','none'); $this->assertEquals("",$first_entry->getAbbrv()); - // resetting the default link style - bibtexbrowser_configure('BIBTEXBROWSER_LINK_STYLE','bib2links_default'); - } function testMultiSearch() { @@ -393,14 +402,15 @@ class BTBTest extends PHPUnit_Framework_TestCase { function test_PagedDisplay() { - $PAGE_SIZE = 3; + $PAGE_SIZE = 4; bibtexbrowser_configure('BIBTEXBROWSER_DEFAULT_DISPLAY', 'PagedDisplay'); bibtexbrowser_configure('PAGE_SIZE', $PAGE_SIZE); - $_GET['bib'] = 'bibacid-utf8.bib'; - $_GET['all'] = 1; - $d = new Dispatcher(); + $db = new BibDataBase(); + $db->load('bibacid-utf8.bib'); + $d = new PagedDisplay(); + $d->setEntries($db->bibdb); ob_start(); - $d->main(); + $d->display(); $content = "
".ob_get_clean()."
"; $xml = new SimpleXMLElement($content); $result = $xml->xpath('//td[@class=\'bibref\']');