1
0
mirror of https://github.com/danbee/neompc synced 2025-03-04 08:39:10 +00:00

Cleaning up.

This commit is contained in:
Dan Barber 2010-01-09 16:54:08 +00:00
parent a46d2942a6
commit 8fecb39273
34 changed files with 3 additions and 1724 deletions

View File

@ -1,64 +0,0 @@
<?php
require('../config/config.inc.php');
require("../templates/${_CONFIG['template']}/config.inc.php");
?>
song_length = {$song_length};
song_position = {$song_position};
song_min = {$initialmin};
song_sec = {$initialsec};
progressbar_width = <?php echo $_CONFIG['progress_bar_width']; ?>;
mpd_state = '{$mpd_state}';
{literal}
update_int = null;
function format_time(number) {
if (number < 10) {
return '0' + number.toString();
}
else {
return number.toString();
}
}
function update_progress() {
//set the interval if it hasn't been set already.
if (update_int == null) {
update_int = setInterval('update_progress()', 1000);
}
if (song_position < song_length) {
song_position = song_position + 1;
song_sec = song_sec + 1;
if (song_sec >= 60) {
song_sec = 0;
song_min = song_min + 1
}
}
progressbar = document.getElementById('progressbar');
new_margin = Math.round(progressbar_width - ((song_position / song_length) * progressbar_width));
new_margin_string = new_margin + 'px';
progressbar.style.marginRight = new_margin_string;
document.getElementById('min').innerHTML = format_time(song_min);
document.getElementById('sec').innerHTML = format_time(song_sec);
//alert(progressbar.style.marginRight + ' - ' + new_margin_string);
}
if (mpd_state == 'play') {
//start off with a shorter interval. this should make the whole thing a little more accurate.
setTimeout('update_progress()', 750);
}
{/literal}

View File

@ -1,35 +0,0 @@
K 25
svn:wc:ra_dav:version-url
V 42
/svn/!svn/ver/2/trunk/lib/smarty/unit_test
END
smarty_unit_test.php
K 25
svn:wc:ra_dav:version-url
V 63
/svn/!svn/ver/2/trunk/lib/smarty/unit_test/smarty_unit_test.php
END
test_cases.php
K 25
svn:wc:ra_dav:version-url
V 57
/svn/!svn/ver/2/trunk/lib/smarty/unit_test/test_cases.php
END
smarty_unit_test_gui.php
K 25
svn:wc:ra_dav:version-url
V 67
/svn/!svn/ver/2/trunk/lib/smarty/unit_test/smarty_unit_test_gui.php
END
config.php
K 25
svn:wc:ra_dav:version-url
V 53
/svn/!svn/ver/2/trunk/lib/smarty/unit_test/config.php
END
README
K 25
svn:wc:ra_dav:version-url
V 49
/svn/!svn/ver/2/trunk/lib/smarty/unit_test/README
END

View File

@ -1,212 +0,0 @@
10
dir
31
https://neompc.googlecode.com/svn/trunk/lib/smarty/unit_test
https://neompc.googlecode.com/svn
delete
2006-08-02T09:03:37.194556Z
2
danbee
3182664f-f819-0410-8fcb-9f4c312bcbac
smarty_unit_test.php
file
delete
2009-07-01T07:30:01.000000Z
2420634cf218db4740ed816ca33654b1
2006-08-02T09:03:37.194556Z
2
danbee
177
test_cases.php
file
delete
2009-07-01T07:30:01.000000Z
d62292f1b1fc7ad607687ba9f4bed56b
2006-08-02T09:03:37.194556Z
2
danbee
16615
smarty_unit_test_gui.php
file
delete
2009-07-01T07:30:01.000000Z
756cf0c254cc69dc65a5adbab01be1c3
2006-08-02T09:03:37.194556Z
2
danbee
175
configs
dir
delete
config.php
file
delete
2009-07-01T07:30:01.000000Z
58112074797eb30123fb5f6e2465d61e
2006-08-02T09:03:37.194556Z
2
danbee
45
README
file
delete
2009-07-01T07:30:01.000000Z
78b0bc06039371e1c8e271430f6cf0f3
2006-08-02T09:03:37.194556Z
2
danbee
693
templates
dir
delete

View File

@ -1,32 +0,0 @@
Smarty Unit Testing
-------------------
Smarty unit tests require the PEAR PHPUnit
package to be installed. See if you have that
installed with the following command:
$> pear list
If you don't see PHPUnit, install with this:
$> pear install PHPUnit
Edit the config.php file,
be sure everything is defined correctly.
Be sure the following directories are present:
templates
configs
templates_c (writable)
cache (writable)
Then run from the command line:
php -q smarty_unit_test.php
Or from the web browser:
http://www.your_domain.com/path/to/smarty_unit_test_gui.php
This will run a unit test for every component
of Smarty and dump the results. All should pass
with flying colors. :)

