3 require_once('_HelpersUnitTester.php');
4 require_once(AK_LIB_DIR
.DS
.'AkActionView'.DS
.'helpers'.DS
.'javascript_helper.php');
7 class JavaScriptHelperTests
extends HelpersUnitTester
9 function test_for_JavascriptHelper()
11 require_once(AK_LIB_DIR
.DS
.'AkActionView'.DS
.'helpers'.DS
.'javascript_helper.php');
13 $javascript = new JavaScriptHelper();
15 $this->assertEqual($javascript->link_to_function('Greeting', "alert('Hello world!')"),'<a href="#" onclick="alert(\'Hello world!\'); return false;">Greeting</a>');
16 $this->assertEqual($javascript->link_to_function('my link', "if confirm('Really?'){ do_delete(); }",array('href'=>'http://www.akelos.com')),'<a href="http://www.akelos.com" onclick="if confirm(\'Really?\'){ do_delete(); }; return false;">my link</a>');
19 $this->assertEqual($javascript->button_to_function("Greeting", "alert('Hello world!')"),'<input onclick="alert(\'Hello world!\');" type="button" value="Greeting" />');
20 $this->assertEqual($javascript->button_to_function("Delete", "if confirm('Really?'){ do_delete(); }",array('id'=>'confirm')),'<input id="confirm" onclick="if confirm(\'Really?\'){ do_delete(); };" type="button" value="Delete" />');
23 $this->assertEqual($javascript->javascript_tag("alert('All is good')"), "<script type=\"text/javascript\">\n//<![CDATA[\nalert('All is good')\n//]]>\n</script>");
28 class=\"hisghtlight\" />
30 $expected = "\\n <div id=\'meesage\'\\n \\n class=\\\"hisghtlight\\\" />\\n ";
31 $this->assertEqual($javascript->escape_javascript($input), $expected);
34 function test_javascript_tag()
36 $javascript = new JavaScriptHelper();
40 JavascriptHelper
::javascript_tag("alert('test akelos');"),
41 "<script type=\"text/javascript\">\n//<![CDATA[\nalert('test akelos');\n//]]>\n</script>"
46 $javascript->javascript_tag("alert('test akelos');"),
47 "<script type=\"text/javascript\">\n//<![CDATA[\nalert('test akelos');\n//]]>\n</script>"
55 ak_test('JavaScriptHelperTests');