Guest User

Untitled

a guest
Feb 20th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. abstract class AbstractClass
  2. {
  3. public function concreteMethod()
  4. {
  5. return $this->abstractMethod();
  6. }
  7.  
  8. public abstract function abstractMethod();
  9. }
  10.  
  11. class AbstractClassTest extends PHPUnit_Framework_TestCase
  12. {
  13. public function testConcreteMethod()
  14. {
  15. $stub = $this->getMockForAbstractClass('AbstractClass');
  16. $stub->expects($this->any())
  17. ->method('abstractMethod')
  18. ->will($this->returnValue(TRUE));
  19.  
  20. $this->assertTrue($stub->concreteMethod());
  21. }
  22. }
  23.  
  24. protected function setUp()
  25. {
  26. $stub = $this->getMockForAbstractClass('Some_Abstract_Class');
  27. $this->_object = $stub;
  28. }
  29.  
  30. sudo pear channel-update pear.phpunit.de
  31. sudo pear upgrade phpunit/PHPUnit
  32.  
  33. class AbstractClassTest extends PHPUnit_Framework_TestCase
  34. {
  35. /**
  36. * @var AbstractClass
  37. */
  38. private $testedClass;
  39.  
  40. public function setUp()
  41. {
  42. $this->testedClass = new class extends AbstractClass {
  43.  
  44. protected function abstractMethod()
  45. {
  46. // Put a barebones implementation here
  47. }
  48. };
  49. }
  50.  
  51. // Put your tests here
  52. }
Add Comment
Please, Sign In to add comment