355c42cb30
Conflicts: include/config.php update.php
224 lines
6.5 KiB
PHP
224 lines
6.5 KiB
PHP
<?php
|
|
/**
|
|
* this file contains tests for the template engine
|
|
*
|
|
* @package test.util
|
|
*/
|
|
|
|
/** required, it is the file under test */
|
|
require_once('include/template_processor.php');
|
|
require_once('include/text.php');
|
|
|
|
class TemplateMockApp {
|
|
public $theme_info=array();
|
|
}
|
|
|
|
if(!function_exists('current_theme')) {
|
|
function current_theme() {
|
|
return 'clean';
|
|
}
|
|
}
|
|
|
|
if(!function_exists('x')) {
|
|
function x($s,$k = NULL) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
if(!function_exists('get_app')) {
|
|
function get_app() {
|
|
return new TemplateMockApp();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* TestCase for the template engine
|
|
*
|
|
* @author Alexander Kampmann
|
|
* @package test.util
|
|
*/
|
|
class TemplateTest extends PHPUnit_Framework_TestCase {
|
|
|
|
public function setUp() {
|
|
global $t;
|
|
$t=new Template;
|
|
}
|
|
|
|
public function testListToShort() {
|
|
@list($first, $second)=array('first');
|
|
|
|
$this->assertTrue(is_null($second));
|
|
}
|
|
|
|
public function testSimpleVariableString() {
|
|
$tpl='Hello $name!';
|
|
|
|
$text=replace_macros($tpl, array('$name'=>'Anna'));
|
|
|
|
$this->assertEquals('Hello Anna!', $text);
|
|
}
|
|
|
|
public function testSimpleVariableInt() {
|
|
$tpl='There are $num new messages!';
|
|