class XMLRPCValidator1Test in SimpleTest 5
Same name and namespace in other branches
- 6 tests/xmlrpc_validator1.test \XMLRPCValidator1Test
Hierarchy
- class \DrupalTestCase extends \WebTestCase
- class \XMLRPCValidator1Test
Expanded class hierarchy of XMLRPCValidator1Test
File
- tests/
xmlrpc_validator1.test, line 2
View source
class XMLRPCValidator1Test extends DrupalTestCase {
function get_info() {
return array(
'name' => 'XML-RPC validator1',
'desc' => t('See !validator-link. note: simpletest_xmlrpc.module must be enabled', array(
'!validator-link' => l('the xmlrpc validator1 specification', 'http://www.xmlrpc.com/validator1Docs'),
)),
'group' => 'XML-RPC Tests',
);
}
function test_run_all_tests() {
if (!$this
->drupalModuleEnable('simpletest_xmlrpc')) {
return FALSE;
}
$xml_url = url(NULL, NULL, NULL, TRUE) . 'xmlrpc.php';
srand();
mt_srand();
$array_1 = array(
array(
'curly' => mt_rand(-100, 100),
),
array(
'curly' => mt_rand(-100, 100),
),
array(
'larry' => mt_rand(-100, 100),
),
array(
'larry' => mt_rand(-100, 100),
),
array(
'moe' => mt_rand(-100, 100),
),
array(
'moe' => mt_rand(-100, 100),
),
array(
'larry' => mt_rand(-100, 100),
),
);
shuffle($array_1);
$l_res_1 = simpletest_xmlrpc_arrayOfStructsTest($array_1);
$r_res_1 = xmlrpc($xml_url, 'validator1.arrayOfStructsTest', $array_1);
$this
->assertIdentical($l_res_1, $r_res_1, 'array of structs test: %s');
$string_2 = 't\'&>>zf"md>yr>xlcev<h<"k&j<og"w&&>">>uai"np&s>>q\'&b<>"&&&';
$l_res_2 = simpletest_xmlrpc_countTheEntities($string_2);
$r_res_2 = xmlrpc($xml_url, 'validator1.countTheEntities', $string_2);
$this
->assertIdentical($l_res_2, $r_res_2, 'count the entities test: %s');
$struct_3 = array(
'moe' => mt_rand(-100, 100),
'larry' => mt_rand(-100, 100),
'curly' => mt_rand(-100, 100),
'homer' => mt_rand(-100, 100),
);
$l_res_3 = simpletest_xmlrpc_easyStructTest($struct_3);
$r_res_3 = xmlrpc($xml_url, 'validator1.easyStructTest', $struct_3);
$this
->assertIdentical($l_res_3, $r_res_3, 'easy struct test: %s');
$struct_4 = array(
'sub1' => array(
'bar' => 13,
),
'sub2' => 14,
'sub3' => array(
'foo' => 1,
'baz' => 2,
),
'sub4' => array(
'ss' => array(
'sss' => array(
'ssss' => 'sssss',
),
),
),
);
$l_res_4 = simpletest_xmlrpc_echoStructTest($struct_4);
$r_res_4 = xmlrpc($xml_url, 'validator1.echoStructTest', $struct_4);
$this
->assertIdentical($l_res_4, $r_res_4, 'echo struct test: %s');
$int_5 = mt_rand(-100, 100);
$bool_5 = $int_5 % 2 == 0;
$string_5 = $this
->randomName();
$double_5 = (double) (mt_rand(-1000, 1000) / 100);
$time_5 = time();
$base64_5 = $this
->randomName(100);
$l_res_5 = simpletest_xmlrpc_manyTypesTest($int_5, $bool_5, $string_5, $double_5, xmlrpc_date($time_5), $base64_5);
$l_res_5[5] = $l_res_5[5]->data;
/* override warpping */
$r_res_5 = xmlrpc($xml_url, 'validator1.manyTypesTest', $int_5, $bool_5, $string_5, $double_5, xmlrpc_date($time_5), xmlrpc_base64($base64_5));
/* Contains objects, objects are not equal */
// See http://drupal.org/node/37766 why this currnetly fails
$this
->assertEqual($l_res_5, $r_res_5, 'many types test: %s');
$size = mt_rand(100, 200);
$array_6 = array();
for ($i = 0; $i < $size; $i++) {
$array_6[] = $this
->randomName(mt_rand(8, 12));
}
$l_res_6 = simpletest_xmlrpc_moderateSizeArrayCheck($array_6);
$r_res_6 = xmlrpc($xml_url, 'validator1.moderateSizeArrayCheck', $array_6);
$this
->assertIdentical($l_res_6, $r_res_6, 'moderate size array check: %s');
$struct_7 = array();
for ($y = 2000; $y < 2002; $y++) {
for ($m = 3; $m < 5; $m++) {
for ($d = 1; $d < 6; $d++) {
$ys = (string) $y;
$ms = sprintf('%02d', $m);
$ds = sprintf('%02d', $d);
$struct_7[$ys][$ms][$ds]['moe'] = mt_rand(-100, 100);
$struct_7[$ys][$ms][$ds]['larry'] = mt_rand(-100, 100);
$struct_7[$ys][$ms][$ds]['curly'] = mt_rand(-100, 100);
}
}
}
$l_res_7 = simpletest_xmlrpc_nestedStructTest($struct_7);
$r_res_7 = xmlrpc($xml_url, 'validator1.nestedStructTest', $struct_7);
$this
->assertIdentical($l_res_7, $r_res_7, 'nested struct test: %s');
$int_8 = mt_rand(-100, 100);
$l_res_8 = simpletest_xmlrpc_simpleStructReturnTest($int_8);
$r_res_8 = xmlrpc($xml_url, 'validator1.simpleStructReturnTest', $int_8);
$this
->assertIdentical($l_res_8, $r_res_8, 'nested struct test: %s');
/* Now test multicall */
$x = array();
$x[] = array(
'validator1.arrayOfStructsTest',
$array_1,
);
$x[] = array(
'validator1.countTheEntities',
$string_2,
);
$x[] = array(
'validator1.easyStructTest',
$struct_3,
);
$x[] = array(
'validator1.echoStructTest',
$struct_4,
);
$x[] = array(
'validator1.manyTypesTest',
$int_5,
$bool_5,
$string_5,
$double_5,
xmlrpc_date($time_5),
xmlrpc_base64($base64_5),
);
$x[] = array(
'validator1.moderateSizeArrayCheck',
$array_6,
);
$x[] = array(
'validator1.nestedStructTest',
$struct_7,
);
$x[] = array(
'validator1.simpleStructReturnTest',
$int_8,
);
$a_l_res = array(
$l_res_1,
$l_res_2,
$l_res_3,
$l_res_4,
$l_res_5,
$l_res_6,
$l_res_7,
$l_res_8,
);
$a_r_res = xmlrpc($xml_url, $x);
$this
->assertEqual($a_l_res, $a_r_res, 'multicall equals result');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DrupalTestCase:: |
property | |||
DrupalTestCase:: |
property | |||
DrupalTestCase:: |
property | |||
DrupalTestCase:: |
property | |||
DrupalTestCase:: |
property | |||
DrupalTestCase:: |
function | Will trigger a pass if both parameters refer to different objects. Fail otherwise. | ||
DrupalTestCase:: |
function | Will trigger a pass if the two parameters have the same value only. Otherwise a fail. | ||
DrupalTestCase:: |
function | Confirms that an error has occurred and optionally that the error text matches exactly. | ||
DrupalTestCase:: |
function | Confirms that an error has occurred and that the error text matches a Perl regular expression. | ||
DrupalTestCase:: |
function | Will trigger a pass if the two parameters have the same value and same type. Otherwise a fail. | ||
DrupalTestCase:: |
function | Type and class test. Will pass if class matches the type name or is a subclass or if not an object, but the type is correct. | ||
DrupalTestCase:: |
function | Confirms that no errors have occurred so far in the test method. | ||
DrupalTestCase:: |
function | Type and class mismatch test. Will pass if class name or underling type does not match the one specified. | ||
DrupalTestCase:: |
function | Will trigger a pass if the two parameters have a different value. Otherwise a fail. | ||
DrupalTestCase:: |
function | Will trigger a pass if the two parameters have the different value or different type. | ||
DrupalTestCase:: |
function | Will be true if the value is set. | ||
DrupalTestCase:: |
function | Will trigger a pass if the Perl regex pattern is not present in subject. Fail if found. | ||
DrupalTestCase:: |
function | Will trigger a pass if the raw text is NOT found on the loaded page Fail otherwise. | ||
DrupalTestCase:: |
function | Will be true if the value is null. | ||
DrupalTestCase:: |
function | Will trigger a pass if both parameters refer to the same object. Fail otherwise. | ||
DrupalTestCase:: |
function | Will trigger a pass if the Perl regex pattern is found in the subject. Fail otherwise. | ||
DrupalTestCase:: |
function | Will trigger a pass if the raw text is found on the loaded page Fail otherwise. | ||
DrupalTestCase:: |
function | Follows a link by name. Will click the first link found with this link text by default, or a later one if an index is given. Match is case insensitive with normalised space. Does make assertations if the click was sucessful or not and it does… | ||
DrupalTestCase:: |
function | @abstract Checks to see if we need to send a http-auth header to authenticate when browsing a site. | ||
DrupalTestCase:: |
function | Create a role / perm combination specified by permissions | ||
DrupalTestCase:: |
function | Creates a user / role / permissions combination specified by permissions | ||
DrupalTestCase:: |
function | @abstract Brokder for the get function adds the authentication headers if necessary @author Earnest Berry III <earnest.berry@gmail.com> | ||
DrupalTestCase:: |
function | @TODO: needs documentation | ||
DrupalTestCase:: |
function | Logs in a user with the internal browser | ||
DrupalTestCase:: |
function | Disables a drupal module | ||
DrupalTestCase:: |
function | Enables a drupal module | ||
DrupalTestCase:: |
function | Do a post request on a drupal page. It will be done as usual post request with SimpleBrowser | ||
DrupalTestCase:: |
function | @abstract Broker for the post function adds the authentication headers if necessary @author Earnest Berry III <earnest.berry@gmail.com> | ||
DrupalTestCase:: |
function | |||
DrupalTestCase:: |
function | Set a druapl variable and keep track of the changes for tearDown() | ||
DrupalTestCase:: |
function | Generates a random string, to be used as name or whatever | ||
DrupalTestCase:: |
function | Just some info for the reporter | ||
DrupalTestCase:: |
function | tearDown implementation, setting back switched modules etc | 1 | |
XMLRPCValidator1Test:: |
function | |||
XMLRPCValidator1Test:: |
function |