View File

@ -1,5 +0,0 @@
<?php
define('SMARTY_DIR', '../libs/');
?>

View File

@ -1,10 +0,0 @@
<?php
require_once 'test_cases.php';
require_once 'PHPUnit.php';
$suite = new PHPUnit_TestSuite("SmartyTest");
$result = PHPUnit::run($suite);
echo $result -> toString();
?>

View File

@ -1,10 +0,0 @@
<?php
require_once 'test_cases.php';
require_once 'PHPUnit.php';
$suite = new PHPUnit_TestSuite("SmartyTest");
$result = PHPUnit::run($suite);
echo $result -> toHTML();
?>

View File

@ -1,450 +0,0 @@
<?php
require_once './config.php';
require_once SMARTY_DIR . 'Smarty.class.php';
require_once 'PHPUnit.php';
class Obj {
var $val = 'val';
var $arr = array('one' => 'one', 'two' => 2);
var $ten = 10;
function meth($a="a", $b="b") {
return "$a:$b";
}
function six() {
return 6;
}
}
class SmartyTest extends PHPUnit_TestCase {
// contains the object handle of the string class
var $abc;
// contains the last triggered error's errorlevel
var $errorlevel;
// constructor of the test suite
function SmartyTest($name) {
$this->PHPUnit_TestCase($name);
}
// called before the test functions will be executed
// this function is defined in PHPUnit_TestCase and overwritten
// here
function setUp() {
// create a new instance of String with the
// string 'abc'
$this->smarty = new Smarty;
}
// called after the test functions are executed
// this function is defined in PHPUnit_TestCase and overwritten
// here
function tearDown() {
// delete your instance
unset($this->smarty);
}
// dummy errorhandler for functions that are supposed to call trigger_error()
function error_handler($errorlevel) {
if ($errorlevel) $this->errorlevel = $errorlevel;
}
/* DIRECTORY TESTS */
// test that template_dir exists
function test_template_dir_exists() {
$this->assertTrue(file_exists($this->smarty->template_dir));
}
// test that template_dir is a directory
function test_template_dir_is_dir() {
$this->assertTrue(is_dir($this->smarty->template_dir));
}
// test that template_dir is readable
function test_template_dir_is_readable() {
$this->assertTrue(is_readable($this->smarty->template_dir));
}
// test that config_dir exists
function test_config_dir_exists() {
$this->assertTrue(file_exists($this->smarty->config_dir));
}
// test that config_dir is a directory
function test_config_dir_is_dir() {
$this->assertTrue(is_dir($this->smarty->config_dir));
}
// test that config_dir is readable
function test_config_dir_is_readable() {
$this->assertTrue(is_readable($this->smarty->config_dir));
}
// test that compile_dir exists
function test_compile_dir_exists() {
$this->assertTrue(file_exists($this->smarty->compile_dir));
}
// test that compile_dir is a directory
function test_compile_dir_is_dir() {
$this->assertTrue(is_dir($this->smarty->compile_dir));
}
// test that compile_dir is readable
function test_compile_dir_is_readable() {
$this->assertTrue(is_readable($this->smarty->compile_dir));
}
// test that compile_dir is writable
function test_compile_dir_is_writable() {
$this->assertTrue(is_writable($this->smarty->compile_dir));
}
// test that cache_dir exists
function test_cache_dir_exists() {
$this->assertTrue(file_exists($this->smarty->cache_dir));
}
// test that cache_dir is a directory
function test_cache_dir_is_dir() {
$this->assertTrue(is_dir($this->smarty->cache_dir));
}
// test that cache_dir is readable
function test_cache_dir_is_readable() {
$this->assertTrue(is_readable($this->smarty->cache_dir));
}
// test that cache_dir is writable
function test_cache_dir_is_writable() {
$this->assertTrue(is_writable($this->smarty->cache_dir));
}
/* METHOD EXISTS TESTS */
function test_assign_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'assign'));
}
function test_assign_by_ref_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'assign_by_ref'));
}
function test_append_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'append'));
}
function test_append_by_ref_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'append_by_ref'));
}
function test_clear_assign_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'clear_assign'));
}
function test_register_function_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'register_function'));
}
function test_unregister_function_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'unregister_function'));
}
function test_register_object_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'register_object'));
}
function test_unregister_object_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'unregister_object'));
}
function test_register_block_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'register_block'));
}
function test_unregister_block_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'unregister_block'));
}
function test_register_compiler_function_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'register_compiler_function'));
}
function test_unregister_compiler_function_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'unregister_compiler_function'));
}
function test_register_modifier_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'register_modifier'));
}
function test_unregister_modifier_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'unregister_modifier'));
}
function test_register_resource_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'register_resource'));
}
function test_unregister_resource_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'unregister_resource'));
}
function test_register_prefilter_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'register_prefilter'));
}
function test_unregister_prefilter_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'unregister_prefilter'));
}
function test_register_postfilter_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'register_postfilter'));
}
function test_unregister_postfilter_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'unregister_postfilter'));
}
function test_register_outputfilter_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'register_outputfilter'));
}
function test_unregister_outputfilter_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'unregister_outputfilter'));
}
function test_load_filter_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'load_filter'));
}
function test_clear_cache_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'clear_cache'));
}
function test_clear_all_cache_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'clear_all_cache'));
}
function test_is_cached_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'is_cached'));
}
function test_clear_all_assign_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'clear_all_assign'));
}
function test_clear_compiled_tpl_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'clear_compiled_tpl'));
}
function test_template_exists_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'template_exists'));
}
function test_get_template_vars_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'get_template_vars'));
}
function test_get_config_vars_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'get_config_vars'));
}
function test_trigger_error_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'trigger_error'));
}
function test_display_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'display'));
}
function test_fetch_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'fetch'));
}
function test_config_load_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'config_load'));
}
function test_get_registered_object_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'get_registered_object'));
}
function test_clear_config_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'clear_config'));
}
function test_get_plugin_filepath() {
$this->assertTrue(method_exists($this->smarty, '_get_plugin_filepath'));
}
function test_clear_compiled_tpl() {
$this->assertTrue($this->smarty->clear_compiled_tpl());
}
/* DISPLAY TESTS */
// test that display() executes properly
function test_call_to_display() {
ob_start();
$this->smarty->display('index.tpl');
$output = ob_get_contents();
ob_end_clean();
$this->assertEquals($output, 'TEST STRING');
}
/* FETCH TESTS */
// test that fetch() executes properly
function test_call_to_fetch() {
$this->assertEquals($this->smarty->fetch('index.tpl'), 'TEST STRING');
}
/* ASSIGN TESTS */
// test assigning a simple template variable
function test_assign_var() {
$this->smarty->assign('foo', 'bar');
$this->assertEquals($this->smarty->fetch('assign_var.tpl'), 'bar');
}
/* PARSING TESTS */
// test assigning and calling an object
function test_parse_obj_meth() {
$obj = new Obj();
$this->smarty->assign('obj', $obj);
$this->smarty->assign('foo', 'foo');
$this->assertEquals('foo:2.5
2.5:foo
2.5:b
val:foo
foo:val
foo:foo
one:2
foo:foo:b', $this->smarty->fetch('parse_obj_meth.tpl'));
}
// test assigning and calling an object
function test_parse_math() {
$obj = new Obj();
$this->smarty->assign('obj', $obj);
$this->smarty->assign('flt', 2.5);
$this->smarty->assign('items', array(1, 2));
$this->assertEquals('3
3.5
7
11
4
4.5
8
12
12.5
25
16
20
8.5
7', $this->smarty->fetch('parse_math.tpl'));
}
/* CONFIG FILE TESTS */
// test assigning a double quoted global variable
function test_config_load_globals_double_quotes() {
// load the global var
$this->smarty->config_load('globals_double_quotes.conf');
// test that it is assigned
$this->assertEquals($this->smarty->_config[0]['vars']['foo'], 'bar');
}
// test assigning a single quoted global variable
function test_config_load_globals_single_quotes() {
// load the global var
$this->smarty->config_load('globals_single_quotes.conf');
// test that it is assigned
$this->assertEquals($this->smarty->_config[0]['vars']['foo'], 'bar');
}
// test loading and running modifier.escape.php
function test_escape_modifier_get_plugins_filepath() {
$filepath = $this->smarty->_get_plugin_filepath('modifier', 'escape');
$this->assertTrue($filepath);
}
function test_escape_modifier_include_file() {
$filepath = $this->smarty->_get_plugin_filepath('modifier', 'escape');
$this->assertTrue(include($filepath));
}
function test_escape_modifier_function_exists() {
$this->assertTrue(function_exists('smarty_modifier_escape'));
}
function test_escape_modifier_escape_default() {
$string = smarty_modifier_escape("<html><body></body></html>");
$this->assertEquals('&lt;html&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt;',
$string);
}
function test_escape_modifier_escape_html() {
$string = smarty_modifier_escape("<html><body></body></html>", 'html');
$this->assertEquals('&lt;html&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt;',
$string);
}
function test_escape_modifier_escape_htmlall() {
$string = smarty_modifier_escape("<html><body></body></html>", 'htmlall');
$this->assertEquals('&lt;html&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt;',
$string);
}
function test_escape_modifier_escape_url() {
$string = smarty_modifier_escape("http://test.com?foo=bar", 'url');
$this->assertEquals('http%3A%2F%2Ftest.com%3Ffoo%3Dbar', $string);
}
function test_escape_modifier_escape_quotes() {
$string = smarty_modifier_escape("'\\'\\''", 'quotes');
$this->assertEquals("\\'\\'\\'\\'", $string);
}
function test_escape_modifier_escape_hex() {
$string = smarty_modifier_escape("abcd", 'hex');
$this->assertEquals('%61%62%63%64', $string);
}
function test_escape_modifier_escape_hexentity() {
$string = smarty_modifier_escape("ABCD", 'hexentity');
$this->assertEquals('&#x41;&#x42;&#x43;&#x44;', $string);
}
function test_escape_modifier_escape_javascript() {
$string = smarty_modifier_escape("\r\n\\", 'javascript');
$this->assertEquals('\\r\\n\\\\', $string);
}
function test_core_is_secure_file_exists() {
$file = SMARTY_CORE_DIR . 'core.is_secure.php';
$this->assertTrue(file_exists($file));
}
function test_core_is_secure_file_include() {
$file = SMARTY_CORE_DIR . 'core.is_secure.php';
$this->assertTrue(include($file));
}
function test_core_is_secure_function_exists() {
$this->assertTrue(function_exists('smarty_core_is_secure'));
}
function test_core_is_secure_function_is_secure_true() {
$security = $this->smarty->security;
$this->smarty->security = true;
/* check if index.tpl is secure (should be true) */
$params = array('resource_type' => 'file',
'resource_base_path' => dirname(__FILE__) . '/templates',
'resource_name' => dirname(__FILE__) . '/templates/index.tpl');
$this->assertTrue(smarty_core_is_secure($params, $this->smarty));
$this->smarty->security = $security;
}
function test_core_is_secure_function_is_secure_false() {
$security = $this->smarty->security;
$this->smarty->security = true;
/* check if test_cases.php is secure (should be false) */
$params = array('resource_type' => 'file',
'resource_base_path' => dirname(__FILE__) . '/templates',
'resource_name' => __FILE__);
$this->assertFalse(smarty_core_is_secure($params, $this->smarty));
$this->smarty->security = $security;
}
// test constants and security
function test_core_is_secure_function_smarty_var_const() {
define('TEST_CONSTANT', 'test constant');
$this->assertEquals('test constant', $this->smarty->fetch('constant.tpl',
null, 'var_const'));
}
function test_core_is_secure_function_smarty_var_const_allowed() {
$security = $this->smarty->security;
$security_settings = $this->smarty->security_settings;
$this->smarty->security_settings['ALLOW_CONSTANTS'] = true;
$this->smarty->security = true;
$this->assertEquals('test constant', $this->smarty->fetch('constant.tpl',
null, 'var_const_allowed'));
$this->smarty->security_settings = $security_settings;
$this->smarty->security = $security;
}
function test_core_is_secure_function_smarty_var_const_not_allowed() {
$security = $this->smarty->security;
$this->smarty->security = true;
/* catch errors: */
$this->errorlevel = null;
set_error_handler(array(&$this, 'error_handler'));
$this->smarty->fetch('constant.tpl', null, 'var_const_not_allowed');
restore_error_handler();
$this->assertEquals( $this->errorlevel, E_USER_WARNING);
$this->smarty->security = $security;
}
}
?>

View File

@ -1,32 +0,0 @@
Smarty Unit Testing
-------------------
Smarty unit tests require the PEAR PHPUnit
package to be installed. See if you have that
installed with the following command:
$> pear list
If you don't see PHPUnit, install with this:
$> pear install PHPUnit
Edit the config.php file,
be sure everything is defined correctly.
Be sure the following directories are present:
templates
configs
templates_c (writable)
cache (writable)
Then run from the command line:
php -q smarty_unit_test.php
Or from the web browser:
http://www.your_domain.com/path/to/smarty_unit_test_gui.php
This will run a unit test for every component
of Smarty and dump the results. All should pass
with flying colors. :)

