Class PhpSecInfo_Test

Description

This is a skeleton class for PhpSecInfo tests You should extend this to make a "group" skeleton to categorize tests under, then make a subdir with your group name that contains test classes extending your group skeleton class.

Located in /PhpSecInfo/Test/Test.php (line 36)


	
			
Direct descendents
Class Description
PhpSecInfo_Test_Cgi This is a skeleton class for PhpSecInfo "CGI" tests
PhpSecInfo_Test_Core This is a skeleton class for PhpSecInfo "Core" tests
PhpSecInfo_Test_Curl This is a skeleton class for PhpSecInfo "Curl" tests
PhpSecInfo_Test_Session This is a skeleton class for PhpSecInfo "Session" tests
Variable Summary
string $test_group
string $test_name
string $_language
string $_message
array $_messages
integer $_result
Method Summary
boolean|mixed getBooleanIniValue (string $ini_key)
string getMessage ()
string|boolean getMoreInfoURL ()
integer getResult ()
string getStringValue (mixed $val)
string getTestGroup ()
string getTestName ()
array|boolean getUnixId ()
boolean isTestable ()
boolean osIsWindows ()
integer returnBytes (string $val)
void setMessageForResult (integer $result_code, string $language_code, string $message)
void setTestGroup (string $test_group)
void setTestName (string $test_name)
string|NULL sys_get_temp_dir ()
void test ()
integer _execTest ()
void _setMessage (integer $result_code, string $language_code)
void _setMessages ()
void _setResult (integer $result_code)
Variables
mixed $current_value (line 93)

Enter description here...

string $test_group = 'misc' (line 46)

This value is used to group test results together.

For example, all tests related to the mysql lib should be grouped under "mysql."


Redefined in descendants as:
string $test_name = 'misc_test' (line 54)

This should be a unique, human-readable identifier for this test


Redefined in descendants as:
string $_language = PHPSECINFO_LANG_DEFAULT (line 86)

the language code. Should be a pointer to the setting in the PhpSecInfo object

string $_message (line 78)

The message corresponding to the result of the test

array $_messages = array() (line 105)

This is a hash of messages that correspond to various test result levels.

There are five messages, each corresponding to one of the result constants (PHPSECINFO_TEST_RESULT_OK, PHPSECINFO_TEST_RESULT_NOTICE, PHPSECINFO_TEST_RESULT_WARN, PHPSECINFO_TEST_RESULT_ERROR, PHPSECINFO_TEST_RESULT_NOTRUN)

  • var: array
integer $_result = PHPSECINFO_TEST_RESULT_NOTRUN (line 70)

The result returned from the test

Methods
Constructor PhpSecInfo_Test (line 113)

Constructor for Test skeleton class

PhpSecInfo_Test PhpSecInfo_Test ()
getBooleanIniValue (line 422)

This method converts the several possible return values from allegedly "boolean" ini settings to proper booleans

Properly converted input values are: 'off', 'on', 'false', 'true', '', '0', '1' (the last two might not be neccessary, but I'd rather be safe)

If the ini_value doesn't match any of those, the value is returned as-is.

boolean|mixed getBooleanIniValue (string $ini_key)
  • string $ini_key: the ini_key you need the value of
getCurrentTestValue (line 249)

returns the current value. This function should be used to access the value for display. All values are cast as strings

string getCurrentTestValue ()
getMessage (line 204)

Retrieves the message for the current result

string getMessage ()
getMoreInfoURL (line 296)

Returns a link to a page with detailed information about the test

URL is formatted as PHPSECINFO_TEST_MOREINFO_BASEURL + testName

string|boolean getMoreInfoURL ()
getRecommendedTestValue (line 259)

returns the recommended value. This function should be used to access the value for display. All values are cast as strings

string getRecommendedTestValue ()
getResult (line 192)

Retrieves the result

integer getResult ()
getStringValue (line 401)

This just does the usual PHP string casting, except for the boolean FALSE value, where the string "0" is returned instead of an empty string

string getStringValue (mixed $val)
  • mixed $val
getTestGroup (line 343)

Returns the test group this test belongs to

string getTestGroup ()
getTestName (line 314)

This retrieves the name of this test.

If a name has not been set, this returns a formatted version of the class name.

string getTestName ()
getUnixId (line 504)

Returns an array of data returned from the UNIX 'id' command

includes uid, username, gid, groupname, and groups (if "exec" is enabled). Groups is an array of all the groups the user belongs to. Keys are the group ids, values are the group names.

returns FALSE if no suitable function is available to retrieve the data

array|boolean getUnixId ()
isTestable (line 132)

Determines whether or not it's appropriate to run this test (for example, if this test is for a particular library, it shouldn't be run if the lib isn't loaded).

This is a terrible name, but I couldn't think of a better one atm.

boolean isTestable ()

Redefined in descendants as:
osIsWindows (line 483)

A quick function to determine whether we're running on Windows.

Uses the PHP_OS constant.

boolean osIsWindows ()
returnBytes (line 371)

This function takes the shorthand notation used in memory limit settings for PHP and returns the byte value. Totally stolen from http://us3.php.net/manual/en/function.ini-get.php

  1. echo 'post_max_size in bytes = ' . $this->return_bytes(ini_get('post_max_size'));

integer returnBytes (string $val)
  • string $val
setMessageForResult (line 226)

Sets the message for a given result code and language

  1. $this->setMessageForResult(PHPSECINFO_TEST_RESULT_NOTRUN, 'en', 'This test cannot be run');

void setMessageForResult (integer $result_code, string $language_code, string $message)
  • integer $result_code
  • string $language_code
  • string $message
setTestGroup (line 353)

sets the test group

void setTestGroup (string $test_group)
  • string $test_group
setTestName (line 333)

sets the test name

void setTestName (string $test_name)
  • string $test_name
sys_get_temp_dir (line 463)

sys_get_temp_dir provides some temp dir detection capability that is lacking in versions of PHP that do not have the sys_get_temp_dir() function

string|NULL sys_get_temp_dir ()
test (line 179)

This is the wrapper that executes the test and sets the result code and message

void test ()
_execTest (line 143)

The "meat" of the test. This is where the real test code goes. You should override this when extending

integer _execTest ()

Redefined in descendants as:
_setMessage (line 280)

Sets the $this->_message variable based on the passed result and language codes

void _setMessage (integer $result_code, string $language_code)
  • integer $result_code
  • string $language_code
_setMessages (line 157)

This function loads up result messages into the $this->_messages array.

Using this method rather than setting $this->_messages directly allows result messages to be inherited. This is broken out into a separate function rather than the constructor for ease of extension purposes (php4 is whack, man).

void _setMessages ()

Redefined in descendants as:
_setResult (line 269)

Sets the result code

void _setResult (integer $result_code)
  • integer $result_code

Documentation generated on Fri, 06 Apr 2007 13:32:22 -0400 by phpDocumentor 1.3.0RC3