Back to index

php5  5.3.10
Public Member Functions | Protected Attributes | Private Attributes
gtMethod Class Reference

Class for method under test (see gtFunction for non-OO tests) More...

Inheritance diagram for gtMethod:
Inheritance graph
[legend]
Collaboration diagram for gtMethod:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 __construct ($className, $methodName)
 Construct gtMethod object from the class and method names.
 setConstructorArgumentNames ()
 Set the names of the class constructor arguments.
 setArgumentNames ()
 Set the names of the mandatory and optional arguments to the method.
 getConstructorArgumentNames ()
 Return the list of constructor argument names.
 getName ()
 Return the name of the method.
 getClassName ()
 Return the name of the class.
 setConstructorArgumentList ()
 Set the list of arguments to be passed to the constructor.
 getConstructorArgumentList ()
 Return the list of the arguments to be passed to the constructor.
 setConstructorInitStatements ()
 Set up the source statements that initialise constructor arguments;.
 getConstructorInitStatements ()
 Return the constructor initialisation statements.
 getMandatoryArgumentNames ()
 Return the list of all mandatory argument names.
 getOptionalArgumentNames ()
 Return the list of all optional argument names.
 setArgumentLists ()
 setExtraArgumentList ()
 Set the argument list to call the subject with.
 getExtraArgumentList ()
 Return the list of arguments as it appears in the function call.
 setShortArgumentList ()
 Set the list of function arguments to be one less that the number of mandatory arguments.
 getShortArgumentList ()
 Return the short list of arguments.
 setValidArgumentLists ()
 Construct the list of all possible ways to call the subject (function or method)
 getValidArgumentLists ()
 Return the array of all possible sets of method/function arguments.
 getMaximumArgumentList ()
 Returns the argument list with the greatest possible number of arguments.
 setInitialisationStatements ()
 Write initialisation statemenst for all the variables that might be used.
 getInitialisationStatements ()
 Return the initialisation statements.

Protected Attributes

 $optionalArgumentNames
 $mandatoryArgumentNames
 $extraArgumentList = ''
 $shortArgumentList = ''
 $allowedArgumentLists
 $maximumArgumentList
 $initialisationStatements

Private Attributes

 $className
 $methodName
 $constructorArgumentNames
 $constructorArgumentList = ''
 $constructorInitialisationStatements

Detailed Description

Class for method under test (see gtFunction for non-OO tests)

Definition at line 6 of file gtMethod.php.


Constructor & Destructor Documentation

gtMethod::__construct ( className,
methodName 
)

Construct gtMethod object from the class and method names.

Parameters:
string$className
string$methodName

Definition at line 22 of file gtMethod.php.

                                                       {
    $this->className = $className;
    $this->methodName = $methodName;
  }

Member Function Documentation

Return the name of the class.

Returns:
string

Definition at line 87 of file gtMethod.php.

                                 {
    return $this->className;
  }

Return the list of the arguments to be passed to the constructor.

Returns:
string

Definition at line 111 of file gtMethod.php.

Return the list of constructor argument names.

Returns:
array

Definition at line 68 of file gtMethod.php.

Return the constructor initialisation statements.

Returns:
array

Definition at line 135 of file gtMethod.php.

Return the list of arguments as it appears in the function call.

Returns:
string - list of arguments

Definition at line 67 of file gtTestSubject.php.

Return the initialisation statements.

Returns:
unknown

Definition at line 162 of file gtTestSubject.php.

Return the list of all mandatory argument names.

Returns:
array

Definition at line 21 of file gtTestSubject.php.

Returns the argument list with the greatest possible number of arguments.

Returns:
string

Definition at line 135 of file gtTestSubject.php.

                                           {
    return end($this->allowedArgumentLists);
  }

Return the name of the method.

Returns:
string

Definition at line 77 of file gtMethod.php.

                            {
    return $this->methodName;
  }

Return the list of all optional argument names.

Returns:
array

Definition at line 31 of file gtTestSubject.php.

Return the short list of arguments.

Returns:
string - list of arguments

Definition at line 92 of file gtTestSubject.php.

Return the array of all possible sets of method/function arguments.

Returns:
unknown

Definition at line 125 of file gtTestSubject.php.

Definition at line 35 of file gtTestSubject.php.

Here is the call graph for this function:

Set the names of the mandatory and optional arguments to the method.

Definition at line 47 of file gtMethod.php.

                                     {

    $methodClass  = new reflectionMethod($this->className, $this->methodName);
    $parameters = $methodClass->getParameters();

    foreach ($methodClass->getParameters() as $i => $param) {
      if($param->isOptional()) {
        $this->optionalArgumentNames[] = $param->getName();
      } else {
        $this->mandatoryArgumentNames[] = $param->getName();
      }

    }
  }

Set the list of arguments to be passed to the constructor.

