$t->fail('->getQuery() throws an exception if a field is a real column and neither a column nor type method exists');
} catch (Exception $e) {
    $t->pass('->getQuery() throws an exception if a field is a real column and neither a column nor type method exists');
}
// BC with symfony 1.2
$filter = new TestFormFilter();
$filter->bind(array('nomethod' => 'nomethod'));
try {
    $filter->getQuery();
    $t->pass('->getQuery() does not throw an exception when a value without a query method is passed');
} catch (Exception $e) {
    $t->fail('->getQuery() does not throw an exception when a value without a query method is passed');
}
// new in symfony 1.3
$filter = new TestFormFilter();
$filter->bind(array('name' => 'Kris Wallsmith'));
$filter->getQuery();
$t->is_deeply($filter->processedFields, array('name'), '->getQuery() processes fields not specified in getFields()');
$t->diag('->setTableMethod()');
$filter = new ArticleFormFilter();
$filter->setTableMethod('getNewQuery');
$filter->bind(array());
$t->is_deeply($filter->getQuery()->getDqlPart('select'), array('title, body'), '->setTableMethod() specifies a method that can return a new query');
$filter = new ArticleFormFilter();
$filter->setTableMethod('filterSuppliedQuery');
$filter->bind(array());
$t->is_deeply($filter->getQuery()->getDqlPart('select'), array('title, body'), '->setTableMethod() specifies a method that can modify the supplied query');
$filter = new ArticleFormFilter();
$filter->setTableMethod('filterSuppliedQueryAndReturn');
$filter->bind(array());
$t->is_deeply($filter->getQuery()->getDqlPart('select'), array('title, body'), '->setTableMethod() specifies a method that can modify and return the supplied query');
示例#2
0
$filter->bind(array('nomethod' => 'nomethod'));
try {
    $filter->getQuery();
    $t->pass('->getQuery() does not throw an exception when a value without a query method is passed');
} catch (Exception $e) {
    $t->fail('->getQuery() does not throw an exception when a value without a query method is passed');
}
// new in symfony 1.3
$filter = new TestFormFilter();
$filter->bind(array('name' => 'Kris Wallsmith'));
$filter->getQuery();
$t->is_deeply($filter->processedFields, array('name'), '->getQuery() processes fields not specified in getFields()');
// pass 0 to number filter
$filter = new TestFormFilter();
$filter->bind(array('author_id' => array('text' => 0)));
$query = $filter->getQuery();
$t->is(trim($query->getDql()), 'FROM Article r WHERE r.author_id = ?', '->getQuery() filters by a 0 number');
$t->is($query->getFlattenedParams(), array(0), '->getQuery() filters by a 0 number');
$t->diag('->setTableMethod()');
$filter = new ArticleFormFilter();
$filter->setTableMethod('getNewQuery');
$filter->bind(array());
$t->is_deeply($filter->getQuery()->getDqlPart('select'), array('title, body'), '->setTableMethod() specifies a method that can return a new query');
$filter = new ArticleFormFilter();
$filter->setTableMethod('filterSuppliedQuery');
$filter->bind(array());
$t->is_deeply($filter->getQuery()->getDqlPart('select'), array('title, body'), '->setTableMethod() specifies a method that can modify the supplied query');
$filter = new ArticleFormFilter();
$filter->setTableMethod('filterSuppliedQueryAndReturn');
$filter->bind(array());
$t->is_deeply($filter->getQuery()->getDqlPart('select'), array('title, body'), '->setTableMethod() specifies a method that can modify and return the supplied query');