Add tests for ideogram searching. ft_min_word_len must be 2 or less.

This commit is contained in:
Colin Kuskie 2009-08-21 21:29:43 +00:00
parent d9cf707963
commit ea51ba559e
4 changed files with 36 additions and 3 deletions

View file

@ -17,6 +17,7 @@ use FindBin;
use strict;
use lib "$FindBin::Bin/lib";
use Test::More;
use Test::Deep;
use WebGUI::Test; # Must use this before any other WebGUI modules
use WebGUI::Session;
@ -28,12 +29,13 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
plan tests => 7; # Increment this number for each test you create
plan tests => 10; # Increment this number for each test you create
#----------------------------------------------------------------------------
# put your tests here
use_ok('WebGUI::Search');
use_ok('WebGUI::Search::Index');
my $search = WebGUI::Search->new($session);
@ -50,6 +52,32 @@ ok( $search->_isStopword('anybody+'), '_isStopword: regex metacharacter +
ok( $search->_isStopword('maybe?'), '_isStopword: regex metacharacter ? does not crash the search');
ok(! $search->_isStopword('private.+'), '_isStopword: regex metacharacters .+ do not crash the search');
################################################
#
# Chinese ideograph handling
#
################################################
{
use utf8;
# Create an article to index
my $article = WebGUI::Asset->getImportNode( $session )->addChild( {
className => 'WebGUI::Asset::Wobject::Article',
title => 'Chinese ideograph experiment',
description => "甲骨文",
} );
my $tag = WebGUI::VersionTag->getWorking( $session );
$tag->commit;
WebGUI::Test->tagsToRollback($tag);
WebGUI::Search::Index->create( $article );
my $searcher = WebGUI::Search->new($session);
my $assetIds = $searcher->search({ keywords => "甲", })->getAssetIds;
cmp_deeply( $assetIds, [ $article->getId ], 'basic test for search works');
my $searcher = WebGUI::Search->new($session);
my $assetIds = $searcher->search({ keywords => "Chinese", })->getAssetIds;
cmp_deeply( $assetIds, [ $article->getId ], 'ideograph search works');
}
#----------------------------------------------------------------------------
# Cleanup
END {