-
Notifications
You must be signed in to change notification settings - Fork 153
Code Documentation
TestSwarm (as of 0.3) is in an object-oriented way and and context based. A short overview of the main classes follows.
Given a user agent string this class parses into an object and extracts information about the client. Such as browser name, version, engine and operating system. It also tries to find a matching entry from the useragents
table.
Although right now the only supported database backend is MySQL, the Database class abstracts most MySQL specific methods so that it is fairly easy to change this later on. It also offers various convenience methods (such as getOne
, getRow
and getRows
), and uses proper context based calls to the underlying php functions (e.g. methods like mysql_error
and mysql_insert_id
are always called with the connection object in case multiple connections are active).
Abstraction for accessing request data ($_GET,
$_POST,
$_SESSIONand IP-address). Also provides several convenience methods such as
wasPosted(),
getBool, getInt
, getArray
and getVal( key, defaultValue )
.
The above and other classes are lazy loaded when they are needed. Both the class files themselves are lazy-loaded using the PHP Autoloader and the initialization of the classes is done on-the-fly when they are first needed and the instance is cached from there for re-use.
The base class for all actions. Actions are the front-end independent logic. Pages and APIs use these to get the information in a structured format.
Formats the skin for index.php
requests and Page-extending classes implement page specific output, gathered from one or more instances of Action classes.
As of TestSwarm 0.3 TestSwarm practically uses zero globals. There are however 2 global variables used in some legacy functions that will be phased out later.
-
$swarmInstallDir
(string) This is the absolute path of the directory where the TestSwarm install is located in the file system. -
$swarmContext
(TestSwarmContext) Primary instance of theTestSwarmContext
class. Should be used as little as possible. In general only within an entry point file (index.php
,api.php
). In any other environment the current context should be used from within the enclosing class.
It's not required to define all settings in testswarm.ini
. Only the ones you need to override have to be defined there. The others can be commented out or left out entirely. The application will populate them with the defaults automatically. The default sample INI (./config/config-sample.ini
) contains more information about each setting. Refer to that file for documentation on the settings.