<?php

/**
 * Search_Service tests.
 */
include_once dirname(__FILE__) . '/../../bootstrap/bootstrap.php';
LimeAnnotationSupport::enable();
$t = new lime_test(14);
// @Before
$handler = $t->mock('Search_Handler_Interface');
$service = new Search_Service($handler);
// @After
unset($handler);
unset($service);
// @Test: commit() raise an exception when not in a transaction
$t->expect('sfException');
$service->commit();
// @Test : commit() calls the handler commit function when closing a transaction
$handler->commit()->once();
$handler->replay();
$service->beginTransaction();
$service->commit();
$handler->verify();
// @Test: transactions can be nested
$handler->commit()->never();
$handler->replay();
$service->beginTransaction();
$service->beginTransaction();
$service->commit();
$handler->verify();
$handler->reset();