I am trying to write tests for a Laravel application and I can't seem to figure out how to test static methods that call other static methods from the same class. Say I have this class:
class Foo
{
   public static function foo()
    {
        return !self::bar();
    }
    public static function bar()
    {
        $trueOrFalse = [true, false];
        $key = array_rand($trueOrFalse);
        return $trueOrFalse[$key];
    }
}
I want to test that Foo::foo() returns the opposite of Foo::bar(). So what I would like to do is have a mock that would return a precise value in place of Foo::bar().
I can do that if I write this in my test file
class FooClassTest extends TestCase
{
public function testFooMethod()
    {
       $mock = Mockery::mock('alias:' . Foo::class);
       $mock->shouldReceive('bar')->once()->andReturn(true);
       //assertion
But then, when I write my assertion: $this->assertEquals(false, Foo::foo()); , I get the error "Method Foo::foo() does not exist on this mock object".
That makes sense, since class Foo has been replaced with $mock throughout the app because of the "alias:" flag. Using "overload:" leads to the same error message. And partial mocking doesn't work either.
Is there any way to test such class methods using mocking? Or an alternative to mocking?