View File

@ -1,5 +0,0 @@
<?php
define('SMARTY_DIR', '../libs/');
?>

View File

@ -1,17 +0,0 @@
K 25
svn:wc:ra_dav:version-url
V 50
/svn/!svn/ver/2/trunk/lib/smarty/unit_test/configs
END
globals_double_quotes.conf
K 25
svn:wc:ra_dav:version-url
V 77
/svn/!svn/ver/2/trunk/lib/smarty/unit_test/configs/globals_double_quotes.conf
END
globals_single_quotes.conf
K 25
svn:wc:ra_dav:version-url
V 77
/svn/!svn/ver/2/trunk/lib/smarty/unit_test/configs/globals_single_quotes.conf
END

View File

@ -1,96 +0,0 @@
10
dir
31
https://neompc.googlecode.com/svn/trunk/lib/smarty/unit_test/configs
https://neompc.googlecode.com/svn
delete
2006-08-02T09:03:37.194556Z
2
danbee
3182664f-f819-0410-8fcb-9f4c312bcbac
globals_double_quotes.conf
file
delete
2009-07-01T07:30:00.000000Z
ed231d0264cb0d3027be1b2305ac7c0d
2006-08-02T09:03:37.194556Z
2
danbee
12
globals_single_quotes.conf
file
delete
2009-07-01T07:30:00.000000Z
246d3bda64a6dbd9eff47c38e39c9ff7
2006-08-02T09:03:37.194556Z
2
danbee
12

