Skip to content

Instantly share code, notes, and snippets.

@iggim
Forked from loonies/1_phpunit-api.md
Last active August 29, 2015 14:06
Show Gist options
  • Select an option

  • Save iggim/2a2e478ccd9c0c41d68b to your computer and use it in GitHub Desktop.

Select an option

Save iggim/2a2e478ccd9c0c41d68b to your computer and use it in GitHub Desktop.

PHPUnit_Framework_TestCase


any()

Returns a matcher that matches when the method it is evaluated for is executed zero or more times.

  • return: PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount

PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount any()

never()

Returns a matcher that matches when the method it is evaluated for is never executed.

  • return: PHPUnit_Framework_MockObject_Matcher_InvokedCount

PHPUnit_Framework_MockObject_Matcher_InvokedCount never()

atLeastOnce()

Returns a matcher that matches when the method it is evaluated for is executed at least once.

  • return: PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce

PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce atLeastOnce()

once()

Returns a matcher that matches when the method it is evaluated for is executed exactly once.

  • return: PHPUnit_Framework_MockObject_Matcher_InvokedCount

PHPUnit_Framework_MockObject_Matcher_InvokedCount once()

exactly()

Returns a matcher that matches when the method it is evaluated for is executed exactly once.

  • param: int
  • return: PHPUnit_Framework_MockObject_Matcher_InvokedCount

PHPUnit_Framework_MockObject_Matcher_InvokedCount exactly(int $count)

at()

Returns a matcher that matches when the method it is evaluated for is invoked at the given $index.

  • param: int
  • return: PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex

PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex at(int $index)


getMockBuilder()

Returns a builder object to create mock objects using a fluent interface.

  • param: string
  • return: PHPUnit_Framework_MockObject_MockBuilder

PHPUnit_Framework_MockObject_MockBuilder getMockBuilder(string $className)

PHPUnit_Framework_MockObject_MockBuilder

setMethods()

Specify the methods that are to be replaced with a configurable test double. The behavior of the other methods is not changed.

  • param: array
  • return: PHPUnit_Framework_MockObject_MockBuilder

PHPUnit_Framework_MockObject_MockBuilder setMethods(array $methods)

setConstructorArgs()

Specifies the arguments for the constructor.

  • param: array
  • return: PHPUnit_Framework_MockObject_MockBuilder

PHPUnit_Framework_MockObject_MockBuilder setConstructorArgs(array $args)

setMockClassName()

Specifies the name for the mock class.

  • param: string
  • return: PHPUnit_Framework_MockObject_MockBuilder

PHPUnit_Framework_MockObject_MockBuilder setMockClassName(string $name)

disableOriginalConstructor()

Suppresses the invocation of the original constructor.

  • return: PHPUnit_Framework_MockObject_MockBuilder

PHPUnit_Framework_MockObject_MockBuilder disableOriginalConstructor()

disableOriginalClone()

Suppresses the invocation of the original clone constructor.

  • return: PHPUnit_Framework_MockObject_MockBuilder

PHPUnit_Framework_MockObject_MockBuilder disableOriginalClone()

disableAutoload()

Suppresses the use of class autoloading while creating the mock object.

  • return: PHPUnit_Framework_MockObject_MockBuilder

PHPUnit_Framework_MockObject_MockBuilder disableAutoload()

getMock()

Creates a mock object using a fluent interface.

  • return: PHPUnit_Framework_MockObject_MockObject

PHPUnit_Framework_MockObject_MockObject getMock()

getMockForAbstractClass()

Creates a mock object for an abstract class using a fluent interface.

  • return: PHPUnit_Framework_MockObject_MockObject

PHPUnit_Framework_MockObject_MockObject getMockForAbstractClass()

PHPUnit_Framework_MockObject_MockObject

expects()

PHPUnit_Framework_MockObject_Matcher_Invocation

...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment