You are here

public function PHPUnit_Framework_TestCase::getMock in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/phpunit/src/Framework/TestCase.php \PHPUnit_Framework_TestCase::getMock()

Returns a mock object for the specified class.

@since Method available since Release 3.0.0

Parameters

string $originalClassName Name of the class to mock.:

array|null $methods When provided, only methods whose names are in the array: are replaced with a configurable test double. The behavior of the other methods is not changed. Providing null means that no methods will be replaced.

array $arguments Parameters to pass to the original class' constructor.:

string $mockClassName Class name for the generated test double class.:

bool $callOriginalConstructor Can be used to disable the call to the original class' constructor.:

bool $callOriginalClone Can be used to disable the call to the original class' clone constructor.:

bool $callAutoload Can be used to disable __autoload() during the generation of the test double class.:

bool $cloneArguments:

bool $callOriginalMethods:

Return value

PHPUnit_Framework_MockObject_MockObject

Throws

PHPUnit_Framework_Exception

136 calls to PHPUnit_Framework_TestCase::getMock()
Framework_MockObjectTest::testClonedMockObjectCanBeUsedInPlaceOfOriginalOne in vendor/phpunit/phpunit-mock-objects/tests/MockObjectTest.php
Framework_MockObjectTest::testClonedMockObjectIsNotIdenticalToOriginalOne in vendor/phpunit/phpunit-mock-objects/tests/MockObjectTest.php
Framework_MockObjectTest::testClonedMockObjectShouldStillEqualTheOriginal in vendor/phpunit/phpunit-mock-objects/tests/MockObjectTest.php
Framework_MockObjectTest::testFunctionCallback in vendor/phpunit/phpunit-mock-objects/tests/MockObjectTest.php
Framework_MockObjectTest::testGetMockForAbstractClass in vendor/phpunit/phpunit-mock-objects/tests/MockObjectTest.php

... See full list

File

vendor/phpunit/phpunit/src/Framework/TestCase.php, line 1288

Class

PHPUnit_Framework_TestCase
A TestCase defines the fixture to run multiple tests.

Code

public function getMock($originalClassName, $methods = array(), array $arguments = array(), $mockClassName = '', $callOriginalConstructor = true, $callOriginalClone = true, $callAutoload = true, $cloneArguments = false, $callOriginalMethods = false) {
  $mockObject = $this
    ->getMockObjectGenerator()
    ->getMock($originalClassName, $methods, $arguments, $mockClassName, $callOriginalConstructor, $callOriginalClone, $callAutoload, $cloneArguments, $callOriginalMethods);
  $this->mockObjects[] = $mockObject;
  return $mockObject;
}