new sfLuceneCategories($lucene, 'dd');
    $t->fail('__construct() must reject invalid writers');
} catch (Exception $e) {
    $t->pass('__construct() must reject invalid writers');
}
try {
    $c = new sfLuceneCategories($lucene, $writer);
    $t->pass('__construct() must accept valid writers');
} catch (Exception $e) {
    $t->fail('__construct() must accept valid writers');
    $t->skip('the previous test must pass to continue');
    die;
}
$t->is($c->getAllCategories(), array(), '->getAllCategories() returns an empty array in the beginning');
$t->diag('testing ->getCategory()');
$category = $c->getCategory('foo');
$t->ok($category instanceof sfLuceneCategory, '->getCategory() returns an instance of sfLuceneCategory');
$t->is($category->getName(), 'foo', '->getCategory() returns a category with the correct name');
$t->is($category->getCount(), 0, '->getCategory() returns a category with a default score of 0');
$t->ok($category->getHolder() === $c, '->getCategory()->getHolder() returns the same instance as the holder');
$t->ok($category === $c->getCategory('foo'), '->getCategory() returns the same category each time, for a given name');
$t->diag('testing ->save()');
$category->add(10);
$t->ok($c->isModified(), 'modifying a category flags the holder for modification');
$c->save();
$t->is($writer->read(), '$categories = array();$categories[\'foo\'] = 10;', '->save() writes the changes to the writer');
$c->getCategory('bar')->add(2)->getHolder()->save();
$t->is($writer->read(), '$categories = array();$categories[\'foo\'] = 10;$categories[\'bar\'] = 2;', '->save() writes multiple changes to the writer');
$t->ok($c->isModified() == false, '->save() resets the modification flag');
$writer->write('foobarbaz');
$c->save();