PHPUnit2
[ class tree: PHPUnit2 ] [ index: PHPUnit2 ] [ all elements ]

Class: PHPUnit2_Extensions_MockObject_Mock

Source Location: /PHPUnit2-3.0.0alpha11/Extensions/MockObject/Mock.php

Class Overview


Provides generation of mock classes and objects from existing classes.


Author(s):

Version:

  • Release: @package_version@

Copyright:

  • 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de>

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 92]
Provides generation of mock classes and objects from existing classes.

The mocked class will contain all the methods of the original class but with a different implementation which will call the current PHPUnit2_Extensions_MockObject_InvocationMocker object, this objects takes care of checking expectations and stubs. It is also possible to define which methods are mocked by passing an array of method names.

The simplest way to define a mock object is to do:

  1.  $o = new Mock_MyClass;

The generate() method returns an object which can be queried.

  1.  $m = PHPUnit2_Extensions_MockObject::generate('MyClass');
  2.  $o = new $m->mockClassName;
  3.  print "original class was: . $m->className;



[ Top ]


Class Variables

$className =

[line 95]

  • Access: public

Type:   mixed


[ Top ]

$methods =

[line 96]

  • Access: public

Type:   mixed


[ Top ]

$mockClassName =

[line 94]

  • Access: public

Type:   mixed


[ Top ]



Method Detail

__construct (Constructor)   [line 98]

PHPUnit2_Extensions_MockObject_Mock __construct( $className, [Array $methods = array()], [ $mockClassName = ''])

  • Access: public

Parameters:

   $className   — 
Array   $methods   — 
   $mockClassName   — 

[ Top ]

canMockMethod   [line 181]

void canMockMethod( ReflectionMethod $method)

  • Access: protected

Parameters:

ReflectionMethod   $method   — 

[ Top ]

generate   [line 119]

void generate( $className, [Array $methods = array()], [ $mockClassName = ''])

  • Access: public

Parameters:

   $className   — 
Array   $methods   — 
   $mockClassName   — 

[ Top ]

generateClass   [line 130]

void generateClass( )

  • Access: protected

[ Top ]

generateClassDefinition   [line 153]

void generateClassDefinition( ReflectionClass $class)

  • Access: protected

Parameters:

ReflectionClass   $class   — 

[ Top ]

generateCloneCode   [line 283]

void generateCloneCode( ReflectionClass $class)

  • Access: protected

Parameters:

ReflectionClass   $class   — 

[ Top ]

generateConstructorCode   [line 261]

void generateConstructorCode( ReflectionClass $class)

  • Access: protected

Parameters:

ReflectionClass   $class   — 

[ Top ]

generateMethodDefinition   [line 199]

void generateMethodDefinition( ReflectionMethod $method)

  • Access: protected

Parameters:

ReflectionMethod   $method   — 

[ Top ]

generateMethodParameters   [line 297]

void generateMethodParameters( ReflectionMethod $method, [ $asCall = FALSE])

  • Access: protected

Parameters:

ReflectionMethod   $method   — 
   $asCall   — 

[ Top ]

generateMockApi   [line 240]

void generateMockApi( ReflectionClass $class)

  • Access: protected

Parameters:

ReflectionClass   $class   — 

[ Top ]

shouldMockMethod   [line 194]

void shouldMockMethod( ReflectionMethod $method)

  • Access: protected

Parameters:

ReflectionMethod   $method   — 

[ Top ]


Documentation generated on Mon, 11 Mar 2019 14:40:39 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.