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 35)


	
			
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 ()
integer getResult ()
string getTestGroup ()
string getTestName ()
boolean isTestable ()
integer returnBytes (string $val)
void setMessageForResult (integer $result_code, string $language_code, string $message)
void setTestName (string $test_name)
void test ()
void _execTest ()
void _setMessage (integer $result_code, string $language_code)
void _setMessages ()
void _setResult (integer $result_code)
Variables
string $test_group = 'misc' (line 45)

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 53)

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


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

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

string $_message (line 69)

The message corresponding to the result of the test

array $_messages = array() (line 92)

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

Redefined in descendants as:
integer $_result = PHPSECINFO_TEST_RESULT_NOTRUN (line 61)

The result returned from the test

Methods
Constructor PhpSecInfo_Test (line 116)

Constructor for Test skeleton class

PhpSecInfo_Test PhpSecInfo_Test ()
getBooleanIniValue (line 344)

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
getMessage (line 194)

Retrieves the message for the current result

string getMessage ()
getResult (line 182)

Retrieves the result

integer getResult ()
getTestGroup (line 296)

Returns the test group this test belongs to

string getTestGroup ()
getTestName (line 267)

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 ()
isTestable (line 130)

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:
returnBytes (line 314)

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 215)

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
setTestName (line 286)

sets the test name

void setTestName (string $test_name)
  • string $test_name
test (line 169)

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

void test ()
_execTest (line 142)

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

void _execTest ()

Redefined in descendants as:
_setMessage (line 247)

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 156)

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 extending purposes (php4 is whack, man).

void _setMessages ()

Redefined in descendants as:
_setResult (line 236)

Sets the result code

void _setResult (integer $result_code)
  • integer $result_code

Documentation generated on Tue, 24 Oct 2006 10:53:40 -0400 by phpDocumentor 1.3.0RC3