try {
    $form = new DummyForm();
    $t->pass('__construct() with no arguments does not throw an exception');
} catch (Exception $e) {
    $t->fail('__construct() with no arguments does not throw an exception');
}
$t->diag('testing categories');
try {
    $form->setCategories('foo');
    $t->fail('->setCategories() rejects invalid inputs');
} catch (Exception $e) {
    $t->pass('->setCategories() rejects invalid inputs');
}
$formFreeze = clone $form;
try {
    $form->setCategories(array('foo', 'bar', 'baz'));
    $t->pass('->setCategories() accepts valid inputs');
} catch (Exception $e) {
    $t->fail('->setCategories() accepts valid inputs');
}
$t->is($form->hasCategories(), true, '->hasCategories() returns true when categories are set');
$t->is($form->setupCount, $formFreeze->setupCount + 1, '->setCategories() runs ->setup()');
$t->is($form->configureCount, $formFreeze->configureCount + 1, '->setCategories() runs ->configure()');
$t->is_deeply($form->getCategories(), array('foo', 'bar', 'baz'), '->getCategories() returns the categories');
try {
    $form->setCategories(array());
    $t->pass('->setCategories() accepts an empty array');
} catch (Exception $e) {
    $t->fail('->setCategories() accepts valid inputs');
}
$t->is($form->hasCategories(), false, '->hasCategories() returns true when categories are set');
 * @author Carl Vondrick
 * @version SVN: $Id: sfLucenePropelInitializerTest.php 7108 2008-01-20 07:44:42Z Carl.Vondrick $
 */
require dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new limeade_test(4, limeade_output::get());
$limeade = new limeade_sf($t);
$app = $limeade->bootstrap();
$luceneade = new limeade_lucene($limeade);
$luceneade->configure()->clear_sandbox()->load_models();
class FooBehavior extends sfPropelBehavior
{
    public static function getBehaviors()
    {
        return self::$behaviors;
    }
}
class FooMixer extends sfMixer
{
    public static function getMixins()
    {
        return self::$mixins;
    }
}
$t->diag('testing ::getInstance()');
$init = sfLucenePropelInitializer::getInstance();
$t->isa_ok($init, 'sfLucenePropelInitializer', '::getInstance() returns an instance of sfLucenePropelInitializer');
$t->is(sfLucenePropelInitializer::getInstance(), $init, '::getInstance() returns the same instance each time (singleton)');
$t->is_deeply(FooBehavior::getBehaviors(), array('search' => array('methods' => array(0 => array(0 => 'sfLucenePropelBehavior', 1 => 'saveIndex'), 1 => array(0 => 'sfLucenePropelBehavior', 1 => 'deleteIndex'), 2 => array(0 => 'sfLucenePropelBehavior', 1 => 'insertIndex')), 'hooks' => array(':save:pre' => array(0 => array(0 => 'sfLucenePropelBehavior', 1 => 'preSave')), ':save:post' => array(0 => array(0 => 'sfLucenePropelBehavior', 1 => 'postSave')), ':delete:pre' => array(0 => array(0 => 'sfLucenePropelBehavior', 1 => 'preDelete')), ':delete:post' => array(0 => array(0 => 'sfLucenePropelBehavior', 1 => 'postDelete'))))), '__construct() registers the correct methods and hooks');
$t->diag('testing ->setup()');
$init->setup('FakeModel');
$t->is_deeply(FooMixer::getMixins(), array('BaseFakeForum:save:pre' => array(0 => array(0 => 'sfLucenePropelBehavior', 1 => 'preSave')), 'BaseFakeForum:save:post' => array(0 => array(0 => 'sfLucenePropelBehavior', 1 => 'postSave')), 'BaseFakeForum:delete:pre' => array(0 => array(0 => 'sfLucenePropelBehavior', 1 => 'preDelete')), 'BaseFakeForum:delete:post' => array(0 => array(0 => 'sfLucenePropelBehavior', 1 => 'postDelete')), 'BaseFakeForum:saveIndex' => array(0 => array(0 => 'sfLucenePropelBehavior', 1 => 'saveIndex')), 'BaseFakeForum:deleteIndex' => array(0 => array(0 => 'sfLucenePropelBehavior', 1 => 'deleteIndex')), 'BaseFakeForum:insertIndex' => array(0 => array(0 => 'sfLucenePropelBehavior', 1 => 'insertIndex')), 'BaseFakeModel:save:pre' => array(0 => array(0 => 'sfLucenePropelBehavior', 1 => 'preSave')), 'BaseFakeModel:save:post' => array(0 => array(0 => 'sfLucenePropelBehavior', 1 => 'postSave')), 'BaseFakeModel:delete:pre' => array(0 => array(0 => 'sfLucenePropelBehavior', 1 => 'preDelete')), 'BaseFakeModel:delete:post' => array(0 => array(0 => 'sfLucenePropelBehavior', 1 => 'postDelete')), 'BaseFakeModel:saveIndex' => array(0 => array(0 => 'sfLucenePropelBehavior', 1 => 'saveIndex')), 'BaseFakeModel:deleteIndex' => array(0 => array(0 => 'sfLucenePropelBehavior', 1 => 'deleteIndex')), 'BaseFakeModel:insertIndex' => array(0 => array(0 => 'sfLucenePropelBehavior', 1 => 'insertIndex'))), '->setup() configures sfMixer correctly');
$t->ok(!is_dir(sfConfig::get('sf_data_dir') . '/index/testLucene/en'), 'Lucene directory does not initially exist');
try {
    $e = $t->no_exception('::getInstance() allows valid cultures');
    $lucene = sfLucene::getInstance('testLucene', 'en');
    $e->no();
} catch (Exception $ex) {
    $e->caught($ex);
}
$t->ok(is_dir(sfConfig::get('sf_data_dir') . '/index/testLucene/en'), '::getInstance() creates the index');
$stat = stat(sfConfig::get('sf_data_dir') . '/index/testLucene/en/segments.gen');
$lucene->unlatch();
unset($lucene);
try {
    $lucene = sfLucene::getInstance('testLucene', 'en');
    clearstatcache();
    $t->is_deeply(stat(sfConfig::get('sf_data_dir') . '/index/testLucene/en/segments.gen'), $stat, '::getInstance() again opens the index');
} catch (Exception $e) {
    $t->skip('::getInstance() agains opens the index');
}
try {
    $e = $t->exception('::getInstance() rejects invalid cultures');
    sfLucene::getInstance('testLucene', 'piglatin');
    $e->no();
} catch (Exception $ex) {
    $e->caught($ex);
}
try {
    $e = $t->exception('::getInstance() rejects invalid names');
    sfLucene::getInstance('badname', 'en');
    $e->no();
} catch (Exception $ex) {
 * @version SVN: $Id$
 */
require dirname(__FILE__) . '/../../../bootstrap/unit.php';
$t = new limeade_test(15, limeade_output::get());
$highlighter = new sfLuceneHighlighterMarkerDry();
try {
    $kw = new sfLuceneHighlighterKeywordNamedInsensitive($highlighter, 'FOOBAR');
    $t->pass('__construct() accepts a valid highlighter and valid name');
} catch (Exception $e) {
    $t->fail('__construct() accepts a valid highlighter and valid name');
}
$t->is($kw->getHighlighter(), $highlighter, '->getHighlighter() returns the correct highlighter');
$t->is($kw->getName(), 'FOOBAR', '->getName() returns the correct name');
$t->is($kw->getLength(), 6, '->getLength() returns the correct length');
$got = $kw->tokenize('Foobar is my favorite foobar, but it needs the bar to be foobar');
$expected = array(new sfLuceneHighlighterToken($kw, 'Foobar', 0, 6), new sfLuceneHighlighterToken($kw, 'foobar', 22, 28), new sfLuceneHighlighterToken($kw, 'foobar', 57, 63));
$t->is($got, $expected, '->tokenize() returns correct positions for case-insensitivity');
$t->is_deeply($kw->tokenize('nothing interesting here.  move along!'), array(), '->tokenize() returns nothing if it does not appear in the string');
$t->is($kw->tokenize('mr foobar, where are the foobars?'), array(new sfLuceneHighlighterToken($kw, 'foobar', 3, 9)), '->tokenize() only tokenizes exact matches');
$lighters = array(new sfLuceneHighlighterMarkerUppercase(), new sfLuceneHighlighterMarkerSprint('[h]%s[/h]'));
$harness = new sfLuceneHighlighterMarkerHarness($lighters);
$keywords = sfLuceneHighlighterKeywordNamedInsensitive::generate($harness, array('a', 'b', 'c'));
$t->is(count($keywords), 3, '::generate() returns the same number of initial keywords');
$t->ok($keywords[0]->getName() == 'a' && $keywords[1]->getName() == 'b' && $keywords[2]->getName() == 'c', '::generate() returns the keywords in the same order with the correct names');
$t->isa_ok($keywords[0], 'sfLuceneHighlighterKeywordNamedInsensitive', '::generate() returns instances of sfLuceneHighlighterKeywordNamedInsensitive');
$t->ok($keywords[0]->getHighlighter() === $lighters[0] && $keywords[1]->getHighlighter() == $lighters[1] && $keywords[2]->getHighlighter() == $lighters[0], '::generate() modulates on the same order as the harness');
$keywords = sfLuceneHighlighterKeywordNamedInsensitive::explode($harness, 'foobar António baz.....symf0ny');
$t->is(count($keywords), 4, '::explode() correctly splits the query into separate words');
$t->is($keywords[1]->getName(), 'António', '::explode() handles UTF8 strings correctly');
$t->is($keywords[2]->getName(), 'baz', '::explode() breaks correctly after a UTF8 string');
$t->is($keywords[3]->getName(), 'symf0ny', '::explode() breaks correctly after non-word but non-space character and handles numbers correctly');
/**
 * @package sfLucenePlugin
 * @subpackage Test
 * @author Carl Vondrick
 * @version SVN: $Id: sfLuceneAdvancedFormTest.php 7108 2008-01-20 07:44:42Z Carl.Vondrick $
 */
require dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new limeade_test(10, limeade_output::get());
$limeade = new limeade_sf($t);
$app = $limeade->bootstrap();
$t->diag('testing constructor');
try {
    $form = new sfLuceneAdvancedForm();
    $t->pass('__construct() with no arguments does not throw an exception');
} catch (Exception $e) {
    $t->fail('__construct() with no arguments does not throw an exception');
}
$t->diag('testing initialization');
$t->isa_ok($form->getWidgetSchema(), 'sfWidgetFormSchema', 'widget schema is appropriate type');
$t->isa_ok($form->getValidatorSchema(), 'sfValidatorSchema', 'validator schema is appropriate type');
$t->isa_ok($form->getWidgetSchema()->getFormFormatter(), 'sfLuceneWidgetFormatterAdvanced', 'formatter is appropriate type');
$t->diag('testing categories');
$categories = array('foo', 'bar', 'baz', 'foobar');
$form->setCategories($categories);
$t->ok($form->getWidgetSchema()->offsetExists('category'), '->setCategories() adds "category" key to widget schema');
$t->is_deeply($form->getWidgetSchema()->offsetGet('category')->getOption('choices'), $categories, '->setCategories() configures widget with correct choices');
$t->ok($form->getValidatorSchema()->offsetExists('category'), '->setCategories() adds "category" key to validator schema');
$t->is_deeply($form->getValidatorSchema()->offsetGet('category')->getOption('choices'), $categories, '->setCategories() configures validator with correct choices');
$form->setCategories(array());
$t->ok(!$form->getWidgetSchema()->offsetExists('category'), '->setCategories() removes "category" key from widget schema');
$t->ok(!$form->getValidatorSchema()->offsetExists('category'), '->setCategories() removes "category" key from validator schema');
    $results->setMaxPerPage(10);
    $t->pass('->setMaxPerPage() accepts an integer per page');
} catch (Exception $e) {
    $t->fail('->setMaxPerPage() accepts an integer per page');
}
$t->is($results->getPage(), 2, '->getPage() returns current page');
$t->is($results->getMaxPerPage(), 10, '->getMaxPerPage() returns the max per page');
$t->is($results->getNbResults(), 1001, '->getNbResults() returns the total number of results');
$t->ok($results->haveToPaginate(), '->haveToPaginate() returns correct value');
$results->setPage(0);
$t->is($results->getPage(), 1, '->setPage() to 0 sets the page to 1');
$results->setPage(100000);
$t->is($results->getPage(), 101, '->setPage() above to upper bound resets to last page');
$results->setPage(2);
$t->diag('testing ->getResults()');
$t->is_deeply($results->getResults()->toArray(), range(10, 20), '->getResults() returns the correct range');
$results->setPage(3);
$t->is_deeply($results->getResults()->toArray(), range(20, 30), '->getResults() returns the correct range after page change');
$results->setMaxPerPage(0);
$t->is_deeply($results->getResults()->toArray(), range(0, 1000), '->getResults() returns all results if the max per page is 0');
$results->setMaxPerPage(10);
$t->diag('testing page numbers');
$t->is($results->getFirstPage(), 1, '->getFirstPage() returns 1 as first page');
$t->is($results->getLastPage(), 101, '->getLastPage() returns the last page in the range');
$t->is($results->getNextPage(), 4, '->getNextPage() returns the next page');
$results->setPage(101);
$t->is($results->getNextPage(), 101, '->getNextPage() returns last page if at end');
$results->setPage(4);
$t->is($results->getPreviousPage(), 3, '->getPreviousPage() returns the previous page');
$results->setPage(1);
$t->is($results->getPreviousPage(), 1, '->getPreviousPage() returns the first page if at start');
    inst()->addProximity(37.7752, -122.4192, 0);
    $t->fail('->addProximity() rejects a zero proximity');
} catch (Exception $e) {
    $t->pass('->addProximity() rejects a zero proximity');
}
try {
    inst()->addProximity(37.7752, -122.4192, 90, 0);
    $t->fail('->addProximity() rejects a zero radius');
} catch (Exception $e) {
    $t->pass('->addProximity() rejects a zero radius');
}
$s = inst()->addProximity(37.7752, -122.4192, 200)->getQuery()->getSubqueries();
$s = $s[0]->getSubqueries();
$t->ok($s[0]->isInclusive(), '->addProximity() uses inclusive range queries');
$t->ok($s[1]->isInclusive(), '->addProximity() uses inclusive range queries');
$t->is_deeply(explode(chr(0), $s[0]->getLowerTerm()->key()), array('latitude', '35.9785590093'), '->addProximity() calculates correct lower bound latitude');
$t->is_deeply(explode(chr(0), $s[0]->getUpperTerm()->key()), array('latitude', '39.5718409907'), '->addProximity() calculates correct upper bound latitude');
$t->is_deeply(explode(chr(0), $s[1]->getLowerTerm()->key()), array('longitude', '-124.692219999'), '->addProximity() calculates correct lower bound longitude');
$t->is_deeply(explode(chr(0), $s[1]->getUpperTerm()->key()), array('longitude', '-120.146180001'), '->addProximity() calculates correct upper bound longitude');
$t->diag('testing sorting');
$sorts = inst()->addSortBy('foo', SORT_ASC, SORT_REGULAR)->addSortBy('bar', SORT_DESC, SORT_NUMERIC)->getSorts();
$t->is_deeply($sorts, array(array('field' => 'foo', 'order' => SORT_ASC, 'type' => SORT_REGULAR), array('field' => 'bar', 'order' => SORT_DESC, 'type' => SORT_NUMERIC)), '->addSortBy() correctly adds the sort fields');
$sorts = inst()->addAscendingSortBy('foo', SORT_STRING)->getSorts();
$t->is_deeply($sorts, array(array('field' => 'foo', 'order' => SORT_ASC, 'type' => SORT_STRING)), '->addAscendingSortBy() correctly adds a sort field');
$sorts = inst()->addDescendingSortBy('foo', SORT_STRING)->getSorts();
$t->is_deeply($sorts, array(array('field' => 'foo', 'order' => SORT_DESC, 'type' => SORT_STRING)), '->addDescendingSortBy() correctly adds a sort field');
$t->diag('testing scoring');
class FooScoring extends Zend_Search_Lucene_Search_Similarity_Default
{
}
$fooScoring = new FooScoring();
 */
require dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new limeade_test(5, limeade_output::get());
class Foo
{
}
function inst($app_configuration)
{
    return sfLuceneCriteria::newInstance();
}
$t->diag('testing constructors');
try {
    $criteria = new sfLuceneFacetsCriteria();
    $t->pass('__construct() takes a sfLucene instance');
} catch (Exception $e) {
    $t->fail('__construct() takes a sfLuce instance');
}
$t->isa_ok(sfLuceneFacetsCriteria::newInstance(), 'sfLuceneFacetsCriteria', '::newInstance() returns an sfLuceneFacetsCriteria object');
$t->diag('testing ->getQuery()');
$t->ok(is_string($criteria->getQuery()), '->getQuery() returns an instance a string');
$criteria->addFacetField('language');
$criteria->addFacetField('task');
$criteria->addFacetQuery('price:[0 TO 100]');
$criteria->addFacetQuery('price:[100 TO 200]');
$expected = array('fl' => array(0 => '*,score'), 'sort' => array(0 => 'score desc'), 'facet' => array(0 => 'true'), 'facet.field' => array(0 => 'language', 1 => 'task'), 'facet.query' => array(0 => 'price:[0 TO 100]', 1 => 'price:[100 TO 200]'));
$t->is_deeply($criteria->getParams(), $expected, '->getParams() return the parameters array');
$t->diag('testing ->addFacetField() and ->addFacetQuery() reset');
$criteria->addFacetField('another_field', true);
$criteria->addFacetQuery('the_price:[0 TO 100]', true);
$expected = array('fl' => array(0 => '*,score'), 'sort' => array(0 => 'score desc'), 'facet' => array(0 => 'true'), 'facet.field' => array(0 => 'another_field'), 'facet.query' => array(0 => 'the_price:[0 TO 100]'));
$t->is_deeply($criteria->getParams(), $expected, '->getParams() return the parameters array with reseted values');
<?php

