FOSSology  4.7.1
Open Source License Compliance by Open Source Software
test_common_active.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2011 Hewlett-Packard Development Company, L.P.
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
13 require_once(dirname(__FILE__) .'/../common-active.php');
14 
18 class test_common_active extends \PHPUnit\Framework\TestCase
19 {
23  protected function setUp() : void
24  {
25  }
26 
31  {
33  $html_result = ActiveHTTPscript("test");
34  $script_header = "<script language='javascript'>\n<!--\n";
35  $script_foot = "\n// -->\n</script>\n";
36  $html_expect = "var test=null;\n";
37  /* Check for browser support. */
38  $html_expect .= "function test_Get(Url)\n";
39  $html_expect .= "{\n";
40  $html_expect .= "if (window.XMLHttpRequest)\n";
41  $html_expect .= " {\n";
42  $html_expect .= " test=new XMLHttpRequest();\n";
43  $html_expect .= " }\n";
44  /* Check for IE5 and IE6 */
45  $html_expect .= "else if (window.ActiveXObject)\n";
46  $html_expect .= " {\n";
47  $html_expect .= " test=new ActiveXObject('Microsoft.XMLHTTP');\n";
48  $html_expect .= " }\n";
49 
50  $html_expect .= "if (test!=null)\n";
51  $html_expect .= " {\n";
52  $html_expect .= " test.onreadystatechange=test_Reply;\n";
53  /***
54  'true' means asynchronous request.
55  Rather than waiting for the reply, the reply is
56  managed by the onreadystatechange event handler.
57  ***/
58  $html_expect .= " test.open('GET',Url,true);\n";
59  $html_expect .= " test.send(null);\n";
60  $html_expect .= " }\n";
61  $html_expect .= "else\n";
62  $html_expect .= " {\n";
63  $html_expect .= " alert('Your browser does not support XMLHTTP.');\n";
64  $html_expect .= " return;\n";
65  $html_expect .= " }\n";
66  $html_expect .= "}\n";
67  $html_expect_script = $script_header.$html_expect.$script_foot;
68  $this->assertEquals($html_expect_script, $html_result);
69 
71  $html_result = ActiveHTTPscript("test", 0);
72  $this->assertEquals($html_expect, $html_result);
73  }
74 
78  protected function tearDown() : void
79  {
80  }
81 }
testActiveHTTPscript()
test for ActiveHTTPscript
setUp()
initialization
tearDown()
clean the env
ActiveHTTPscript($RequestName, $IncludeScriptTags=1)
Given a function name, create the JavaScript needed for doing the request.