View File

@ -1 +0,0 @@
foo = "bar"

View File

@ -1 +0,0 @@
foo = 'bar'

View File

@ -1,10 +0,0 @@
<?php
require_once 'test_cases.php';
require_once 'PHPUnit.php';
$suite = new PHPUnit_TestSuite("SmartyTest");
$result = PHPUnit::run($suite);
echo $result -> toString();
?>

View File

@ -1,10 +0,0 @@
<?php
require_once 'test_cases.php';
require_once 'PHPUnit.php';
$suite = new PHPUnit_TestSuite("SmartyTest");
$result = PHPUnit::run($suite);
echo $result -> toHTML();
?>

View File

@ -1,35 +0,0 @@
K 25
svn:wc:ra_dav:version-url
V 52
/svn/!svn/ver/2/trunk/lib/smarty/unit_test/templates
END
parse_obj_meth.tpl
K 25
svn:wc:ra_dav:version-url
V 71
/svn/!svn/ver/2/trunk/lib/smarty/unit_test/templates/parse_obj_meth.tpl
END
parse_math.tpl
K 25
svn:wc:ra_dav:version-url
V 67
/svn/!svn/ver/2/trunk/lib/smarty/unit_test/templates/parse_math.tpl
END
index.tpl
K 25
svn:wc:ra_dav:version-url
V 62
/svn/!svn/ver/2/trunk/lib/smarty/unit_test/templates/index.tpl
END
constant.tpl
K 25
svn:wc:ra_dav:version-url
V 65
/svn/!svn/ver/2/trunk/lib/smarty/unit_test/templates/constant.tpl
END
assign_var.tpl
K 25
svn:wc:ra_dav:version-url
V 67
/svn/!svn/ver/2/trunk/lib/smarty/unit_test/templates/assign_var.tpl
END

