update version numbers, add initial unit test directory

This commit is contained in:
mohrt
2004-01-16 22:12:08 +00:00
parent 5383e42a1d
commit 51e1064d69
10 changed files with 239 additions and 4 deletions

3
NEWS
View File

@@ -1,3 +1,6 @@
Version 2.6.1 (Jan 16, 2004)
----------------------------
- rename $smarty->tpl_error_reporting to $smarty->error_reporting
(messju)
- fix interpretation of $smarty->security in {html_image} (messju)

View File

@@ -24,7 +24,7 @@
* http://smarty.php.net/
*
* @link http://smarty.php.net/
* @version 2.6.1
* @version 2.6.2-dev
* @copyright Copyright: 2001-2003 ispi of Lincoln, Inc.
* @author Andrei Zmievski <andrei@php.net>
* @access public

View File

@@ -40,7 +40,7 @@
* @author Monte Ohrt <monte@ispi.net>
* @author Andrei Zmievski <andrei@php.net>
* @package Smarty
* @version 2.6.1
* @version 2.6.2-dev
*/
/* $Id$ */
@@ -480,7 +480,7 @@ class Smarty
*
* @var string
*/
var $_version = '2.6.1';
var $_version = '2.6.2-dev';
/**
* current template inclusion depth

View File

@@ -34,7 +34,7 @@
* @link http://smarty.php.net/
* @author Monte Ohrt <monte@ispi.net>
* @author Andrei Zmievski <andrei@php.net>
* @version 2.6.1
* @version 2.6.2-dev
* @copyright 2001-2003 ispi of Lincoln, Inc.
* @package Smarty
*/

32
unit_test/README Normal file
View File

@@ -0,0 +1,32 @@
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. :)

5
unit_test/config.php Normal file
View File

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

View File

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

View File

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

87
unit_test/test_case.php Normal file
View File

@@ -0,0 +1,87 @@
<?php
require_once './config.php';
require_once SMARTY_DIR . 'Smarty.class.php';
require_once 'PHPUnit.php';
class SmartyTest extends PHPUnit_TestCase {
// contains the object handle of the string class
var $abc;
// 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);
}
// 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));
}
}
?>

88
unit_test/test_cases.php Normal file
View File

@@ -0,0 +1,88 @@
<?php
define('SMARTY_DIR', '../libs/');
require_once SMARTY_DIR . 'Smarty.class.php';
require_once 'PHPUnit.php';
class SmartyTest extends PHPUnit_TestCase {
// contains the object handle of the string class
var $abc;
// 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);
}
// 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));
}
}
?>