From: Gunnar Wrobel Date: Tue, 11 Jan 2011 04:45:35 +0000 (+0100) Subject: Start the templates helper. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=b05da2739f6f0db559f84a4d02a57deebef0a1f0;p=horde.git Start the templates helper. --- diff --git a/components/lib/Components/Helper/Templates.php b/components/lib/Components/Helper/Templates.php new file mode 100644 index 000000000..d7d598e65 --- /dev/null +++ b/components/lib/Components/Helper/Templates.php @@ -0,0 +1,59 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Components + */ + +/** + * Components_Helper_Templates:: converts templates into target files. + * + * Copyright 2011 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Horde + * @package Components + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Components + */ +class Components_Helper_Templates +{ + /** + * The target location. + * + * @var string + */ + private $_target; + + /** + * Constructor. + * + * @param string $source The template(s) source path. + * @param string $target The template(s) target path. + */ + public function __construct($source, $target) + { + $this->_target = $target; + } + + /** + * Rewrite the template(s) from the source(s) to the target location(s). + * + * @param array $parameters The template(s) parameters. + * + * @return NULL + */ + public function write(array $parameters = array()) + { + file_put_contents($this->_target, ''); + } +} \ No newline at end of file diff --git a/components/package.xml b/components/package.xml index 74c829028..a936a2c5b 100644 --- a/components/package.xml +++ b/components/package.xml @@ -24,8 +24,8 @@ jan@horde.org yes - 2010-12-10 - + 2011-01-11 + 0.0.1 0.0.1 @@ -67,6 +67,7 @@ + @@ -75,6 +76,7 @@ + @@ -207,6 +209,7 @@ + @@ -215,6 +218,9 @@ + + + @@ -228,6 +234,7 @@ + @@ -300,12 +307,14 @@ + + @@ -332,6 +341,7 @@ + @@ -363,8 +373,10 @@ + + @@ -380,7 +392,7 @@ alpha alpha - 2010-12-10 + 2011-01-11 LGPL * Initial release diff --git a/components/test/Components/Autoload.php b/components/test/Components/Autoload.php index 10cdc35a9..ee991d9dd 100644 --- a/components/test/Components/Autoload.php +++ b/components/test/Components/Autoload.php @@ -27,4 +27,5 @@ if (!class_exists('Components')) { error_reporting(E_ALL | E_STRICT); /** Load the basic test definition */ -require_once dirname(__FILE__) . '/StoryTestCase.php'; \ No newline at end of file +require_once dirname(__FILE__) . '/StoryTestCase.php'; +require_once dirname(__FILE__) . '/TestCase.php'; \ No newline at end of file diff --git a/components/test/Components/TestCase.php b/components/test/Components/TestCase.php new file mode 100644 index 000000000..058683221 --- /dev/null +++ b/components/test/Components/TestCase.php @@ -0,0 +1,37 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Components + */ + +/** + * Test base. + * + * Copyright 2011 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Horde + * @package Components + * @subpackage UnitTests + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Components + */ +class Components_TestCase +extends PHPUnit_Framework_TestCase +{ + protected function getTemporaryDirectory() + { + return Horde_Util::createTempDir(); + } +} \ No newline at end of file diff --git a/components/test/Components/Unit/Components/Helper/TemplatesTest.php b/components/test/Components/Unit/Components/Helper/TemplatesTest.php new file mode 100644 index 000000000..eeb180548 --- /dev/null +++ b/components/test/Components/Unit/Components/Helper/TemplatesTest.php @@ -0,0 +1,45 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Components + */ + +/** + * Prepare the test setup. + */ +require_once dirname(__FILE__) . '/../../../Autoload.php'; + +/** + * Test the template machinery. + * + * Copyright 2011 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Horde + * @package Components + * @subpackage UnitTests + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Components + */ +class Components_Unit_Components_Helper_TemplatesTest +extends Components_TestCase +{ + public function testWrite() + { + $target = $this->getTemporaryDirectory() . '/target'; + $templates = new Components_Helper_Templates('', $target, array()); + $templates->write(); + $this->assertTrue(file_exists($target)); + } +} \ No newline at end of file