Skip to content

Instantly share code, notes, and snippets.

@trashSydowDev
Forked from loonies/1_phpunit-api.md
Last active November 23, 2015 21:36
Show Gist options
  • Select an option

  • Save trashSydowDev/37ebc7de78e9b2ce8a3f to your computer and use it in GitHub Desktop.

Select an option

Save trashSydowDev/37ebc7de78e9b2ce8a3f 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