Exemplo n.º 1
0
<?php

require_once 'PHPUnit/Framework.php';
if (!defined('GROUPED')) {
    $config = parse_ini_file('../paths.ini', true);
    require $config['libraries']['Opl'] . 'Base.php';
    Opl_Loader::loadPaths($config);
    Opl_Loader::register();
}
class tl implements Opl_Translation_Interface
{
    public function _($group, $id)
    {
    }
    public function assign($group, $id)
    {
    }
}
// end tl;
class expressionTest extends PHPUnit_Framework_TestCase
{
    protected $tpl;
    protected $cpl;
    protected function setUp()
    {
        $tpl = new Opt_Class();
        $tpl->sourceDir = '/';
        $tpl->sourceDir = './templates/';
        $tpl->compileDir = './templates_c/';
        $tpl->escape = false;
        $tpl->register(Opt_Class::PHP_FUNCTION, '_', '_');
Exemplo n.º 2
0
<?php

// OPL Initialization
$config = parse_ini_file('../paths.ini', true);
require $config['libraries']['Opl'] . 'Base.php';
Opl_Loader::loadPaths($config);
Opl_Loader::setCheckFileExists(false);
Opl_Loader::register();
Opl_Registry::setState('opl_debug_console', false);
Opl_Registry::setState('opl_extended_errors', true);
try {
    Opl_Loader::setHandleUnknownLibraries(false);
    $viewSettings = array('sourceDir' => './templates/', 'compileDir' => './templates_c/', 'prologRequired' => true, 'stripWhitespaces' => false, 'gzipCompression' => true, 'contentType' => 0, 'charset' => 'utf-8');
    $tpl = new Opt_Class();
    $tpl->setup($viewSettings);
    $opc = new Opc_Class();
    $viewCacheOptions = array('cacheDir' => './cache/', 'expiryTime' => 120, 'key' => null);
    $viewCache = new Opc_View_Cache($viewCacheOptions);
    $tpl->setCache($viewCache);
    $view = new Opt_View('caching_test_dynamic.tpl');
    $view->pagetitle = 'Caching system test';
    $view->dynamic = 'Dynamic3';
    $out = new Opt_Output_Http();
    $out->setContentType();
    $out->render($view);
} catch (Opc_Exception $exception) {
    $handler = new Opc_ErrorHandler();
    $handler->display($exception);
}
Exemplo n.º 3
0
<?php

/**
 * The bootstrap file for unit tests.
 *
 * @author Tomasz "Zyx" Jędrzejewski
 * @copyright Copyright (c) 2009-2010 Invenzzia Group
 * @license http://www.invenzzia.org/license/new-bsd New BSD License
 */
$config = parse_ini_file(dirname(__FILE__) . '/../paths.ini', true);
require $config['libraries']['Opl'] . 'Opl/Loader.php';
$loader = new Opl_Loader('_');
$loader->addLibrary('Opl', $config['libraries']['Opl']);
$loader->register();
Exemplo n.º 4
0
 /**
  * Creates a new instance of the template compiler. The compiler can
  * be created, using the settings from the main OPT class or another
  * compiler.
  *
  * @param Opt_Class|Opt_Compiler_Class $tpl The initial object.
  */
 public function __construct($tpl)
 {
     if ($tpl instanceof Opt_Class) {
         $this->_tpl = $tpl;
         $this->_namespaces = $tpl->_getList('_namespaces');
         $this->_classes = $tpl->_getList('_classes');
         $this->_functions = $tpl->_getList('_functions');
         $this->_components = $tpl->_getList('_components');
         $this->_blocks = $tpl->_getList('_blocks');
         $this->_phpFunctions = $tpl->_getList('_phpFunctions');
         $this->_formats = $tpl->_getList('_formats');
         $this->_tf = $tpl->_getList('_tf');
         $this->_entities = $tpl->_getList('_entities');
         $this->_exprEngines = $tpl->_getList('_exprEngines');
         $this->_modifiers = $tpl->_getList('_modifiers');
         $this->_charset = strtoupper($tpl->charset);
         // Create the processors and call their configuration method in the constructors.
         $instructions = $tpl->_getList('_instructions');
         foreach ($instructions as $instructionClass) {
             $obj = new $instructionClass($this, $tpl);
             $this->_processors[$obj->getName()] = $obj;
             // Add the tags and attributes registered by this processor.
             foreach ($obj->getInstructions() as $item) {
                 $this->_instructions[$item] = $obj;
             }
             foreach ($obj->getAttributes() as $item) {
                 $this->_attributes[$item] = $obj;
             }
         }
     } elseif ($tpl instanceof Opt_Compiler_Class) {
         // Simply import the data structures from that compiler.
         $this->_tpl = $tpl->_tpl;
         $this->_namespaces = $tpl->_namespaces;
         $this->_classes = $tpl->_classes;
         $this->_functions = $tpl->_functions;
         $this->_components = $tpl->_components;
         $this->_blocks = $tpl->_blocks;
         $this->_inheritance = $tpl->_inheritance;
         $this->_formatInfo = $tpl->_formatInfo;
         $this->_formats = $tpl->_formats;
         $this->_tf = $tpl->_tf;
         $this->_processor = $tpl->_processors;
         $this->_instructions = $tpl->_instructions;
         $this->_attributes = $tpl->_attributes;
         $this->_charset = $tpl->_charset;
         $this->_entities = $tpl->_entities;
         $this->_exprEngines = $tpl->_exprEngines;
         $this->_modifiers = $tpl->_modifiers;
         $tpl = $this->_tpl;
     }
     // We've just thrown the performance away by loading the compiler, so this won't make things worse
     // but the user may be happy :). However, don't show this message, if we are in the performance mode.
     if (!is_writable($tpl->compileDir) && $tpl->_compileMode != Opt_Class::CM_PERFORMANCE) {
         throw new Opt_FilesystemAccess_Exception('compilation', 'writeable');
     }
     // If the debug console is active, preload the XML tree classes.
     // Without it, the debug console would show crazy things about the memory usage.
     if ($this->_tpl->debugConsole && !class_exists('Opt_Xml_Root')) {
         Opl_Loader::load('Opt_Xml_Root');
         Opl_Loader::load('Opt_Xml_Text');
         Opl_Loader::load('Opt_Xml_Cdata');
         Opl_Loader::load('Opt_Xml_Element');
         Opl_Loader::load('Opt_Xml_Attribute');
         Opl_Loader::load('Opt_Xml_Expression');
         Opl_Loader::load('Opt_Xml_Prolog');
         Opl_Loader::load('Opt_Xml_Dtd');
         Opl_Loader::load('Opt_Format_Array');
     }
     $this->_contextStack = new SplStack();
 }
Exemplo n.º 5
0
 /**
  * @cover Opl_Loader::load
  * @cover Opl_Loader::addLibrary
  */
 public function testLoadWholeNameByBasePath()
 {
     Opl_Loader::addLibrary('Bar', array('basePath' => 'vfs://'));
     ob_start();
     Opl_Loader::load('Bar');
     $this->assertEquals(ob_get_clean(), "BAR.PHP\n");
     return true;
 }