# Class goog.testing.MockControl

code »

Controls a set of mocks. Controlled mocks are replayed, verified, and cleaned-up at the same time.

## Constructor

goog.testing.MockControl ( )
Show:Public Protected Private

## Instance Methods

code »$replayAll ( )

Calls replay on each controlled mock.

code »$resetAll ( )

Calls reset on each controlled mock.

code »$tearDown ( )

Calls tearDown on each controlled mock, if necesssary.

code »$verifyAll ( )

Calls verify on each controlled mock.

code »addMock ( mock ) ⇒ `goog.testing.MockInterface`

Takes control of this mock.

Parameters

mock: `goog.testing.MockInterface`
  Mock to be controlled.

Returns

The same mock passed in, for convenience.

code »createConstructorMock ( scope, constructorName, opt_strictness ) ⇒ `!goog.testing.MockInterface`

Creates a controlled MethodMock for a constructor. Passes its arguments through to the MethodMock constructor. See `goog.testing.createConstructorMock` for details.

Parameters

scope: `Object`
  The scope of the constructor to be mocked out.
constructorName: `string`
  The name of the function we're going to mock.
opt_strictness: `number=`
  One of goog.testing.Mock.LOOSE or goog.testing.Mock.STRICT. The default is STRICT.

Returns

The mocked method.

code »createFunctionMock ( opt_functionName, opt_strictness ) ⇒ `goog.testing.MockInterface`

Creates a controlled FunctionMock. Passes its arguments through to the FunctionMock constructor.

Parameters

opt_functionName: `string=`
  The optional name of the function to mock set to '[anonymous mocked function]' if not passed in.
opt_strictness: `number=`
  One of goog.testing.Mock.LOOSE or goog.testing.Mock.STRICT. The default is STRICT.

Returns

The mocked function.

code »createGlobalFunctionMock ( functionName, opt_strictness ) ⇒ `goog.testing.MockInterface`

Creates a controlled GlobalFunctionMock. Passes its arguments through to the GlobalFunctionMock constructor.

Parameters

functionName: `string`
  The name of the function we're going to mock.
opt_strictness: `number=`
  One of goog.testing.Mock.LOOSE or goog.testing.Mock.STRICT. The default is STRICT.

Returns

The mocked function.

code »createLooseMock ( objectToMock, opt_ignoreUnexpectedCalls, opt_mockStaticMethods, opt_createProxy ) ⇒ `!goog.testing.LooseMock`

Creates a controlled LooseMock. Passes its arguments through to the LooseMock constructor.

Parameters

objectToMock: `(Object|Function)`
  The object that should be mocked, or the constructor of an object to mock.
opt_ignoreUnexpectedCalls: `boolean=`
  Whether to ignore unexpected calls.
opt_mockStaticMethods: `boolean=`
  An optional argument denoting that a mock should be constructed from the static functions of a class.
opt_createProxy: `boolean=`
  An optional argument denoting that a proxy for the target mock should be created.

Returns

The mock object.

code »createMethodMock ( scope, functionName, opt_strictness ) ⇒ `!goog.testing.MockInterface`

Creates a controlled MethodMock. Passes its arguments through to the MethodMock constructor.

Parameters

scope: `Object`
  The scope of the method to be mocked out.
functionName: `string`
  The name of the function we're going to mock.
opt_strictness: `number=`
  One of goog.testing.Mock.LOOSE or goog.testing.Mock.STRICT. The default is STRICT.

Returns

The mocked method.

code »createStrictMock ( objectToMock, opt_mockStaticMethods, opt_createProxy ) ⇒ `!goog.testing.StrictMock`

Creates a controlled StrictMock. Passes its arguments through to the StrictMock constructor.

Parameters

objectToMock: `(Object|Function)`
  The object that should be mocked, or the constructor of an object to mock.
opt_mockStaticMethods: `boolean=`
  An optional argument denoting that a mock should be constructed from the static functions of a class.
opt_createProxy: `boolean=`
  An optional argument denoting that a proxy for the target mock should be created.

Returns

The mock object.

## Instance Properties

code »mocks_ : `Array.<goog.testing.MockInterface>`

The list of mocks being controlled.