} catch (Exception $e) { $t->fail('__construct() accepts valid search instances and valid models'); } $t->diag('testing ->insert(), fields'); $h->get('fields')->get('title')->set('type', 'foobar'); try { $indexer->insert(); $t->fail('->insert() fails if a field has an invalid type'); } catch (Exception $e) { $t->pass('->insert() fails if a field has an invalid type'); } $h->get('fields')->get('title')->set('type', 'keyword'); $indexer->delete(); $indexer->insert(); $lucene->commit(); $doc = getDoc($lucene, $indexer->getModelGuid()); $t->ok($doc->getDocument()->getField('title')->isStored, 'field type "Keyword" is stored'); $t->ok($doc->getDocument()->getField('title')->isIndexed, 'field type "Keyword" is indexed'); $t->ok(!$doc->getDocument()->getField('title')->isTokenized, 'field type "Keyword" is not tokenized'); $t->ok(!$doc->getDocument()->getField('title')->isBinary, 'field type "Keyword" is not binary'); $h->get('fields')->get('title')->set('type', 'unindexed'); $indexer->delete(); $indexer->insert(); $lucene->commit(); $doc = getDoc($lucene, $indexer->getModelGuid()); $t->ok($doc->getDocument()->getField('title')->isStored, 'field type "Unindexed" is stored'); $t->ok(!$doc->getDocument()->getField('title')->isIndexed, 'field type "Unindexed" is not indexed'); $t->ok(!$doc->getDocument()->getField('title')->isTokenized, 'field type "Unindexed" is not tokenized'); $t->ok(!$doc->getDocument()->getField('title')->isBinary, 'field type "Unindexed" is not binary'); $h->get('fields')->get('title')->set('type', 'binary'); $indexer->delete();