I have a trait:
trait A {
function foo() {
...
}
}
and a class that uses the trait like this:
class B {
use A {
foo as traitFoo;
}
function foo() {
$intermediate = $this->traitFoo();
...
}
}
I want to test the class' foo()
method and want to mock (with Mockery) the behavior of the trait's foo()
method. I tried using a partial and mocking traitFoo()
like:
$mock = Mockery::mock(new B());
$mock->shouldReceive('traitFoo')->andReturn($intermediate);
But it doesn't work.
Is it possible to do this? Is there an alternative way? I want to test B::foo()
isolating it from the trait's foo()
implementation.
Thanks in advance.