ultimix

- Main Page
- Data Structures
- Files
- Examples

- Data Structures
- Data Structure Index
- Data Fields

Public Member Functions | Data Fields
testing_1_0_0 Class Reference

## Public Member Functions
| get_package_directory ()
| get_testing_object ()
| security ($Options)
| get_sub_test_count ()
| get_sub_test_name ()
| run_exact_test ($Methods, $m)
| find_test_and_run ($Methods)
| run_sub_test ()
| run_views ()
| view ($Options)

## Data Fields
| $TestingObject = false

## Detailed Description

Class for unit testing.

Author
  Dodonov A.A.

Definition at line 26 of file testing.php.

## Member Function Documentation

find_test_and_run | ( |  | $Methods | ) |

Function finds test and run it.

Parameters

  $Methods | - Test class'es methods.

Returns
  Test's result.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 326 of file testing.php.

{
try
{
$Counter = 0;
$Security = get_package( 'security' , 'last' );
foreach( $Methods as $key => $m )
{
if( strpos( $m , 'test' ) === 0 && $Counter++ == $Security->get_gp( 'test_id' , 'integer' ) )
{
return( $this->run_exact_test( $Methods , $m ) );
}
}
if( $Security->get_gp( 'test_id' , 'integer' , 0 ) >= $Counter )
{
return( 'Value test_id is too big. It mast be less than '.$Counter );
}
else
{
return( 'Test was not called' );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_package_directory | ( |  | ) |

Getting package directory.

Returns
  Package path.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 58 of file testing.php.

{
try
{
$Security = get_package( 'security' , 'last' );
$PackageDirectory = _get_package_relative_path_ex(
$Security->get_gp( 'testing_package_name' , 'command' ) ,
$Security->get_gp( 'testing_package_version' , 'command' , 'last' )
);
return( $PackageDirectory );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_sub_test_count | ( |  | ) |

Function returns subtests count.

Returns
  Subtests count.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 186 of file testing.php.

{
try
{
/* gettting count of tests */
$this->get_testing_object();
$Methods = get_class_methods( get_class( $this->TestingObject ) );
$Counter = 0;
foreach( $Methods as $key => $m )
{
if( strpos( $m , 'test' ) === 0 )
{
$Counter++;
}
}
return( $Counter );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_sub_test_name | ( |  | ) |

Function returns subtest's name.

Returns
  Subtest's name.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 230 of file testing.php.

{
try
{
$this->get_testing_object();
$Methods = get_class_methods( get_class( $this->TestingObject ) );
$Counter = 0;
$Security = get_package( 'security' , 'last' );
foreach( $Methods as $key => $m )
{
if( strpos( $m , 'test' ) === 0 )
{
if( $Counter == $Security->get_gp( 'test_id' , 'integer' ) )
{
return( $m );
}
$Counter++;
}
}
if( $Security->get_gp( 'test_id' , 'integer' , 0 ) >= $Counter )
{
return( 'Value test_id is too big. It mast be less than '.$Counter );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_testing_object | ( |  | ) |

Getting object with tests.

Returns
  Object with unit-tests.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 95 of file testing.php.

{
try
{
if( $this->TestingObject === false )
{
$PackageDirectory = $this->get_package_directory();
if( file_exists( "$PackageDirectory/include/php/unit_tests.php" ) === false )
{
return( false );
}
require_once( "$PackageDirectory/include/php/unit_tests.php" );
$this->TestingObject = new unit_tests();
}
if( $this->TestingObject === false )
{
throw( new Exception( "Testing class was not found" ) );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

run_exact_test | ( |  | $Methods,
|  |  | $m
| ) |  |

Function runs exact test.

Returns
  Test's result.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 280 of file testing.php.

{
try
{
if( in_array( 'set_up' , $Methods ) )
{
call_user_func_array( array( $this->TestingObject , 'set_up' ) , array() );
}
$Result = call_user_func_array( array( $this->TestingObject , $m ) , array() );
if( in_array( 'tear_down' , $Methods ) )
{
call_user_func_array( array( $this->TestingObject , 'tear_down' ) , array() );
}
return( $Result );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

run_sub_test | ( |  | ) |

Function runs test.

Returns
  Test's result.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 374 of file testing.php.

{
try
{
/* running subtest */
$this->get_testing_object();
$Methods = get_class_methods( get_class( $this->TestingObject ) );
if( isset( $Methods[ 0 ] ) == false )
{
return( 'No test were found' );
}
return( $this->find_test_and_run( $Methods ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

run_views | ( |  | ) |

Function runs viwe's functions.

Returns
  Result.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 413 of file testing.php.

{
try
{
$Security = get_package( 'security' , 'last' );
if( $Security->get_gp( 'action' , 'command' , 'none' ) === 'get_sub_test_count' )
{
return( $this->get_sub_test_count() );
}
if( $Security->get_gp( 'action' , 'command' , 'none' ) === 'get_sub_test_name' )
{
return( $this->get_sub_test_name() );
}
if( $Security->get_gp( 'action' , 'command' , 'none' ) === 'run_sub_test' )
{
return( $this->run_sub_test() );
}
return( 'Illegal request parameters' );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

security | ( |  | $Options | ) |

Security validations.

Parameters

  $Options | - Display options.

Returns
  false if everyting is OK.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 145 of file testing.php.

{
try
{
$UserController = get_package( 'user::user_controller' , 'last' , __FILE__ );
$UserController->login( $Options );
$Permits = get_package( 'permit::permit_algorithms' , 'last' , __FILE__ );
if( $Permits->object_has_permit( false , 'user' , 'tester' ) === false )
{
$UserAlgorithms = get_package( 'user::user_algorithms' , 'last' , __FILE__ );
print( $UserAlgorithms->get_login() );
return( 'No permits' );
}
return( false );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

view | ( |  | $Options | ) |

Components view.

Parameters

  $Options | - Display options.

Returns
  HTML code of the component.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 464 of file testing.php.

{
try
{
if( ( $Result = $this->security( $Options ) ) !== false )
{
return( $Result );
}
return( $this->run_views() );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

## Field Documentation

$TestingObject = false

Object with unit-tests.

Author
  Dodonov A.A.

Definition at line 38 of file testing.php.

The documentation for this class was generated from the following file:

- packages/testing/testing.php