View File

@ -1,198 +0,0 @@
10
dir
31
https://neompc.googlecode.com/svn/trunk/lib/smarty/unit_test/templates
https://neompc.googlecode.com/svn
delete
2006-08-02T09:03:37.194556Z
2
danbee
3182664f-f819-0410-8fcb-9f4c312bcbac
parse_obj_meth.tpl
file
delete
2009-07-01T07:30:00.000000Z
04c262797f9511dc8bf2efbe8b88db46
2006-08-02T09:03:37.194556Z
2
danbee
223
parse_math.tpl
file
delete
2009-07-01T07:30:01.000000Z
7d8f8f21bbbea465912808f2a771b0db
2006-08-02T09:03:37.194556Z
2
danbee
333
index.tpl
file
delete
2009-07-01T07:30:01.000000Z
5f67dddc7f725b471636979a396feea5
2006-08-02T09:03:37.194556Z
2
danbee
12
constant.tpl
file
delete
2009-07-01T07:30:01.000000Z
47bdaabc70bd26c1dc59ee5c5a03ad2f
2006-08-02T09:03:37.194556Z
2
danbee
30
assign_var.tpl
file
delete
2009-07-01T07:30:01.000000Z
379d2efa2bf92a1bc62bfe92646de808
2006-08-02T09:03:37.194556Z
2
danbee
7

View File

@ -1 +0,0 @@
{$smarty.const.TEST_CONSTANT}

View File

@ -1,12 +0,0 @@
{foreach name=loop from=$items item=i}
{$smarty.foreach.loop.iteration+2}
{$smarty.foreach.loop.iteration+$flt}
{$smarty.foreach.loop.iteration+$obj->six()}
{$smarty.foreach.loop.iteration+$obj->ten}
{/foreach}
{$obj->ten+$flt}
{$obj->ten*$flt}
{$obj->six()+$obj->ten}
{$obj->ten+$obj->ten}
{$obj->six()+$flt}
{$obj->six()+$items.0}

View File

@ -1,8 +0,0 @@
{$obj->meth($foo, 2.5)}
{$obj->meth(2.5, $foo)}
{$obj->meth(2.5)}
{$obj->meth($obj->val, "foo")}
{$obj->meth("foo", $obj->val)}
{$obj->meth("foo", $foo)}
{$obj->meth($obj->arr.one, 2)}
{$obj->meth($obj->meth("foo", $foo))}

