コード例 #1
0
<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require_once dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new lime_test(8);
$handler = new sfFilterConfigHandler();
$handler->initialize();
$dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'sfFilterConfigHandler' . DIRECTORY_SEPARATOR;
// parse errors
$t->diag('parse errors');
$files = array($dir . 'no_class.yml');
try {
    $data = $handler->execute($files);
    $t->fail('filters.yml must have a "class" section for each filter entry');
} catch (sfParseException $e) {
    $t->like($e->getMessage(), '/with missing class key/', 'filters.yml must have a "class" section for each filter entry');
}
// no execution/rendering filter
foreach (array('execution', 'rendering') as $key) {
    $files = array($dir . sprintf('no_%s.yml', $key));
    try {
        $data = $handler->execute($files);
        $t->fail(sprintf('filters.yml must have a filter of type "%s"', $key));
    } catch (sfParseException $e) {
        $t->like($e->getMessage(), sprintf('/must register a filter of type "%s"/', $key), sprintf('filters.yml must have a filter of type "%s"', $key));