diff options
Diffstat (limited to 'vendor/flexi/test/lib')
| -rw-r--r-- | vendor/flexi/test/lib/helper/js_helper_test.php | 93 | ||||
| -rw-r--r-- | vendor/flexi/test/lib/helper/prototype_helper_test.php | 180 | ||||
| -rw-r--r-- | vendor/flexi/test/lib/helper/scriptaculous_helper_test.php | 67 | ||||
| -rw-r--r-- | vendor/flexi/test/lib/helper/tag_helper_test.php | 65 | ||||
| -rw-r--r-- | vendor/flexi/test/lib/helper/text_helper_test.php | 80 | ||||
| -rw-r--r-- | vendor/flexi/test/lib/js_template_test.php | 56 | ||||
| -rw-r--r-- | vendor/flexi/test/lib/php_template_test.php | 182 | ||||
| -rw-r--r-- | vendor/flexi/test/lib/template_factory_test.php | 117 | ||||
| -rw-r--r-- | vendor/flexi/test/lib/template_test.php | 215 |
9 files changed, 0 insertions, 1055 deletions
diff --git a/vendor/flexi/test/lib/helper/js_helper_test.php b/vendor/flexi/test/lib/helper/js_helper_test.php deleted file mode 100644 index f7c36ff..0000000 --- a/vendor/flexi/test/lib/helper/js_helper_test.php +++ /dev/null @@ -1,93 +0,0 @@ -<?php - -# Copyright (c) 2008 - Marcus Lunzenauer <mlunzena@uos.de> -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -require_once dirname(__FILE__) . '/../../flexi_tests.php'; -Flexi_Tests::setup(); -require_once dirname(__FILE__) . '/../../../lib/helper/js_helper.php'; - -/** - * Testcase for JsHelper. - * - * @package flexi - * @subpackage test - * - * @author mlunzena - * @copyright (c) Authors - * @version $Id: js_helper_test.php 4194 2006-10-24 14:52:31Z mlunzena $ - */ - -class JsHelperTestCase extends UnitTestCase { - - function setUp() { - } - - function tearDown() { - } - - - function test_link_to_function() { - $foo = JsHelper::link_to_function('Greeting', "alert('Hello world!')", - array('title' => 'hello')); - $exp = '<a title="hello" href="#" onclick="alert(\'Hello world!\'); '. - 'return false;">Greeting</a>'; - $this->assertEqual($exp, $foo); - } - - function test_button_to_function() { - $foo = JsHelper::button_to_function("Greeting", "alert('Hello world!')"); - $exp = '<input type="button" value="Greeting" '. - 'onclick="alert(\'Hello world!\');" />'; - $this->assertEqual($exp, $foo); - - $foo = JsHelper::button_to_function("Greeting", "alert('Hello world!')", - array('onclick' => 'alert(\'One\')')); - $exp = '<input onclick="alert(\'One\'); alert(\'Hello world!\');" '. - 'type="button" value="Greeting" />'; - $this->assertEqual($exp, $foo); - } - - function test_escape_javascript() { - $strings = array( - "\r" => '\n', - "\n" => '\n', - '\\' => '\\\\', - '</' => '<\\/', - '"' => '\\"', - "'" => "\\'" - ); - foreach ($strings as $string => $expect) { - $this->assertEqual(JsHelper::escape_javascript($string), $expect); - } - } - - function test_javascript_tag() { - $foo = JsHelper::javascript_tag("alert('All is good')"); - $exp = <<<EXPECTED -<script type="text/javascript"> -//<![CDATA[ -alert('All is good') -//]]> -</script> -EXPECTED; - $this->assertEqual($exp, $foo); - } -} diff --git a/vendor/flexi/test/lib/helper/prototype_helper_test.php b/vendor/flexi/test/lib/helper/prototype_helper_test.php deleted file mode 100644 index 3307f6a..0000000 --- a/vendor/flexi/test/lib/helper/prototype_helper_test.php +++ /dev/null @@ -1,180 +0,0 @@ -<?php - -# Copyright (c) 2008 - Marcus Lunzenauer <mlunzena@uos.de> -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -require_once dirname(__FILE__) . '/../../flexi_tests.php'; -Flexi_Tests::setup(); -require_once dirname(__FILE__) . '/../../../lib/helper/prototype_helper.php'; - -/** - * Testcase for JsHelper. - * - * @package flexi - * @subpackage test - * - * @author mlunzena - * @copyright (c) Authors - * @version $Id: prototype_helper_test.php 4194 2006-10-24 14:52:31Z mlunzena $ - */ - -class PrototypeHelperTestCase extends UnitTestCase { - - function setUp() { - } - - function tearDown() { - } - - function test_link_to_remote() { - - $foo = PrototypeHelper::link_to_remote('Delete this post', - array('update' => 'posts', - 'url' => 'http://destroy?id=1')); - $exp = '<a href="#" onclick="new Ajax.Updater(\'posts\', \'http://destroy?id=1\', {asynchronous:true, evalScripts:false}); return false;">Delete this post</a>'; - $this->assertEqual($exp, $foo); - - - $foo = PrototypeHelper::link_to_remote('Delete this post', - array('update' => array('success' => 'posts', - 'failure' => 'error'), - 'url' => 'http://destroy?id=1')); - $exp = '<a href="#" onclick="new Ajax.Updater({success:\'posts\',failure:\'error\'}, \'http://destroy?id=1\', {asynchronous:true, evalScripts:false}); return false;">Delete this post</a>'; - $this->assertEqual($exp, $foo); - - - $foo = PrototypeHelper::link_to_remote('Delete this post', - array('url' => 'http://destroy?id=1', - 404 => "alert('Not found...?')", - 'failure' => "alert('HTTPError!')")); - $exp = '<a href="#" onclick="new Ajax.Request(\'http://destroy?id=1\', {asynchronous:true, evalScripts:false, on404:function(request, json){alert(\'Not found...?\')}, onFailure:function(request, json){alert(\'HTTPError!\')}}); return false;">Delete this post</a>'; - $this->assertEqual($exp, $foo); - } - - function test_periodically_call_remote() { - $foo = PrototypeHelper::periodically_call_remote( - array('url' => 'http://clock', - 'frequency' => 2, - 'update' => 'clock')); - $exp = <<<EXPECTED -<script type="text/javascript"> -//<![CDATA[ -new PeriodicalExecuter(function() {new Ajax.Updater('clock', 'http://clock', {asynchronous:true, evalScripts:false})}, 2) -//]]> -</script> -EXPECTED; - $this->assertEqual($exp, $foo); - } - - function test_form_remote_tag() { - - $foo = PrototypeHelper::form_remote_tag(array( - 'url' => 'http://tag_add', - 'update' => 'question_tags', - 'loading' => "Element.show('indicator'); tag.value = '';", - 'complete' => "Element.hide('indicator');")); - $exp = <<<EXPECTED -<form onsubmit="new Ajax.Updater('question_tags', 'http://tag_add', {asynchronous:true, evalScripts:false, onComplete:function(request, json){Element.hide('indicator');}, onLoading:function(request, json){Element.show('indicator'); tag.value = '';}, parameters:Form.serialize(this)}); return false;" action="http://tag_add" method="post"> -EXPECTED; - $this->assertEqual($exp, $foo); - } - - function test_submit_to_remote() { - $foo = PrototypeHelper::submit_to_remote('name', 'value', - array( - 'url' => 'http://tag_add', - 'update' => 'question_tags', - 'loading' => "Element.show('indicator'); tag.value = '';", - 'complete' => "Element.hide('indicator');")); - $exp = <<<EXPECTED -<input type="button" onclick="new Ajax.Updater('question_tags', 'http://tag_add', {asynchronous:true, evalScripts:false, onComplete:function(request, json){Element.hide('indicator');}, onLoading:function(request, json){Element.show('indicator'); tag.value = '';}, parameters:Form.serialize(this.form)}); return false;" name="name" value="value" /> -EXPECTED; - $this->assertEqual($exp, $foo); - } - - function test_update_element_function() { - $foo = PrototypeHelper::update_element_function('element_id', - array('position' => 'bottom', 'content' => "<p>New product!</p>")); - $exp = "new Insertion.Bottom('element_id','<p>New product!<\/p>');\n"; - $this->assertEqual($exp, $foo); - } - - function test_evaluate_remote_response() { - $foo = PrototypeHelper::evaluate_remote_response(); - $exp = 'eval(request.responseText)'; - $this->assertEqual($exp, $foo); - } - - function test_remote_function() { - $foo = PrototypeHelper::remote_function(array('update' => 'options', - 'url' => 'http://update')); - $exp = <<<EXPECTED -new Ajax.Updater('options', 'http://update', {asynchronous:true, evalScripts:false}) -EXPECTED; - $this->assertEqual($exp, $foo); - } - - function test_observe_field() { - $foo = PrototypeHelper::observe_field('element_id', - array('url' => 'http://update', - 'frequency' => 0, - 'update' => 'update_id')); - $exp = <<<EXPECTED -<script type="text/javascript"> -//<![CDATA[ -new Form.Element.EventObserver("element_id", 0, function(element, value) {new Ajax.Updater('update_id', 'http://update', {asynchronous:true, evalScripts:false, parameters:value})}); -//]]> -</script> -EXPECTED; - $this->assertEqual($exp, $foo); - } - - function test_observe_form() { - $foo = PrototypeHelper::observe_form('form_id', - array('url' => 'http://update', - 'frequency' => 0, - 'update' => 'update_id')); - $exp = <<<EXPECTED -<script type="text/javascript"> -//<![CDATA[ -new Form.EventObserver("form_id", 0, function(element, value) {new Ajax.Updater('update_id', 'http://update', {asynchronous:true, evalScripts:false, parameters:value})}); -//]]> -</script> -EXPECTED; - $this->assertEqual($exp, $foo); - } - - function test_jsgen() { - $page = new Flexi_JavascriptGenerator(); - $page->insert_html('bottom', 'list', '<li>Last item</li>'); - $page->replace_html('person-45', 'Deleted.'); - $page->replace('person-45', 'Deleted.'); - $page->remove('id-1', 'id-2', 'id-3'); - $page->show('id-1', 'id-2', 'id-3'); - $page->hide('id-1', 'id-2', 'id-3'); - $page->toggle('id-1', 'id-2', 'id-3'); - $page->alert('Some "Message"!\/'); - $page->redirect_to('http://www.google.com'); - $page->delay('alert("Hallo Welt")', 23); - $page->visual_effect('highlight', 'id-42'); - # TODO (mlunzena) no asserts - # var_dump($page->to_s()); - } -} diff --git a/vendor/flexi/test/lib/helper/scriptaculous_helper_test.php b/vendor/flexi/test/lib/helper/scriptaculous_helper_test.php deleted file mode 100644 index 30531f9..0000000 --- a/vendor/flexi/test/lib/helper/scriptaculous_helper_test.php +++ /dev/null @@ -1,67 +0,0 @@ -<?php - -# Copyright (c) 2008 - Marcus Lunzenauer <mlunzena@uos.de> -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -require_once dirname(__FILE__) . '/../../flexi_tests.php'; -Flexi_Tests::setup(); -require_once dirname(__FILE__) . '/../../../lib/helper/scriptaculous_helper.php'; - -/** - * Testcase for ScriptaculousHelper. - * - * @package flexi - * @subpackage test - * - * @author mlunzena - * @copyright (c) Authors - * @version $Id$ - */ - -class ScriptaculousHelperTestCase extends UnitTestCase { - - function setUp() { - } - - function tearDown() { - } - - function test_visual_effect() { - $result = ScriptaculousHelper::visual_effect('toggle_blind', 'id'); - $expected = 'new Effect.toggle(\'id\', \'blind\', {})'; - $this->assertEqual($result, $expected); - } - - function test_sortable_element() { - $result = ScriptaculousHelper::sortable_element('list', array( - 'url' => '/', - 'containment' => array('left', 'right'), - 'only' => 'middle', - )); - $expected = <<<SCRIPT -<script type="text/javascript"> -//<![CDATA[ -Sortable.create('list', {containment:['left','right'], onUpdate:function(){new Ajax.Request('/', {asynchronous:true, evalScripts:false, parameters:Sortable.serialize('list')})}, only:'middle'}) -//]]> -</script> -SCRIPT; - $this->assertEqual($result, $expected); - } -} diff --git a/vendor/flexi/test/lib/helper/tag_helper_test.php b/vendor/flexi/test/lib/helper/tag_helper_test.php deleted file mode 100644 index bd872f7..0000000 --- a/vendor/flexi/test/lib/helper/tag_helper_test.php +++ /dev/null @@ -1,65 +0,0 @@ -<?php - -# Copyright (c) 2008 - Marcus Lunzenauer <mlunzena@uos.de> -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -require_once dirname(__FILE__) . '/../../flexi_tests.php'; -Flexi_Tests::setup(); -require_once dirname(__FILE__) . '/../../../lib/helper/tag_helper.php'; - -/** - * Testcase for TagHelper. - * - * @package flexi - * @subpackage test - * - * @author mlunzena - * @copyright (c) Authors - * @version $Id: tag_helper_test.php 4194 2006-10-24 14:52:31Z mlunzena $ - */ - -class TagHelperTestCase extends UnitTestCase { - - function setUp() { - } - - function tearDown() { - } - - function test_tag() { - $foo = TagHelper::tag('img', array('src' => 'test.gif')); - $this->assertEqual('<img src="test.gif" />', $foo); - } - - function test_content_tag() { - $foo = TagHelper::content_tag('a', '#', array('href' => '#')); - $this->assertEqual('<a href="#">#</a>', $foo); - } - - function test_cdata_section() { - $foo = TagHelper::cdata_section('foo'); - $this->assertEqual('<![CDATA[foo]]>', $foo); - } - - function test_string_to_array() { - $array = TagHelper::string_to_array('id="anId" class=\'aClass\''); - $this->assertEqual(array('id' => 'anId', 'class' => 'aClass'), $array); - } -} diff --git a/vendor/flexi/test/lib/helper/text_helper_test.php b/vendor/flexi/test/lib/helper/text_helper_test.php deleted file mode 100644 index 1ac7834..0000000 --- a/vendor/flexi/test/lib/helper/text_helper_test.php +++ /dev/null @@ -1,80 +0,0 @@ -<?php - -# Copyright (c) 2008 - Marcus Lunzenauer <mlunzena@uos.de> -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -require_once dirname(__FILE__) . '/../../flexi_tests.php'; -Flexi_Tests::setup(); -require_once dirname(__FILE__) . '/../../../lib/helper/text_helper.php'; - -/** - * Testcase for TextHelper. - * - * @package flexi - * @subpackage test - * - * @author mlunzena - * @copyright (c) Authors - * @version $Id$ - */ - -class TextHelperTestCase extends UnitTestCase { - - function setUp() { - } - - function tearDown() { - TextHelper::reset_cycle(); - } - - function test_camelize() { - $foo = TextHelper::camelize('foo_bar_baz/FOO is great'); - $this->assertEqual('FooBarBazFOOIsGreat', $foo); - } - - function test_simple_cycle() { - $this->assertEqual('odd', TextHelper::cycle('odd', 'even')); - $this->assertEqual('even', TextHelper::cycle('odd', 'even')); - $this->assertEqual('odd', TextHelper::cycle('odd', 'even')); - $this->assertEqual('even', TextHelper::cycle('odd', 'even')); - } - - function test_reset_cycle() { - $this->assertEqual('odd', TextHelper::cycle('odd', 'even')); - $this->assertEqual('even', TextHelper::cycle('odd', 'even')); - $this->assertEqual('odd', TextHelper::cycle('odd', 'even')); - TextHelper::reset_cycle(); - $this->assertEqual('odd', TextHelper::cycle('odd', 'even')); - } - - function test_double_cycle_should_reset_each_time() { - $this->assertEqual('odd', TextHelper::cycle('odd', 'even')); - $this->assertEqual('red', TextHelper::cycle('red', 'black')); - $this->assertEqual('odd', TextHelper::cycle('odd', 'even')); - $this->assertEqual('red', TextHelper::cycle('red', 'black')); - } - - function test_named_cycles() { - $this->assertEqual('odd', TextHelper::cycle(array('odd', 'even', 'name' => '1st'))); - $this->assertEqual('red', TextHelper::cycle('red', 'black')); - $this->assertEqual('even', TextHelper::cycle(array('odd', 'even', 'name' => '1st'))); - $this->assertEqual('black', TextHelper::cycle('red', 'black')); - } -} diff --git a/vendor/flexi/test/lib/js_template_test.php b/vendor/flexi/test/lib/js_template_test.php deleted file mode 100644 index 77f577b..0000000 --- a/vendor/flexi/test/lib/js_template_test.php +++ /dev/null @@ -1,56 +0,0 @@ -<?php - -# Copyright (c) 2008 - Marcus Lunzenauer <mlunzena@uos.de> -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -require_once dirname(__FILE__) . '/../flexi_tests.php'; -Flexi_Tests::setup(); - -class JsTemplateTestCase extends UnitTestCase { - - var $factory; - - function setUp() { - $this->setUpFS(); - $this->factory = new Flexi_TemplateFactory('var://templates/'); - } - - function tearDown() { - unset($this->factory); - - stream_wrapper_unregister("var"); - } - - function setUpFS() { - ArrayFileStream::set_filesystem(array( - 'templates' => array( - 'foo.pjs' => '', - 'layout.pjs' => '' - ))); - stream_wrapper_register("var", "ArrayFileStream") or die("Failed to register protocol"); - } - - - function test_something() { - $template = $this->factory->open('foo'); - $template->render(array('whom' => 'world'), 'layout'); - } -} - diff --git a/vendor/flexi/test/lib/php_template_test.php b/vendor/flexi/test/lib/php_template_test.php deleted file mode 100644 index 1c6d85c..0000000 --- a/vendor/flexi/test/lib/php_template_test.php +++ /dev/null @@ -1,182 +0,0 @@ -<?php - -# Copyright (c) 2008 - Marcus Lunzenauer <mlunzena@uos.de> -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -require_once dirname(__FILE__) . '/../flexi_tests.php'; -Flexi_Tests::setup(); - -class PhpTemplateTestCase extends UnitTestCase { - - var $factory; - - - function setUp() { - $this->setUpFS(); - $this->factory = new Flexi_TemplateFactory('var://templates/'); - } - - - function tearDown() { - unset($this->factory); - - stream_wrapper_unregister("var"); - } - - function setUpFS() { - ArrayFileStream::set_filesystem(array( - 'templates' => array( - - 'foo_using_partial.php' => - 'Hello, <?= $this->render_partial("foos_partial") ?>!', - - 'foos_partial.php' => - '<h1><?= $whom ?> at <?= $when ?></h1>', - - 'foo_with_partial_collection.php' => - '[<?= $this->render_partial_collection("item", $items, "spacer") ?>]', - - 'item.php' => - '"<?= $item ?>"', - - 'spacer.php' => - ', ', - - 'attributes.php' => - '<? foreach (get_defined_vars() as $name => $value) : ?>' . - '<?= $name ?><?= $value ?>'. - '<? endforeach ?>', - - 'foo.php' => - 'Hello, <?= $whom ?>!', - - 'layout.php' => - '[<?= $content_for_layout ?>]', - ))); - stream_wrapper_register("var", "ArrayFileStream") or die("Failed to register protocol"); - } - - function test_render_partial() { - $template = $this->factory->open('foo_using_partial'); - $template->set_attribute('whom', 'bar'); - $output = $template->render(array('when' => 'now')); - $spec = "Hello, <h1>bar at now</h1>!"; - $this->assertEqual($output, $spec); - } - - - function test_render_partial_collection() { - $template = $this->factory->open('foo_with_partial_collection'); - $result = $template->render_partial_collection('item', - range(1, 3), - 'spacer'); - $this->assertEqual('"1", "2", "3"', $result); - } - - - function test_should_override_attributes_with_those_passed_to_render() { - - $template = $this->factory->open('attributes'); - $template->set_attribute('foo', 'baz'); - - $template->render(array('foo' => 'bar')); - - $bar = $template->get_attribute('foo'); - $this->assertEqual($bar, 'bar'); - - $out = $template->render(); - - $bar = $template->get_attribute('foo'); - $this->assertEqual($bar, 'bar'); - } - - function test_render_without_layout() { - $foo = $this->factory->open('foo'); - $foo->set_attribute('whom', 'bar'); - $out = $foo->render(); - $this->assertEqual('Hello, bar!', $out); - } - - function test_render_with_layout() { - $foo = $this->factory->open('foo'); - $foo->set_attribute('whom', 'bar'); - $foo->set_layout('layout'); - $out = $foo->render(); - $this->assertEqual('[Hello, bar!]', $out); - } - - function test_render_with_layout_inline() { - $out = $this->factory->render('foo', array('whom' => 'bar'), 'layout'); - $this->assertEqual('[Hello, bar!]', $out); - } - - function test_render_with_missing_layout() { - $foo = $this->factory->open('foo'); - $this->expectException("Flexi_TemplateNotFoundException"); - $foo->set_layout('nosuchlayout'); - } - - function test_render_with_attributes() { - $foo = $this->factory->open('foo'); - $foo->set_attribute('whom', 'bar'); - $foo->set_layout('layout'); - $foo_out = $foo->render(); - - $bar = $this->factory->open('foo'); - $bar_out = $bar->render(array('whom' => 'bar'), 'layout'); - - $this->assertEqual($foo_out, $bar_out); - } -} - - -class PhpTemplatePartialBugTestCase extends UnitTestCase { - function setUp() { - $this->setUpFS(); - $this->factory = new Flexi_TemplateFactory('var://templates/'); - } - - function tearDown() { - unset($this->factory); - - stream_wrapper_unregister("var"); - } - - function setUpFS() { - ArrayFileStream::set_filesystem(array( - 'templates' => array( - 'layout.php' => - '<? $do_not_echo_this = $this->render_partial_collection("partial", range(1, 5));'. - 'echo $content_for_layout;', - 'partial.php' => - 'partial', - 'template.php' => - 'template', - ))); - stream_wrapper_register("var", "ArrayFileStream") or die("Failed to register protocol"); - } - - function test_partial_bug() { - $template = $this->factory->open('template'); - $template->set_layout('layout'); - $result = $template->render(); - $this->assertEqual($result, "template"); - } -} diff --git a/vendor/flexi/test/lib/template_factory_test.php b/vendor/flexi/test/lib/template_factory_test.php deleted file mode 100644 index c2166da..0000000 --- a/vendor/flexi/test/lib/template_factory_test.php +++ /dev/null @@ -1,117 +0,0 @@ -<?php - -# Copyright (c) 2008 - Marcus Lunzenauer <mlunzena@uos.de> -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -require_once dirname(__FILE__) . '/../flexi_tests.php'; -Flexi_Tests::setup(); - -/** - * Testcase for TemplateFactory.php. - * - * @package flexi - * @subpackage test - * - * @author mlunzena - * @copyright (c) Authors - * @version $Id: template_test.php 4194 2006-10-24 14:52:31Z mlunzena $ - */ - -class TemplateFactoryTestCase extends UnitTestCase { - - var $factory; - - function setUp() { - $this->setUpFS(); - $this->factory = new Flexi_TemplateFactory('var://templates'); - } - - function tearDown() { - unset($this->factory); - stream_wrapper_unregister("var"); - } - - function setUpFS() { - ArrayFileStream::set_filesystem(array( - 'templates' => array( - 'foo.php' => 'some content', - 'baz.unknown' => 'some content', - 'multiplebasenames' => array( - 'foo.txt' => 'there is no matching template class', - 'foo.php' => 'some content', - 'bar.txt' => 'there is no matching template class' - ) - ) - )); - stream_wrapper_register("var", "ArrayFileStream") - or die("Failed to register protocol"); - } - - function test_should_create_factory() { - $factory = new Flexi_TemplateFactory('.'); - $this->assertNotNull($factory); - } - - function test_should_create_factory_using_path() { - $path = 'var://'; - $factory = new Flexi_TemplateFactory($path); - $this->assertNotNull($factory); - } - - function test_should_open_template_using_relative_path() { - $foo = $this->factory->open('foo'); - $this->assertNotNull($foo); - } - - function test_should_open_template_using_absolute_path() { - $foo = $this->factory->open('var://templates/foo'); - $this->assertNotNull($foo); - } - - function test_should_throw_an_exception_opening_a_missing_template_without_file_extension() { - $this->expectException('Flexi_TemplateNotFoundException'); - $bar = $this->factory->open('bar'); - } - - function test_should_throw_an_exception_opening_a_missing_template_with_file_extension() { - $this->expectException('Flexi_TemplateNotFoundException'); - $bar = $this->factory->open('bar.php'); - } - - function test_should_open_template_using_extension() { - $foo = $this->factory->open('foo.php'); - $this->assertIsA($foo, 'Flexi_PhpTemplate'); - } - - function test_should_throw_an_exception_when_opening_a_template_with_unknown_extension() { - $this->expectException('Flexi_TemplateNotFoundException'); - $baz = $this->factory->open('baz'); - } - - function test_should_throw_an_exception_opening_a_template_in_a_non_existing_directory() { - $this->expectException('Flexi_TemplateNotFoundException'); - $this->factory->open('doesnotexist/foo'); - } - - function test_should_search_for_a_supported_template() { - $template = $this->factory->open('multiplebasenames/foo'); - $this->assertIsA($template, 'Flexi_PhpTemplate'); - } -} diff --git a/vendor/flexi/test/lib/template_test.php b/vendor/flexi/test/lib/template_test.php deleted file mode 100644 index e0f2e0b..0000000 --- a/vendor/flexi/test/lib/template_test.php +++ /dev/null @@ -1,215 +0,0 @@ -<?php - -# Copyright (c) 2008 - Marcus Lunzenauer <mlunzena@uos.de> -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -require_once dirname(__FILE__) . '/../flexi_tests.php'; -Flexi_Tests::setup(); - -Mock::generate('Flexi_TemplateFactory'); -Mock::generatePartial('Flexi_Template', 'MockTemplate', array('_render')); - -class AnEmptyTemplate extends UnitTestCase { - - - var $factory; - - - function setUp() { - $this->factory = new MockFlexi_TemplateFactory(TEST_DIR . '/templates/template_tests'); - $template = new MockTemplate(); - $template->__construct('foo', $this->factory); - $this->factory->setReturnValue('open', $template); - } - - - function tearDown() { - unset($this->factory); - } - - - function test_should_have_no_attributes() { - $template = $this->factory->open(''); - $this->assertEqual(0, sizeof($template->get_attributes())); - } - - - function test_should_not_be_empty_after_setting_an_attribute() { - $template = $this->factory->open(''); - $template->set_attribute('foo', 'bar'); - $this->assertNotEqual(0, sizeof($template->get_attributes())); - } - - - function test_should_be_empty_after_clear() { - - $template = $this->factory->open('foo'); - - $this->assertEqual(0, sizeof($template->get_attributes())); - - $template->clear_attributes(); - $this->assertEqual(0, sizeof($template->get_attributes())); - } -} - - -class ATemplate extends UnitTestCase { - - - var $factory; - - - function setUp() { - $this->factory = new MockFlexi_TemplateFactory(TEST_DIR . '/templates/template_tests'); - $template = new MockTemplate(); - $template->__construct('foo', $this->factory); - $this->factory->setReturnValue('open', $template); - } - - - function tearDown() { - unset($this->factory); - } - - - function test_should_return_an_previously_set_attribute() { - $template = $this->factory->open('foo'); - $template->set_attribute('whom', 'bar'); - $this->assertEqual('bar', $template->get_attribute('whom')); - } - - - function test_should_return_previously_set_attributes() { - - $template = $this->factory->open('foo'); - $template->set_attributes(array('whom' => 'bar', 'foo' => 'baz')); - - $attributes = $template->get_attributes(); - $this->assertIsA($attributes, 'array'); - $this->assertEqual(2, sizeof($attributes)); - $this->assertEqual('bar', $attributes['whom']); - $this->assertEqual('baz', $attributes['foo']); - } - - - function test_should_merge_attributes_with_set_attributes() { - - $template = $this->factory->open('foo'); - $template->set_attributes(array('a' => 1, 'b' => 2)); - - $this->assertEqual(2, sizeof($template->get_attributes())); - $this->assertEqual(1, $template->get_attribute('a')); - $this->assertEqual(2, $template->get_attribute('b')); - - $template->set_attributes(array('b' => 8, 'c' => 9)); - - $this->assertEqual(3, sizeof($template->get_attributes())); - $this->assertEqual(1, $template->get_attribute('a')); - $this->assertEqual(8, $template->get_attribute('b')); - $this->assertEqual(9, $template->get_attribute('c')); - } - - - function test_should_be_empty_after_clear() { - - $template = $this->factory->open('foo'); - - $template->set_attributes(array('a' => 1, 'b' => 2)); - $this->assertNotEqual(0, sizeof($template->get_attributes())); - - $template->clear_attributes(); - $this->assertEqual(0, sizeof($template->get_attributes())); - } -} - - - -class MagicMethodsTemplate extends UnitTestCase { - - - var $factory; - - - function setUp() { - $this->factory = new MockFlexi_TemplateFactory(TEST_DIR . '/templates/template_tests'); - $this->template = new MockTemplate(); - $this->template->__construct('foo', $this->factory); - } - - - function tearDown() { - unset($this->factory); - unset($this->template); - } - - - function test_should_set_an_attribute_using_the_magic_methods() { - $this->template->foo = 'bar'; - $this->assertEqual('bar', $this->template->get_attribute('foo')); - } - - - function test_should_not_set_a_protected_member_field_as_an_attribute() { - $this->template->_layout = 'bar'; - $this->assertNull($this->template->get_attribute('_layout')); - $this->assertEqual('bar', $this->template->_layout); - } - - function test_should_overwrite_an_attribute() { - $this->template->set_attribute('foo', 'bar'); - $this->template->foo = 'baz'; - $this->assertEqual('baz', $this->template->get_attribute('foo')); - } - - function test_should_return_an_existing_attribute_using_the_magic_methods() { - $this->template->set_attribute('foo', 'bar'); - $this->assertEqual('bar', $this->template->foo); - } - - - function test_should_return_null_for_a_non_existing_attribute_using_the_magic_methods() { - $this->assertNull($this->template->foo); - } - - - function test_should_unset_an_attribute_using_the_magic_methods() { - $this->template->foo = 'bar'; - unset($this->template->foo); - $this->assertNull($this->template->foo); - } - - - function test_should_return_null_on_unsetting_a_non_attribute() { - unset($this->template->foo); - $this->assertNull($this->template->foo); - } - - - function test_should_return_true_on_isset_for_an_attribute() { - $this->template->foo = 'bar'; - $this->assertTrue(isset($this->template->foo)); - } - - - function test_should_return_false_on_isset_for_a_non_existing_attribute() { - $this->assertFalse(isset($this->template->foo)); - } -} - |
