Beispiel #1
0
 /**
  * Prepare a new Opt_Class object for tests.
  */
 protected function setUp()
 {
     // @codeCoverageIgnoreStart
     $this->_tpl = new Opt_Class();
     $this->_tpl->sourceDir = './templates/';
     $this->_tpl->compileDir = './templates_c/';
     $this->_tpl->setup();
     // @codeCoverageIgnoreStop
 }
 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, '_', '_');
     $tpl->register(Opt_Class::PHP_FUNCTION, 'foo', 'foo');
     $tpl->register(Opt_Class::PHP_FUNCTION, 'bar', 'bar');
     $tpl->register(Opt_Class::PHP_FUNCTION, 'joe', 'joe');
     $tpl->register(Opt_Class::PHP_FUNCTION, 'lol', 'lol');
     $tpl->register(Opt_Class::PHP_FUNCTION, 'funct', 'funct');
     $tpl->register(Opt_Class::PHP_FUNCTION, 'rotfl', 'rotfl');
     $tpl->register(Opt_Class::PHP_FUNCTION, 'lmao1', '#1#lmao');
     $tpl->register(Opt_Class::PHP_FUNCTION, 'lmao2', '#2,1#lmao');
     $tpl->register(Opt_Class::PHP_FUNCTION, 'lmao3', '#3,1,2:null#lmao');
     $tpl->register(Opt_Class::PHP_CLASS, 'class', '_class');
     $tpl->register(Opt_Class::PHP_CLASS, 'e', 'e');
     $tpl->register(Opt_Class::PHP_CLASS, 'u', 'u');
     $tpl->register(Opt_Class::PHP_CLASS, 'a', 'a');
     Opl_Registry::register('opl_translate', new tl());
     $tpl->setup();
     $this->tpl = $tpl;
     $this->cpl = new Opt_Compiler_Class($tpl);
 }
 /**
  * Configures the test case.
  */
 public function setUp()
 {
     $tpl = new Opt_Class();
     $tpl->sourceDir = '/';
     $tpl->sourceDir = 'php://memory';
     $tpl->compileDir = dirname(__FILE__) . '/../../Cache/';
     $tpl->escape = false;
     $tpl->allowArrays = true;
     $tpl->allowObjects = true;
     $tpl->allowObjectCreation = true;
     $tpl->register(Opt_Class::PHP_FUNCTION, '_', '_');
     $tpl->register(Opt_Class::PHP_FUNCTION, 'foo', 'foo');
     $tpl->register(Opt_Class::PHP_FUNCTION, 'bar', 'bar');
     $tpl->register(Opt_Class::PHP_FUNCTION, 'joe', 'joe');
     $tpl->register(Opt_Class::PHP_FUNCTION, 'lol', 'lol');
     $tpl->register(Opt_Class::PHP_FUNCTION, 'funct', 'funct');
     $tpl->register(Opt_Class::PHP_FUNCTION, 'rotfl', 'rotfl');
     $tpl->register(Opt_Class::PHP_FUNCTION, 'lmao1', '#1#lmao');
     $tpl->register(Opt_Class::PHP_FUNCTION, 'lmao2', '#2,1#lmao');
     $tpl->register(Opt_Class::PHP_FUNCTION, 'lmao3', '#3,1,2:null#lmao');
     $tpl->register(Opt_Class::PHP_CLASS, 'class', '_class');
     $tpl->register(Opt_Class::PHP_CLASS, 'e', 'e');
     $tpl->register(Opt_Class::PHP_CLASS, 'u', 'u');
     $tpl->register(Opt_Class::PHP_CLASS, 'a', 'a');
     Opl_Registry::register('opl_translate', $this->getMock('Opl_Translation_Interface'));
     $tpl->setup();
     $this->tpl = $tpl;
     $this->cpl = new Opt_Compiler_Class($tpl);
 }