Definition at line 95 of file gtMethod.php.

                                               {
    if(count ($this->constructorArgumentNames) > 0) {
      
      for( $i = 0; $i < count( $this->constructorArgumentNames ); $i++) {
        $this->constructorArgumentList .= "\$".$this->constructorArgumentNames[$i].", ";
      }
      $this->constructorArgumentList = substr($this->constructorArgumentList, 0, -2);
    }
  }

Set the names of the class constructor arguments.

Take only mandatory argument names.

Definition at line 32 of file gtMethod.php.

                                                {
    $reflectionClass = new ReflectionClass($this->className);
    $constructor = $reflectionClass->getConstructor();
    foreach($constructor->getParameters() as $i => $param) {
      //if(!$param->isOptional()) {
        $this->constructorArgumentNames[] = $param->getName();
      //}
    }
  }

Set up the source statements that initialise constructor arguments;.

Definition at line 120 of file gtMethod.php.

                                                 {
    if(count ($this->constructorArgumentNames) > 0) {
      foreach( $this->constructorArgumentNames as $name) {
        $this->constructorInitialisationStatements[] = "\$".$name." = ";
      }
    }

  }

Set the argument list to call the subject with.

Adds one extra argument.

Definition at line 45 of file gtTestSubject.php.

                                         {
    if(count ($this->mandatoryArgumentNames) > 0) {
      for( $i = 0; $i < count( $this->mandatoryArgumentNames ); $i++) {
        $this->extraArgumentList .= "\$".$this->mandatoryArgumentNames[$i].", ";
      }
    }
     
    if(count ($this->optionalArgumentNames) > 0) {
      for( $i = 0; $i < count( $this->optionalArgumentNames ); $i++) {
        $this->extraArgumentList .=  "\$".$this->optionalArgumentNames[$i].", ";
      }
    }

    $this->extraArgumentList= $this->extraArgumentList. "\$extra_arg";
  }

Here is the caller graph for this function:

Write initialisation statemenst for all the variables that might be used.

Definition at line 144 of file gtTestSubject.php.

                                                {
    if(count ($this->mandatoryArgumentNames) > 0) {
      foreach( $this->mandatoryArgumentNames as $name) {
        $this->initialisationStatements[] = "\$".$name." = ";
      }
    }
    if(count ($this->optionalArgumentNames) > 0) {
      foreach( $this->optionalArgumentNames as $name) {
        $this->initialisationStatements[] = "\$".$name." = ";
      }
    }
  }

Set the list of function arguments to be one less that the number of mandatory arguments.

Definition at line 76 of file gtTestSubject.php.

                                         {

    if(count ($this->mandatoryArgumentNames) > 0) {
      for( $i = 0; $i < count( $this->mandatoryArgumentNames ) - 1; $i++) {
        $this->shortArgumentList .= "\$".$this->mandatoryArgumentNames[$i].", ";
      }
      $this->shortArgumentList = substr($this->shortArgumentList, 0, -2);
    }
  }

Here is the caller graph for this function:

Construct the list of all possible ways to call the subject (function or method)

Definition at line 101 of file gtTestSubject.php.

                                          {
    $this->allowedArgumentLists[0] = '';
    if(count ($this->mandatoryArgumentNames) > 0) {
      for( $i = 0; $i < count( $this->mandatoryArgumentNames ); $i++) {
        $this->allowedArgumentLists[0] .= "\$".$this->mandatoryArgumentNames[$i].", ";
      }
    }
     
    if(count ($this->optionalArgumentNames) > 0) {
      for( $i = 0; $i < count( $this->optionalArgumentNames ); $i++) {
        $this->allowedArgumentLists[] = $this->allowedArgumentLists[$i]."\$".$this->optionalArgumentNames[$i].", ";
        $this->allowedArgumentLists[$i] = substr ($this->allowedArgumentLists[$i], 0, -2);
      }
    }

    $this->allowedArgumentLists[count($this->allowedArgumentLists) -1 ] = substr($this->allowedArgumentLists[count($this->allowedArgumentLists) -1 ], 0, -2);
  }

Here is the caller graph for this function:


Member Data Documentation

gtTestSubject::$allowedArgumentLists [protected, inherited]

Definition at line 10 of file gtTestSubject.php.

Definition at line 8 of file gtMethod.php.

Definition at line 11 of file gtMethod.php.

Definition at line 10 of file gtMethod.php.

Definition at line 12 of file gtMethod.php.

gtTestSubject::$extraArgumentList = '' [protected, inherited]

Definition at line 7 of file gtTestSubject.php.

Definition at line 14 of file gtTestSubject.php.

Definition at line 5 of file gtTestSubject.php.

gtTestSubject::$maximumArgumentList [protected, inherited]

Definition at line 12 of file gtTestSubject.php.

Definition at line 9 of file gtMethod.php.

gtTestSubject::$optionalArgumentNames [protected, inherited]

Definition at line 4 of file gtTestSubject.php.

gtTestSubject::$shortArgumentList = '' [protected, inherited]

Definition at line 8 of file gtTestSubject.php.


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