コード例 #1
0
ファイル: smoketest.php プロジェクト: xapian/xapian
    exit(1);
}
set_error_handler("die_on_error", -1);
include "xapian.php";
# Test the version number reporting functions give plausible results.
$v = Xapian::major_version() . '.' . Xapian::minor_version() . '.' . Xapian::revision();
$v2 = Xapian::version_string();
if ($v != $v2) {
    print "Unexpected version output ({$v} != {$v2})\n";
    exit(1);
}
$db = new XapianWritableDatabase('', Xapian::DB_BACKEND_INMEMORY);
$db2 = new XapianWritableDatabase('', Xapian::DB_BACKEND_INMEMORY);
# Check PHP5 handling of Xapian::DocNotFoundError
try {
    $doc2 = $db->get_document(2);
    print "Retrieved non-existent document\n";
    exit(1);
} catch (Exception $e) {
    if ($e->getMessage() !== "DocNotFoundError: Docid 2 not found") {
        print "DocNotFoundError Exception string not as expected, got: '{$e->getMessage()}'\n";
        exit(1);
    }
}
# Check QueryParser parsing error.
try {
    $qp = new XapianQueryParser();
    $qp->set_stemmer(new XapianStem("en"));
    $qp->parse_query("test AND");
    print "Successfully parsed bad query\n";
    exit(1);