Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // test class
- class Snap_MockObject_Mockable_With_Static_Members {
- protected static function getTrue() {
- return true;
- }
- public static function getProtectedTrue() {
- return self::getTrue();
- }
- }
- // create a mock, with getTrue punched out to return false instead
- // then call getProtectedTrue on our mock
- // we should get false back
- class Snap_MockObject_Test_MockGenerationWithOverridingStaticMethods extends Snap_UnitTestCase {
- public function setUp() {
- $this->mocked_obj = $this->mock('Snap_MockObject_Mockable_With_Static_Members')
- ->requiresInheritance()
- ->setReturnValue('getTrue', false)
- ->construct();
- }
- public function tearDown() {
- unset($this->mocked_obj);
- }
- // we use call_user_func_array because we have no clue what the name of
- // $this->mocked_obj is, which would make static method testing
- // impossible.
- // this can be overhauled with Late Static Bindings some day
- public function testProtectedMethodCallsOverriddenCorrectly() {
- return $this->assertFalse(SNAP_callStatic($this->mocked_obj, 'getProtectedTrue'), array()));
- }
- }
Add Comment
Please, Sign In to add comment