Beispiel #4
0
function getCompilerEnvironment()
{
    $tpl = new Opt_Class();
    $tpl->sourceDir = './templates/';
    $tpl->compileDir = './templates_c/';
    $tpl->setup();
    $tpl->compiler = new Opt_Compiler_Class($tpl);
    return $tpl;
}
Beispiel #5
0
 public function init()
 {
     $tpl = new Opt_Class();
     $tpl->sourceDir = 'test://templates/';
     $tpl->compileDir = CPL_DIR;
     $tpl->compileMode = Opt_Class::CM_REBUILD;
     $tpl->stripWhitespaces = false;
     $tpl->prologRequired = true;
     $tpl->setup();
     $this->tpl = $tpl;
 }
 /**
  * Does the engine add the slashes to the paths?
  */
 public function testSlashing()
 {
     $foo = new Opt_Class();
     $foo->sourceDir = './templates';
     $foo->compileDir = './templates_c';
     $foo->setup();
     if ($foo->sourceDir['file'] != './templates/' || $foo->compileDir != './templates_c/') {
         $this->fail('No ending slash in the paths. SourceDir: ' . $foo->sourceDir . '; CompileDir: ' . $foo->compileDir);
     }
     unset($foo);
 }
Beispiel #7
0
 protected function setUp()
 {
     $tpl = new Opt_Class();
     $tpl->sourceDir = 'test://templates/';
     $tpl->compileDir = CPL_DIR;
     $tpl->compileMode = Opt_Class::CM_REBUILD;
     $tpl->stripWhitespaces = false;
     $tpl->prologRequired = true;
     $tpl->register(Opt_Class::OPT_FORMAT, 'Test');
     $tpl->setup();
     $this->tpl = $tpl;
 }
Beispiel #8
0
 /**
  * @covers Opt_Class::register
  */
 public function testRegisterIsLockedAfterInit()
 {
     try {
         $this->_tpl->sourceDir = 'php://memory';
         $this->_tpl->compileDir = 'php://memory';
         $this->_tpl->setup();
         $this->_tpl->register(Opt_Class::PHP_CLASS, 'foo', 'bar');
     } catch (Opt_Initialization_Exception $exception) {
         return true;
     }
     $this->fail('Exception Opt_Initialization_Exception not returned');
 }
 protected function setUp()
 {
     $tpl = new Opt_Class();
     $tpl->sourceDir = 'test://templates/';
     $tpl->compileDir = CPL_DIR;
     $tpl->compileMode = Opt_Class::CM_REBUILD;
     $tpl->stripWhitespaces = false;
     $tpl->prologRequired = true;
     $tpl->register(Opt_Class::OPT_COMPONENT, 'opt:myComponent', 'myComponent');
     $tpl->register(Opt_Class::OPT_BLOCK, 'opt:myBlock', 'myBlock');
     $tpl->setup();
     $this->tpl = $tpl;
     Opt_View::clear();
 }
<?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);
}
Beispiel #11
0
            $results[] = array('name' => $name, 'value' => $value);
        }
        $view->results = $results;
    }
}
// end GeneralForm;
try {
    $tpl = new Opt_Class();
    $opf = new Opf_Class($tpl);
    $tpl->sourceDir = './templates/';
    $tpl->compileDir = './templates_c/';
    $tpl->compileMode = Opt_Class::CM_REBUILD;
    $tpl->stripWhitespaces = false;
    $tpl->gzipCompression = false;
    $tpl->register(Opt_Class::PHP_FUNCTION, 'dump', 'var_dump');
    $tpl->setup();
    $translate = new Opc_Translate(new Opc_Translate_Adapter_Ini(array('directory' => './lang/')));
    $translate->setLanguage('en');
    $opf->setTranslationInterface($translate);
    $view = new Opt_View('situation_5.tpl');
    $view->devFile = 'situation_5.php';
    $form = new GeneralForm('form5');
    $form->setView($view);
    $form->execute();
    $output = new Opt_Output_Http();
    $output->render($view);
} catch (Exception $e) {
    var_dump($e);
} catch (Opl_Exception $exception) {
    $handler = new Opl_ErrorHandler();
    $handler->display($exception);