<?xml version="1.0" encoding="UTF-8"?>
-<package packagerversion="1.4.9" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
-http://pear.php.net/dtd/tasks-1.0.xsd
-http://pear.php.net/dtd/package-2.0
-http://pear.php.net/dtd/package-2.0.xsd">
+<package packagerversion="1.9.1" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
<name>Template</name>
<channel>pear.horde.org</channel>
<summary>Horde Template System</summary>
- <description>Horde Template system. Adapted from bTemplate, by Brian Lozier <brian@massassi.net>.
- </description>
+ <description>Horde Template system. Adapted from bTemplate, by Brian Lozier <brian@massassi.net>.</description>
<lead>
<name>Chuck Hagenbuch</name>
<user>chuck</user>
<email>slusarz@horde.org</email>
<active>yes</active>
</lead>
- <date>2009-06-10</date>
+ <date>2011-01-24</date>
+ <time>17:28:58</time>
<version>
<release>0.1.0</release>
<api>0.1.0</api>
<api>beta</api>
</stability>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Remove dependency on Horde_Core.
+ <notes>
+* Remove dependency on Horde_Core.
* Initial Horde 4 package.
</notes>
<contents>
- <dir name="/">
+ <dir baseinstalldir="/" name="/">
<dir name="lib">
<dir name="Horde">
<file name="Template.php" role="php" />
<dir name="test">
<dir name="Horde">
<dir name="Template">
- <file name="array_assoc.html" role="test" />
- <file name="array_assoc.phpt" role="test" />
- <file name="array_if.html" role="test" />
- <file name="array_if.phpt" role="test" />
- <file name="array_nested.html" role="test" />
- <file name="array_nested.phpt" role="test" />
- <file name="array_simple.html" role="test" />
- <file name="array_simple.phpt" role="test" />
- <file name="divider.phpt" role="test" />
- <file name="if.html" role="test" />
- <file name="if.phpt" role="test" />
- <file name="iterator.phpt" role="test" />
- <file name="scalar.html" role="test" />
- <file name="scalar.phpt" role="test" />
+ <file name="AllTests.php" role="test" />
+ <file name="Autoload.php" role="test" />
+ <file name="TemplateTest.php" role="test" />
</dir> <!-- /test/Horde/Template -->
</dir> <!-- /test/Horde -->
</dir> <!-- /test -->
</dependencies>
<phprelease>
<filelist>
- <install name="lib/Horde/Template.php" as="Horde/Template.php" />
+ <install as="Horde/Template.php" name="lib/Horde/Template.php" />
+ <install as="Horde/Template/AllTests.php" name="test/Horde/Template/AllTests.php" />
+ <install as="Horde/Template/Autoload.php" name="test/Horde/Template/Autoload.php" />
+ <install as="Horde/Template/TemplateTest.php" name="test/Horde/Template/TemplateTest.php" />
</filelist>
</phprelease>
<changelog>
<release>
+ <version>
+ <release>0.0.1</release>
+ <api>0.0.1</api>
+ </version>
+ <stability>
+ <release>alpha</release>
+ <api>alpha</api>
+ </stability>
+ <date>2003-07-05</date>
+ <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
+ <notes>
+Initial release as a PEAR package
+ </notes>
+ </release>
+ <release>
<date>2006-05-08</date>
<time>23:32:28</time>
<version>
</stability>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
<notes>
- - Converted to package.xml 2.0 for pear.horde.org
- - Remove numeric array key constraint (Request #4413).
+- Converted to package.xml 2.0 for pear.horde.org
+- Remove numeric array key constraint (Request #4413).
</notes>
</release>
<release>
<version>
- <release>0.0.1</release>
- <api>0.0.1</api>
+ <release>0.1.0</release>
+ <api>0.1.0</api>
</version>
<stability>
- <release>alpha</release>
- <api>alpha</api>
+ <release>beta</release>
+ <api>beta</api>
</stability>
- <date>2003-07-05</date>
+ <date>2011-01-24</date>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>Initial release as a PEAR package
+ <notes>
+* Remove dependency on Horde_Core.
+ * Initial Horde 4 package.
</notes>
</release>
</changelog>
--- /dev/null
+<?php
+/**
+ * Tests for the horde/Template package.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Template
+ * @package Template
+ * @subpackage UnitTests
+ */
+
+/**
+ * Define the main method
+ */
+if (!defined('PHPUnit_MAIN_METHOD')) {
+ define('PHPUnit_MAIN_METHOD', 'Horde_Template_AllTests::main');
+}
+
+/**
+ * Prepare the test setup.
+ */
+require_once 'Horde/Test/AllTests.php';
+
+/**
+ * @category Horde
+ * @package Template
+ * @subpackage UnitTests
+ */
+class Horde_Template_AllTests extends Horde_Test_AllTests
+{
+}
+
+Horde_Template_AllTests::init('Horde_Template', __FILE__);
+
+if (PHPUnit_MAIN_METHOD == 'Horde_Template_AllTests::main') {
+ Horde_Template_AllTests::main();
+}
--- /dev/null
+<?php
+/**
+ * Setup autoloading for the tests.
+ *
+ * PHP version 5
+ *
+ * @category Horde
+ * @package Template
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Template
+ */
+
+if (!spl_autoload_functions()) {
+ spl_autoload_register(
+ create_function(
+ '$class',
+ '$filename = str_replace(array(\'::\', \'_\'), \'/\', $class);'
+ . '$err_mask = E_ALL ^ E_WARNING;'
+ . '$oldErrorReporting = error_reporting($err_mask);'
+ . 'include "$filename.php";'
+ . 'error_reporting($oldErrorReporting);'
+ )
+ );
+}
+
+/** Catch strict standards */
+error_reporting(E_ALL | E_STRICT);
--- /dev/null
+<?php
+/**
+ * Json serialization tests.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Template
+ * @subpackage UnitTests
+ */
+
+class Horde_Template_TemplateTest extends PHPUnit_Framework_TestCase
+{
+ // Associative Array Test
+ public function testAssociativeArray()
+ {
+ $template = new Horde_Template();
+
+ $template->set('foo', array('one' => 'one', 'two' => 2));
+
+ $this->assertEquals(
+ 'one 2 ',
+ $template->parse('<tag:foo.one /> <tag:foo.two /> <tag:foo />')
+ );
+ }
+
+ // If Array Test
+ public function testIfArray()
+ {
+ $template = new Horde_Template();
+
+ $template->set('foo', array('one', 'two', 'three'), true);
+ $template->set('bar', array(), true);
+
+ $this->assertEquals(
+ "one two three \nelse",
+ $template->parse("<if:foo><loop:foo><tag:foo /> </loop:foo></if:foo>\n<if:bar><loop:bar><tag:bar /></loop:bar><else:bar>else</else:bar></if:bar>")
+ );
+ }
+
+ // Simple Array Test
+ public function testSimpleArray()
+ {
+ $template = new Horde_Template();
+
+ $template->set('string', array('one', 'two', 'three'));
+ $template->set('int', array(1, 2, 3));
+
+ $this->assertEquals(
+ "one two three \n1 2 3 ",
+ $template->parse("<loop:string><tag:string /> </loop:string>\n<loop:int><tag:int /> </loop:int>")
+ );
+ }
+
+ // Divider Test
+ public function testDivider()
+ {
+ $template = new Horde_Template();
+
+ $template->set('a', array('a', 'b', 'c', 'd'));
+
+ $this->assertEquals(
+ 'a,b,c,d',
+ $template->parse("<loop:a><divider:a>,</divider:a><tag:a /></loop:a>")
+ );
+ }
+
+ // If/Else Test
+ public function testIfElse()
+ {
+ $template = new Horde_Template();
+
+ $template->set('foo', true, true);
+ $template->set('bar', false, true);
+ $template->set('baz', 'baz', true);
+
+ $this->assertEquals(
+ "foo\n\nfalse\nbaz",
+ $template->parse("<if:foo>foo</if:foo>\n<if:bar>bar</if:bar>\n<if:bar>true<else:bar>false</else:bar></if:bar>\n<if:baz><tag:baz /></if:baz>")
+ );
+ }
+
+ // Iterator Test
+ public function testIterator()
+ {
+ $template = new Horde_Template();
+
+ $s = array('one', 'two', 'three');
+ $i = array(1, 2, 3);
+ $a = array('one' => 'one', 'two' => 2);
+
+ $template->set('s', $s);
+ $template->set('i', $i);
+ $template->set('a', $a);
+
+ $this->assertEquals(
+ "one,two,three,\n1,2,3,\none,2,",
+ $template->parse("<loop:s><tag:s />,</loop:s>\n<loop:i><tag:i />,</loop:i>\n<tag:a.one />,<tag:a.two />,<tag:a />")
+ );
+ }
+
+ // Scalar Test
+ public function testScalar()
+ {
+ $template = new Horde_Template();
+
+ $template->set('one', 'one');
+ $template->set('two', 2);
+
+ $this->assertEquals(
+ "one\n2",
+ $template->parse("<tag:one />\n<tag:two />")
+ );
+ }
+
+}
+++ /dev/null
-<tag:foo.one /> <tag:foo.two /> <tag:foo />
\ No newline at end of file
+++ /dev/null
---TEST--
-Associative Array Test
---FILE--
-<?php
-
-if (defined('E_DEPRECATED')) {
- error_reporting(error_reporting() & ~E_DEPRECATED);
-}
-
-require dirname(__FILE__) . '/../../../lib/Horde/Template.php';
-$template = new Horde_Template(array('basepath' => dirname(__FILE__)));
-$template->set('foo', array('one' => 'one', 'two' => 2));
-echo $template->fetch('/array_assoc.html');
-
-?>
---EXPECT--
-one 2 <tag:foo />
+++ /dev/null
-<if:foo><loop:foo>
-<tag:foo />
-</loop:foo></if:foo>
-<if:bar><loop:bar>
-<tag:bar />
-</loop:bar><else:bar>
-else
-</else:bar></if:bar>
+++ /dev/null
---TEST--
-If Array Test
---FILE--
-<?php
-
-if (defined('E_DEPRECATED')) {
- error_reporting(error_reporting() & ~E_DEPRECATED);
-}
-
-require dirname(__FILE__) . '/../../../lib/Horde/Template.php';
-$template = new Horde_Template(array('basepath' => dirname(__FILE__)));
-$template->set('foo', array('one', 'two', 'three'), true);
-$template->set('bar', array(), true);
-echo $template->fetch('/array_if.html');
-
-?>
---EXPECT--
-one
-two
-three
-
-else
+++ /dev/null
-<loop:categories>
-<tag:categories /><loop:subcat_<tag:categories />>
- <tag:subcat_<tag:categories /> />
-</loop:subcat_<tag:categories />>
-</loop:categories>
-<loop:keyed><tag:keyed />
- <tag:keyed.key1 />
- <tag:keyed.key2 />
- <tag:keyed.key3 />
-</loop:keyed>
+++ /dev/null
---TEST--
-Nested Array Test
---FILE--
-<?php
-
-if (defined('E_DEPRECATED')) {
- error_reporting(error_reporting() & ~E_DEPRECATED);
-}
-
-require dirname(__FILE__) . '/../../../lib/Horde/Template.php';
-$template = new Horde_Template(array('basepath' => dirname(__FILE__)));
-$categories = array('fruit', 'veggie', 'thing');
-$subcats = array('fruit' => array('apple', 'pear'),
- 'veggie' => array('tomato', 'potato', 'carrot', 'onion'),
- 'thing' => array('spoon', 'paperbag', 'tool'));
-$template->set('categories', $categories);
-foreach ($categories as $c) {
- $template->set('subcat_' . $c, $subcats[$c]);
-}
-$template->set('keyed', array('widgets' => array(
- 'key1' => 'zipit',
- 'key2' => 'twisty',
- 'key3' => 'doowhopper'
-)));
-echo $template->fetch('/array_nested.html');
-
-?>
---EXPECT--
-fruit
- apple
- pear
-veggie
- tomato
- potato
- carrot
- onion
-thing
- spoon
- paperbag
- tool
-widgets
- zipit
- twisty
- doowhopper
+++ /dev/null
-<loop:string>
-<tag:string />
-</loop:string>
-<loop:int>
-<tag:int />
-</loop:int>
+++ /dev/null
---TEST--
-Simple Array Test
---FILE--
-<?php
-
-if (defined('E_DEPRECATED')) {
- error_reporting(error_reporting() & ~E_DEPRECATED);
-}
-
-require dirname(__FILE__) . '/../../../lib/Horde/Template.php';
-$template = new Horde_Template(array('basepath' => dirname(__FILE__)));
-$template->set('string', array('one', 'two', 'three'));
-$template->set('int', array(1, 2, 3));
-echo $template->fetch('/array_simple.html');
-
-?>
---EXPECT--
-one
-two
-three
-
-1
-2
-3
+++ /dev/null
---TEST--
-Divider Test
---FILE--
-<?php
-
-require dirname(__FILE__) . '/../../../lib/Horde/Template.php';
-$template = new Horde_Template();
-$template->set('a', array('a', 'b', 'c', 'd'));
-echo $template->parse("<loop:a><divider:a>,</divider:a><tag:a /></loop:a>");
-
-?>
---EXPECT--
-a,b,c,d
+++ /dev/null
-<if:foo>foo</if:foo>
-<if:bar>bar</if:bar>
-<if:bar>true<else:bar>false</else:bar>void</if:bar>
-<if:baz><tag:baz /></if:baz>
+++ /dev/null
---TEST--
-If/Else Test
---FILE--
-<?php
-
-if (defined('E_DEPRECATED')) {
- error_reporting(error_reporting() & ~E_DEPRECATED);
-}
-
-require dirname(__FILE__) . '/../../../lib/Horde/Template.php';
-$template = new Horde_Template(array('basepath' => dirname(__FILE__)));
-$template->set('foo', true, true);
-$template->set('bar', false, true);
-$template->set('baz', 'baz', true);
-echo $template->fetch('/if.html');
-
-?>
---EXPECT--
-foo
-
-false
-baz
+++ /dev/null
---TEST--
-Iterator Test
---FILE--
-<?php
-
-$s = new ArrayObject(array('one', 'two', 'three'));
-$i = new ArrayObject(array(1, 2, 3));
-$a = new ArrayObject(array('one' => 'one', 'two' => 2));
-
-require dirname(__FILE__) . '/../../../lib/Horde/Template.php';
-$template = new Horde_Template(array('basepath' => dirname(__FILE__)));
-$template->set('s', $s);
-$template->set('i', $i);
-$template->set('a', $a);
-echo $template->parse("<loop:s><tag:s />,</loop:s>\n<loop:i><tag:i />,</loop:i>\n<tag:a.one />,<tag:a.two />,<tag:a />");
-
-?>
---EXPECT--
-one,two,three,
-1,2,3,
-one,2,<tag:a />
+++ /dev/null
-<tag:one />
-<tag:two />
+++ /dev/null
---TEST--
-Scalar Test
---FILE--
-<?php
-
-if (defined('E_DEPRECATED')) {
- error_reporting(error_reporting() & ~E_DEPRECATED);
-}
-
-require dirname(__FILE__) . '/../../../lib/Horde/Template.php';
-$template = new Horde_Template(array('basepath' => dirname(__FILE__)));
-$template->set('one', 'one');
-$template->set('two', 2);
-echo $template->fetch('/scalar.html');
-
-?>
---EXPECT--
-one
-2