Skip to content

Instantly share code, notes, and snippets.

@arodbits
Forked from loonies/1_phpunit-api.md
Created October 4, 2015 19:26
Show Gist options
  • Select an option

  • Save arodbits/c817de10919e7bf2ae93 to your computer and use it in GitHub Desktop.

Select an option

Save arodbits/c817de10919e7bf2ae93 to your computer and use it in GitHub Desktop.
PHPUnit Cheat Sheet

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)

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