/*
 * This file is part of the sfLucenePlugin package
 * (c) 2007 - 2008 Carl Vondrick <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
/**
 * @package sfLucenePlugin
 * @subpackage Test
 * @author Carl Vondrick
 * @version SVN: $Id: sfLuceneProjectConfigHandlerTest.php 7116 2008-01-20 22:43:28Z Carl.Vondrick $
 */
require dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new limeade_test(2, limeade_output::get());
$limeade = new limeade_sf($t);
$app = $limeade->bootstrap();
$luceneade = new limeade_lucene($limeade);
$luceneade->configure()->clear_sandbox()->load_models();
$config = new sfLuceneProjectConfigHandler();
$response = $config->execute(array($luceneade->data_dir . '/configTest/project.yml'));
file_put_contents(lime_test::get_temp_directory() . '/search.yml.php', $response);
require lime_test::get_temp_directory() . '/search.yml.php';
unlink(lime_test::get_temp_directory() . '/search.yml.php');
$t->ok(isset($config), '->execute() creates a $config variable');
$t->is_deeply($config, array('testLucene' => array('models' => array('FakeModel' => array('fields' => array('id' => array('type' => 'text', 'boost' => 1, 'transform' => NULL), 'title' => array('type' => 'text', 'boost' => 1, 'transform' => NULL), 'description' => array('type' => 'text', 'boost' => 3, 'transform' => NULL)), 'title' => 'title', 'description' => 'description', 'categories' => array(0 => 'Forum'), 'route' => 'forum/showForum?id=%id%', 'validator' => 'isIndexable', 'rebuild_limit' => 5, 'peer' => 'FakeForumPeer', 'partial' => 'forumResult', 'indexer' => NULL)), 'index' => array('encoding' => 'UTF-8', 'cultures' => array(0 => 'en', 1 => 'fr'), 'stop_words' => array(0 => 'and', 1 => 'the'), 'short_words' => 2, 'analyzer' => 'utf8num', 'case_sensitive' => false, 'mb_string' => true, 'param' => array()), 'interface' => array('categories' => true, 'advanced' => true), 'factories' => array('indexers' => array(), 'results' => array())), 'barLucene' => array('models' => array('FakeModel' => array('fields' => array(), 'partial' => NULL, 'route' => NULL, 'indexer' => NULL, 'title' => NULL, 'description' => NULL, 'peer' => 'FakeModelPeer', 'rebuild_limit' => 250, 'validator' => NULL, 'categories' => array())), 'index' => array('encoding' => 'utf-8', 'cultures' => array(0 => NULL), 'stop_words' => array(0 => 'a', 1 => 'an', 2 => 'at', 3 => ' the', 4 => 'and', 5 => 'or', 6 => 'is', 7 => 'am', 8 => 'are', 9 => 'of'), 'short_words' => 2, 'analyzer' => 'textnum', 'case_sensitive' => false, 'mb_string' => false, 'param' => array()), 'factories' => array('indexers' => array(), 'results' => array())), 'fooLucene' => array('models' => array(), 'index' => array('encoding' => 'utf-8', 'cultures' => array(0 => NULL), 'stop_words' => array(0 => 'a', 1 => 'an', 2 => 'at', 3 => ' the', 4 => 'and', 5 => 'or', 6 => 'is', 7 => 'am', 8 => 'are', 9 => 'of'), 'short_words' => 2, 'analyzer' => 'textnum', 'case_sensitive' => false, 'mb_string' => false, 'param' => array()), 'factories' => array('indexers' => array(), 'results' => array()))), '->execute() writes the correct configuration from the YAML file');
示例#10
0
    sfLucene::getInstance('badname', 'en', $app_configuration);
    $e->no();
} catch (Exception $ex) {
    $e->caught($ex);
}
$t->skip('->numDocs() TODO !! indicates index is empty');
$t->diag('testing ::getAllInstances()');
try {
    $e = $t->no_exception('::getAllInstance() executes without exception');
    $instances = sfLucene::getAllInstances($app_configuration);
    $e->no();
} catch (Exception $ex) {
    $instances = array();
    $e->caught($ex);
}
$t->is_deeply($instances, array(sfLucene::getInstance('index', 'en', $app_configuration), sfLucene::getInstance('index', 'fr', $app_configuration), sfLucene::getInstance('fooLucene', 'en', $app_configuration)), '::getAllInstances() returns all instances');
$t->is_deeply(sfLucene::getAllNames($app_configuration), array('index', 'fooLucene'), '::getAllNames() returns all configured names');
$t->diag('testing ->loadConfig()');
$lucene = sfLucene::getInstance('index', 'en', $app_configuration);
$h = $lucene->getParameterHolder();
$t->isa_ok($h, 'sfParameterHolder', '->getParameterHolder() returns a parameter holder');
$t->is($h->get('name'), 'index', 'property "name" is the name of the index');
$t->is($h->get('culture'), 'en', 'property "culture" is the culture of the index');
$t->is($h->get('enabled_cultures'), array('en', 'fr'), 'property "enabled_cultures" contains all enabled cultures');
$t->is($h->get('encoding'), 'UTF-8', 'property "encoding" is the encoding');
$t->is($h->get('mb_string'), true, 'property "mb_string" indicates if to use mb_string functions');
$t->isa_ok($h->get('models'), 'sfParameterHolder', 'property "models" is a sfParameterHolder');
$t->isa_ok($h->get('models')->get('FakeForum'), 'sfParameterHolder', 'properties of "models" are sfParameterHolders');
$m = $h->get('models')->get('FakeForum');
$t->is($m->get('title'), 'title', 'model property "title" is the correct title field');
$t->is($m->get('description'), 'description', 'model property "description" is the correct description field');
{
    public $name;
    public function __construct($a)
    {
        $this->name = $a;
    }
}
// create fake response
$standard_response = '{"responseHeader":{"status":0,"QTime":0},"response":{"numFound":3,"start":%s,"docs":[%s]}, %s}';
$expected_objects = array();
$results = array();
foreach (range(1, 3) as $num) {
    $results[] = sprintf('{"description":"symfony fan boy","id":%d,"name":"rande","sfl_guid":"GUID_%d","skills":["symfony","php","objective-c"]}', $num, $num);
}
// faceting stuff
$facets = '"facet_counts":{"facet_queries":{"name:[a TO z]":3},"facet_fields":{"sfl_model":{"User":1, "Group": 2}},"facet_dates":{}}';
$standard_response = sprintf($standard_response, 3, implode(", ", $results), $facets);
$response = new sfLuceneResponse($standard_response);
$search = sfLucene::getInstance('index', 'en', $app_configuration);
$results = new sfLuceneFacetsResults($response, $search);
$t->diag('testing facet queries');
$expected_queries = array("name:[a TO z]" => 3);
$t->is_deeply($results->getFacetQueries(), $expected_queries, '->getFacetQueries() returns the expected array');
$t->is_deeply($results->getFacetQuery("name:[a TO z]"), 3, '->getFacetQuery() returns the expected value');
$t->is_deeply($results->getFacetQuery("non_existant_facet"), null, '->getFacetQuery() return correct value on non existant facet');
$t->diag('testing facet fields');
$expected_fields = array('sfl_model' => array("User" => 1, "Group" => 2));
$t->is_deeply($results->getFacetFields(), $expected_fields, '->getFacetFields() returns the expected array');
$t->cmp_ok($results->getFacetsField('non_existant_field'), '===', null, '->getFacetsField() return null on non existant field');
$t->is_deeply($results->getFacetField('sfl_model'), array("User" => 1, "Group" => 2), '->getFacetField() return correct facet\'s value');
$t->is_deeply($results->getFacetField('non_existant_facet'), null, '->getFacetField() return correct value on non existant facet');
<?php

/*
 * This file is part of the sfLucenePlugin package
 * (c) 2007 - 2008 Carl Vondrick <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
/**
 * @package sfLucenePlugin
 * @subpackage Test
 * @author Carl Vondrick
 * @version SVN: $Id$
 */
require dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new limeade_test(2, limeade_output::get());
$config = new sfLuceneModuleConfigHandler();
$response = $config->execute(array(dirname(__FILE__) . '/../../fixtures/config/module.yml'));
file_put_contents(sys_get_temp_dir() . '/search.yml.php', $response);
require sys_get_temp_dir() . '/search.yml.php';
unlink(sys_get_temp_dir() . '/search.yml.php');
$t->ok(isset($actions), '->execute() creates a $actions variable');
$t->is_deeply($actions, array('testLucene' => array('bar' => array('security' => array('authenticated' => false, 'credentials' => array()), 'params' => array(), 'layout' => false), 'foo' => array('security' => array('authenticated' => true, 'credentials' => array('admin')), 'params' => array('foo' => 'bar', 'baz' => 'foobar'), 'layout' => true))), '->execute() writes the correct configuration from the YAML file');