コード例 #1
0
ファイル: tests.php プロジェクト: idlesign/dja
<?php

require_once 'dja_bootstrap.php';
require_once 'utils.php';
require_once 'filters.php';
// We import loader modules beforehand to warm up.
import_module('loaders/filesystem');
import_module('loaders/app_directories');
// Set test URLs for Dja's generic URL dispatcher.
Dja::setUrlDispatcher(new DjaUrlDispatcher(array('~^/url_tag/client/(?P<id>\\d+)/(?P<action>[^/]+)/$~' => 'regressiontests.templates.views.client_action', '~^/url_tag/client/(?P<client_id>\\d+)/(?P<action>[^/]+)/$~' => 'regressiontests.templates.views.client_action', '~^/url_tag/client/([\\d,]+)/$~' => 'regressiontests.templates.views.client', '~^/url_tag/$~' => 'regressiontests.templates.views.index', '~^/url_tag/named-client/(\\d+)/$~' => 'named.client', '~^/url_tag/Юникод/(\\w+)/$~' => 'метка_оператора', '~^/url_tag/Юникод/(?P<tag>\\S+)/$~' => 'метка_оператора_2')));
// Set test internationalization rules for Dja's generic I18n class.
Dja::setI18n(new DjaI18n(array('de' => 'German', 'ru' => 'Russian'), array('de' => array('Page not found' => 'Seite nicht gefunden', 'Password' => 'Passwort', 'yes,no,maybe' => 'Ja,Nein,Vielleicht'), 'ru' => array('%(counter)s result' => '%(counter)s результат'))));
/*
 * Custom template tag for tests
 */
class EchoNode extends Node
{
    public function __construct($contents)
    {
        $this->contents = $contents;
    }
    public function render($context)
    {
        return join(' ', $this->contents);
    }
}
function do_echo($token)
{
    return new EchoNode(py_slice(explode(' ', $token->contents), 1));
}
$lib = new Library();