mardi 2 juin 2015

PHPUnit mock parent protected method, which is owerriden

How could I test method Bar::foo?

class Foo {
    protected function foo() {
        // Do something
    }
}

class Bar extends Foo {
    protected function foo() {
        parent::foo();
        // Do something else
    }
}

I need to mock Foo::foo and not to have

Fatal error: Access level to Bar::foo() must be public (as in class Foo)...

??

Aucun commentaire:

Enregistrer un commentaire