class QueryParametersToURLUnitTestCase in Query Parameters To URL 7
Class QueryParametersToURLUnitTestCase.
Hierarchy
- class \DrupalTestCase
- class \DrupalUnitTestCase
Expanded class hierarchy of QueryParametersToURLUnitTestCase
File
- ./
query_parameters_to_url.test, line 302 - Query Arguments To URL tests.
View source
class QueryParametersToURLUnitTestCase extends DrupalUnitTestCase {
/**
* Returns test info.
*/
public static function getInfo() {
return array(
'name' => 'Query Parameters To URL Unit tests',
'description' => 'Test query parameter values encoding / decoding.',
'group' => 'Query Parameters To URL',
);
}
/**
* Setup.
*/
public function setUp() {
drupal_load('module', 'query_parameters_to_url');
parent::setUp();
}
/**
* Returns a list of test cases.
*/
public function getTestCases() {
$test_cases = array();
// ?value[a][1][2]=3&value[a][1][6]=7&value[b]=4&value[c]=5
$test_cases[] = array(
'parameter_value_array' => array(
'a' => array(
1 => array(
2 => 3,
6 => 7,
),
),
'b' => 4,
'c' => 5,
),
'encoded_parameter_value_string' => 'a__1__2__3--a__1__6__7--b__4--c__5',
);
// ?f[0]=standard_page&f[1]=sm_og_group_ref:node:100
$test_cases[] = array(
'parameter_value_array' => array(
0 => 'standard_page',
1 => 'sm_og_group_ref:node:100',
),
'encoded_parameter_value_string' => '0__standard_page--1__sm_og_group_ref:node:100',
);
return $test_cases;
}
/**
* Unpacks a test case.
*/
public function unpackTestCase($test_case) {
return array(
$test_case['parameter_value_array'],
$test_case['encoded_parameter_value_string'],
);
}
/**
* Tests if a query parameter's values are properly encoded.
*/
public function testQueryParameterValuesEncoding() {
$test_cases = $this
->getTestCases();
foreach ($test_cases as $test_case) {
list($parameter_values, $expected_query_parameter_string) = $this
->unpackTestCase($test_case);
$encoded_query_parameter = query_parameters_to_url_encode_query_parameter_values($parameter_values);
$message = 'Query parameter values are encoded properly.<br/> Initial array:<br/>!initial<br/>Encoded to string:<br/>!string';
$message = format_string($message, array(
'!initial' => var_export($parameter_values, TRUE),
'!string' => var_export($encoded_query_parameter, TRUE),
));
$this
->assertEqual($encoded_query_parameter, $expected_query_parameter_string, $message);
}
}
/**
* Tests if an encoded query parameter's values is properly decoded.
*/
public function testQueryParameterValuesDecoding() {
$test_cases = $this
->getTestCases();
foreach ($test_cases as $test_case) {
list($expected_parameter_values, $encoded_parameter_string) = $this
->unpackTestCase($test_case);
$decoded_query_parameter_values = query_parameters_to_url_decode_query_parameter_values($encoded_parameter_string);
$message = 'Query parameter values are decoded properly.<br/> Initial string:<br/>!initial<br/>Decoded to array:<br/>!array';
$message = format_string($message, array(
'!initial' => var_export($encoded_parameter_string, TRUE),
'!array' => var_export($decoded_query_parameter_values, TRUE),
));
$this
->assertEqual($decoded_query_parameter_values, $expected_parameter_values, $message);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DrupalTestCase:: |
protected | property | Assertions thrown in that test case. | |
DrupalTestCase:: |
protected | property | The database prefix of this test run. | |
DrupalTestCase:: |
protected | property | The original file directory, before it was changed for testing purposes. | |
DrupalTestCase:: |
public | property | Current results of this test case. | |
DrupalTestCase:: |
protected | property | Flag to indicate whether the test has been set up. | |
DrupalTestCase:: |
protected | property | ||
DrupalTestCase:: |
protected | property | ||
DrupalTestCase:: |
protected | property | This class is skipped when looking for the source of an assertion. | |
DrupalTestCase:: |
protected | property | The test run ID. | |
DrupalTestCase:: |
protected | property | Time limit for the test. | |
DrupalTestCase:: |
public | property | Whether to cache the installation part of the setUp() method. | |
DrupalTestCase:: |
public | property | Whether to cache the modules installation part of the setUp() method. | |
DrupalTestCase:: |
protected | property | URL to the verbose output file directory. | |
DrupalTestCase:: |
protected | function | Internal helper: stores the assert. | |
DrupalTestCase:: |
protected | function | Check to see if two values are equal. | |
DrupalTestCase:: |
protected | function | Check to see if a value is false (an empty string, 0, NULL, or FALSE). | |
DrupalTestCase:: |
protected | function | Check to see if two values are identical. | |
DrupalTestCase:: |
protected | function | Check to see if two values are not equal. | |
DrupalTestCase:: |
protected | function | Check to see if two values are not identical. | |
DrupalTestCase:: |
protected | function | Check to see if a value is not NULL. | |
DrupalTestCase:: |
protected | function | Check to see if a value is NULL. | |
DrupalTestCase:: |
protected | function | Check to see if a value is not false (not an empty string, 0, NULL, or FALSE). | |
DrupalTestCase:: |
public static | function | Delete an assertion record by message ID. | |
DrupalTestCase:: |
protected | function | Fire an error assertion. | 1 |
DrupalTestCase:: |
public | function | Handle errors during test runs. | 1 |
DrupalTestCase:: |
protected | function | Handle exceptions. | |
DrupalTestCase:: |
protected | function | Fire an assertion that is always negative. | |
DrupalTestCase:: |
public static | function | Converts a list of possible parameters into a stack of permutations. | |
DrupalTestCase:: |
protected | function | Cycles through backtrace until the first non-assertion method is found. | |
DrupalTestCase:: |
public static | function | Returns the database connection to the site running Simpletest. | |
DrupalTestCase:: |
public static | function | Store an assertion from outside the testing context. | |
DrupalTestCase:: |
protected | function | Fire an assertion that is always positive. | |
DrupalTestCase:: |
public static | function | Generates a random string containing letters and numbers. | |
DrupalTestCase:: |
public static | function | Generates a random string of ASCII characters of codes 32 to 126. | |
DrupalTestCase:: |
public | function | Run all tests in this class. | |
DrupalTestCase:: |
protected | function | Logs a verbose message in a text file. | |
DrupalUnitTestCase:: |
protected | function | 1 | |
DrupalUnitTestCase:: |
function |
Constructor for DrupalUnitTestCase. Overrides DrupalTestCase:: |
||
QueryParametersToURLUnitTestCase:: |
public static | function | Returns test info. | |
QueryParametersToURLUnitTestCase:: |
public | function | Returns a list of test cases. | |
QueryParametersToURLUnitTestCase:: |
public | function |
Setup. Overrides DrupalUnitTestCase:: |
|
QueryParametersToURLUnitTestCase:: |
public | function | Tests if an encoded query parameter's values is properly decoded. | |
QueryParametersToURLUnitTestCase:: |
public | function | Tests if a query parameter's values are properly encoded. | |
QueryParametersToURLUnitTestCase:: |
public | function | Unpacks a test case. |