Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class ClassWithProtectedMethod
- {
- public function foo()
- {
- return $this->bar();
- }
- protected function bar()
- {
- return 'bar';
- }
- }
- class ProtectedStubTest extends PHPUnit_Framework_TestCase
- {
- public function testProtectedStub()
- {
- $stub = $this->getMock('ClassWithProtectedMethod', array('bar'));
- $stub->expects($this->any())
- ->method('bar')
- ->will($this->returnValue('stub'));
- $this->assertEquals('stub', $stub->foo());
- }
- }
- ?>
- sb@vmware ~ % phpunit ProtectedStubTest
- PHPUnit 3.5.2 by Sebastian Bergmann.
- .
- Time: 0 seconds, Memory: 7.00Mb
- OK (1 test, 2 assertions)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement