Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once('PHPUnit/Framework.php');
- abstract class MyClass
- {
- public function foo()
- {
- return $this->bar();
- }
- protected function bar()
- {
- return 'bar';
- }
- abstract public function test();
- }
- class MockTest extends PHPUnit_Framework_TestCase
- {
- public function testMock()
- {
- $stub = $this->getMockForAbstractClass('MyClass');
- $stub->expects($this->any())
- ->method('bar')
- ->will($this->returnValue('stub'));
- $this->assertEquals('stub', $stub->foo());
- // Returns 'bar'
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement