Skip to content

Instantly share code, notes, and snippets.

@johnkary
Created October 19, 2010 16:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnkary/634490 to your computer and use it in GitHub Desktop.
Save johnkary/634490 to your computer and use it in GitHub Desktop.
Using PHPUnit 3.5 MockBuilder to create a mock concrete object of an abstract class
<?php
//Create mock BaseCredential called 'MockAdminCredential' whose 'calculate'
//function will always return true. All other methods will return NULL
//as per the default behavior of a stub.
$this->mockAdminCredential = $this->getMockBuilder('BaseCredential')
->setMockClassName('MockAdminCredential')
->setMethods(array('calculate'))
->getMock()
->expects($this->any())
->method('calculate')
->will($this->returnValue(true));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment