# Copyright (c) 2006 bivio Software, Inc. All Rights Reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: Xapian.bunit,v 1.14 2010/04/24 21:37:44 nagler Exp $ Request(); my($files) = require('xapian.PL'); my($demo) = unauth_model('RealmOwner', {name => 'xapian_demo'}) ->get('realm_id'); my($guest) = unauth_model('RealmOwner', {name => 'xapian_guest'}) ->get('realm_id'); [ #TODO: cut off and stop words (the) class() => [ { method => 'query', compute_params => sub { my(undef, $params) = @_; return [{ req => req(), @{__PACKAGE__->map_together( sub {@_}, [qw( phrase offset length private_realm_ids public_realm_ids want_all_public )], $params, )}, }]; }, check_return => sub { my($case, $actual, $expect) = @_; $case->actual_return([sort(map($_->{primary_id}, @{$actual->[0]}))]); return [sort(map($files->[$_], @$expect))]; }, } => [ '"commonly worded"' => [], ['"commonly worded"', 0, 0, [$demo], undef, 1] => [0, 1, 4, 5], ['"place for"', 0, 0, [$demo], undef, 0] => [5, 4], ['"place for"', 0, 0, [$demo], undef, 1] => [5, 7, 4], ['"place for"', 0, 0, [$guest], undef, 0] => [7, 6], ['"place for"', 0, 0, [], undef, 1] => [7, 5], ['"place for"', 0, 0, [], [$demo]] => 5, ['"place for"', 0, 0, [$demo], [$guest]] => [7, 5, 4], ['abcz', 0, 0, [$demo]] => 1, sub { unauth_model('RealmFile', {realm_file_id => $files->[1]}) ->delete; commit(); return [{ req => req(), phrase => 'abcz', private_realm_ids => [$demo], }]; } => [], ['"0.txt"', 0, 0, [$demo], undef, 1] => [0], ['"/xapian/0.txt"', 0, 0, [$demo], undef, 1] => [0], ['".txt"', 0, 0, [$demo], undef, 1] => [0, 2, 3, 4, 5, 7], ['"00.txt"', 0, 0, [$demo], undef, 1] => undef, # TODO: Test update of simple fields and content ], ], ];