View File

@ -1 +0,0 @@
{$foo}

View File

@ -1 +0,0 @@
{$smarty.const.TEST_CONSTANT}

View File

@ -1 +0,0 @@
TEST STRING

View File

@ -1,12 +0,0 @@
{foreach name=loop from=$items item=i}
{$smarty.foreach.loop.iteration+2}
{$smarty.foreach.loop.iteration+$flt}
{$smarty.foreach.loop.iteration+$obj->six()}
{$smarty.foreach.loop.iteration+$obj->ten}
{/foreach}
{$obj->ten+$flt}
{$obj->ten*$flt}
{$obj->six()+$obj->ten}
{$obj->ten+$obj->ten}
{$obj->six()+$flt}
{$obj->six()+$items.0}

View File

@ -1,8 +0,0 @@
{$obj->meth($foo, 2.5)}
{$obj->meth(2.5, $foo)}
{$obj->meth(2.5)}
{$obj->meth($obj->val, "foo")}
{$obj->meth("foo", $obj->val)}
{$obj->meth("foo", $foo)}
{$obj->meth($obj->arr.one, 2)}
{$obj->meth($obj->meth("foo", $foo))}

View File

@ -1,450 +0,0 @@
<?php
require_once './config.php';
require_once SMARTY_DIR . 'Smarty.class.php';
require_once 'PHPUnit.php';
class Obj {
var $val = 'val';
var $arr = array('one' => 'one', 'two' => 2);
var $ten = 10;
function meth($a="a", $b="b") {
return "$a:$b";
}
function six() {
return 6;
}
}
class SmartyTest extends PHPUnit_TestCase {
// contains the object handle of the string class
var $abc;
// contains the last triggered error's errorlevel
var $errorlevel;
// constructor of the test suite
function SmartyTest($name) {
$this->PHPUnit_TestCase($name);
}
// called before the test functions will be executed
// this function is defined in PHPUnit_TestCase and overwritten
// here
function setUp() {
// create a new instance of String with the
// string 'abc'
$this->smarty = new Smarty;
}
// called after the test functions are executed
// this function is defined in PHPUnit_TestCase and overwritten
// here
function tearDown() {
// delete your instance
unset($this->smarty);
}
// dummy errorhandler for functions that are supposed to call trigger_error()
function error_handler($errorlevel) {
if ($errorlevel) $this->errorlevel = $errorlevel;
}
/* DIRECTORY TESTS */
// test that template_dir exists
function test_template_dir_exists() {
$this->assertTrue(file_exists($this->smarty->template_dir));
}
// test that template_dir is a directory
function test_template_dir_is_dir() {
$this->assertTrue(is_dir($this->smarty->template_dir));
}
// test that template_dir is readable
function test_template_dir_is_readable() {
$this->assertTrue(is_readable($this->smarty->template_dir));
}
// test that config_dir exists
function test_config_dir_exists() {
$this->assertTrue(file_exists($this->smarty->config_dir));
}
// test that config_dir is a directory
function test_config_dir_is_dir() {
$this->assertTrue(is_dir($this->smarty->config_dir));
}
// test that config_dir is readable
function test_config_dir_is_readable() {
$this->assertTrue(is_readable($this->smarty->config_dir));
}
// test that compile_dir exists
function test_compile_dir_exists() {
$this->assertTrue(file_exists($this->smarty->compile_dir));
}
// test that compile_dir is a directory
function test_compile_dir_is_dir() {
$this->assertTrue(is_dir($this->smarty->compile_dir));
}
// test that compile_dir is readable
function test_compile_dir_is_readable() {
$this->assertTrue(is_readable($this->smarty->compile_dir));
}
// test that compile_dir is writable
function test_compile_dir_is_writable() {
$this->assertTrue(is_writable($this->smarty->compile_dir));
}
// test that cache_dir exists
function test_cache_dir_exists() {
$this->assertTrue(file_exists($this->smarty->cache_dir));
}
// test that cache_dir is a directory
function test_cache_dir_is_dir() {
$this->assertTrue(is_dir($this->smarty->cache_dir));
}
// test that cache_dir is readable
function test_cache_dir_is_readable() {
$this->assertTrue(is_readable($this->smarty->cache_dir));
}
// test that cache_dir is writable
function test_cache_dir_is_writable() {
$this->assertTrue(is_writable($this->smarty->cache_dir));
}
/* METHOD EXISTS TESTS */
function test_assign_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'assign'));
}
function test_assign_by_ref_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'assign_by_ref'));
}
function test_append_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'append'));
}
function test_append_by_ref_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'append_by_ref'));
}
function test_clear_assign_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'clear_assign'));
}
function test_register_function_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'register_function'));
}
function test_unregister_function_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'unregister_function'));
}
function test_register_object_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'register_object'));
}
function test_unregister_object_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'unregister_object'));
}
function test_register_block_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'register_block'));
}
function test_unregister_block_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'unregister_block'));
}
function test_register_compiler_function_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'register_compiler_function'));
}
function test_unregister_compiler_function_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'unregister_compiler_function'));
}
function test_register_modifier_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'register_modifier'));
}
function test_unregister_modifier_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'unregister_modifier'));
}
function test_register_resource_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'register_resource'));
}
function test_unregister_resource_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'unregister_resource'));
}
function test_register_prefilter_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'register_prefilter'));
}
function test_unregister_prefilter_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'unregister_prefilter'));
}
function test_register_postfilter_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'register_postfilter'));
}
function test_unregister_postfilter_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'unregister_postfilter'));
}
function test_register_outputfilter_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'register_outputfilter'));
}
function test_unregister_outputfilter_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'unregister_outputfilter'));
}
function test_load_filter_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'load_filter'));
}
function test_clear_cache_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'clear_cache'));
}
function test_clear_all_cache_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'clear_all_cache'));
}
function test_is_cached_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'is_cached'));
}
function test_clear_all_assign_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'clear_all_assign'));
}
function test_clear_compiled_tpl_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'clear_compiled_tpl'));
}
function test_template_exists_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'template_exists'));
}
function test_get_template_vars_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'get_template_vars'));
}
function test_get_config_vars_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'get_config_vars'));
}
function test_trigger_error_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'trigger_error'));
}
function test_display_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'display'));
}
function test_fetch_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'fetch'));
}
function test_config_load_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'config_load'));
}
function test_get_registered_object_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'get_registered_object'));
}
function test_clear_config_method_exists() {
$this->assertTrue(method_exists($this->smarty, 'clear_config'));
}
function test_get_plugin_filepath() {
$this->assertTrue(method_exists($this->smarty, '_get_plugin_filepath'));
}
function test_clear_compiled_tpl() {
$this->assertTrue($this->smarty->clear_compiled_tpl());
}
/* DISPLAY TESTS */
// test that display() executes properly
function test_call_to_display() {
ob_start();
$this->smarty->display('index.tpl');
$output = ob_get_contents();
ob_end_clean();
$this->assertEquals($output, 'TEST STRING');
}
/* FETCH TESTS */
// test that fetch() executes properly
function test_call_to_fetch() {
$this->assertEquals($this->smarty->fetch('index.tpl'), 'TEST STRING');
}
/* ASSIGN TESTS */
// test assigning a simple template variable
function test_assign_var() {
$this->smarty->assign('foo', 'bar');
$this->assertEquals($this->smarty->fetch('assign_var.tpl'), 'bar');
}
/* PARSING TESTS */
// test assigning and calling an object
function test_parse_obj_meth() {
$obj = new Obj();
$this->smarty->assign('obj', $obj);
$this->smarty->assign('foo', 'foo');
$this->assertEquals('foo:2.5
2.5:foo
2.5:b
val:foo
foo:val
foo:foo
one:2
foo:foo:b', $this->smarty->fetch('parse_obj_meth.tpl'));
}
// test assigning and calling an object
function test_parse_math() {
$obj = new Obj();
$this->smarty->assign('obj', $obj);
$this->smarty->assign('flt', 2.5);
$this->smarty->assign('items', array(1, 2));
$this->assertEquals('3
3.5
7
11
4
4.5
8
12
12.5
25
16
20
8.5
7', $this->smarty->fetch('parse_math.tpl'));
}
/* CONFIG FILE TESTS */
// test assigning a double quoted global variable
function test_config_load_globals_double_quotes() {
// load the global var
$this->smarty->config_load('globals_double_quotes.conf');
// test that it is assigned
$this->assertEquals($this->smarty->_config[0]['vars']['foo'], 'bar');
}
// test assigning a single quoted global variable
function test_config_load_globals_single_quotes() {
// load the global var
$this->smarty->config_load('globals_single_quotes.conf');
// test that it is assigned
$this->assertEquals($this->smarty->_config[0]['vars']['foo'], 'bar');
}
// test loading and running modifier.escape.php
function test_escape_modifier_get_plugins_filepath() {
$filepath = $this->smarty->_get_plugin_filepath('modifier', 'escape');
$this->assertTrue($filepath);
}
function test_escape_modifier_include_file() {
$filepath = $this->smarty->_get_plugin_filepath('modifier', 'escape');
$this->assertTrue(include($filepath));
}
function test_escape_modifier_function_exists() {
$this->assertTrue(function_exists('smarty_modifier_escape'));
}
function test_escape_modifier_escape_default() {
$string = smarty_modifier_escape("<html><body></body></html>");
$this->assertEquals('&lt;html&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt;',
$string);
}
function test_escape_modifier_escape_html() {
$string = smarty_modifier_escape("<html><body></body></html>", 'html');
$this->assertEquals('&lt;html&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt;',
$string);
}
function test_escape_modifier_escape_htmlall() {
$string = smarty_modifier_escape("<html><body></body></html>", 'htmlall');
$this->assertEquals('&lt;html&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt;',
$string);
}
function test_escape_modifier_escape_url() {
$string = smarty_modifier_escape("http://test.com?foo=bar", 'url');
$this->assertEquals('http%3A%2F%2Ftest.com%3Ffoo%3Dbar', $string);
}
function test_escape_modifier_escape_quotes() {
$string = smarty_modifier_escape("'\\'\\''", 'quotes');
$this->assertEquals("\\'\\'\\'\\'", $string);
}
function test_escape_modifier_escape_hex() {
$string = smarty_modifier_escape("abcd", 'hex');
$this->assertEquals('%61%62%63%64', $string);
}
function test_escape_modifier_escape_hexentity() {
$string = smarty_modifier_escape("ABCD", 'hexentity');
$this->assertEquals('&#x41;&#x42;&#x43;&#x44;', $string);
}
function test_escape_modifier_escape_javascript() {
$string = smarty_modifier_escape("\r\n\\", 'javascript');
$this->assertEquals('\\r\\n\\\\', $string);
}
function test_core_is_secure_file_exists() {
$file = SMARTY_CORE_DIR . 'core.is_secure.php';
$this->assertTrue(file_exists($file));
}
function test_core_is_secure_file_include() {
$file = SMARTY_CORE_DIR . 'core.is_secure.php';
$this->assertTrue(include($file));
}
function test_core_is_secure_function_exists() {
$this->assertTrue(function_exists('smarty_core_is_secure'));
}
function test_core_is_secure_function_is_secure_true() {
$security = $this->smarty->security;
$this->smarty->security = true;
/* check if index.tpl is secure (should be true) */
$params = array('resource_type' => 'file',
'resource_base_path' => dirname(__FILE__) . '/templates',
'resource_name' => dirname(__FILE__) . '/templates/index.tpl');
$this->assertTrue(smarty_core_is_secure($params, $this->smarty));
$this->smarty->security = $security;
}
function test_core_is_secure_function_is_secure_false() {
$security = $this->smarty->security;
$this->smarty->security = true;
/* check if test_cases.php is secure (should be false) */
$params = array('resource_type' => 'file',
'resource_base_path' => dirname(__FILE__) . '/templates',
'resource_name' => __FILE__);
$this->assertFalse(smarty_core_is_secure($params, $this->smarty));
$this->smarty->security = $security;
}
// test constants and security
function test_core_is_secure_function_smarty_var_const() {
define('TEST_CONSTANT', 'test constant');
$this->assertEquals('test constant', $this->smarty->fetch('constant.tpl',
null, 'var_const'));
}
function test_core_is_secure_function_smarty_var_const_allowed() {
$security = $this->smarty->security;
$security_settings = $this->smarty->security_settings;
$this->smarty->security_settings['ALLOW_CONSTANTS'] = true;
$this->smarty->security = true;
$this->assertEquals('test constant', $this->smarty->fetch('constant.tpl',
null, 'var_const_allowed'));
$this->smarty->security_settings = $security_settings;
$this->smarty->security = $security;
}
function test_core_is_secure_function_smarty_var_const_not_allowed() {
$security = $this->smarty->security;
$this->smarty->security = true;
/* catch errors: */
$this->errorlevel = null;
set_error_handler(array(&$this, 'error_handler'));
$this->smarty->fetch('constant.tpl', null, 'var_const_not_allowed');
restore_error_handler();
$this->assertEquals( $this->errorlevel, E_USER_WARNING);
$this->smarty->security = $security;
}
}
?>

View File

@ -1,4 +1,4 @@
<?php /* Smarty version 2.6.9, created on 2010-01-09 15:30:55
<?php /* Smarty version 2.6.26, created on 2010-01-09 16:53:35
compiled from default/index.html */ ?>
<!DOCTYPE html>
<html>
@ -23,7 +23,7 @@ unset($_smarty_tpl_vars);
<script type="text/javascript">
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "../lib/javascript.js", 'smarty_include_vars' => array()));
$this->_smarty_include(array('smarty_include_tpl_file' => "../lib/js/javascript.js", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
?>

View File

@ -15,7 +15,7 @@
<body>
<script type="text/javascript">
{include file="../lib/javascript.js"}
{include file="../lib/js/javascript.js"}
</script>
{include file="default/menu.html"}