Mockery exception: could not load mock class already exists

Mockery\Exception\RuntimeException: Could not load mock , class already exists When working with those spaghetti legacy code base, sometimes, it is fucking hard to write the test along with refactoring. We may face with some situation that need to mock the public static function call. class Foo { public function bar() { Utils::staticFunction(); // do another thing } } And the test class: use \Mockery as m; use Foo; class FooTest { public function testBar() { $out = new Foo(); $utils = m::mock('alias:Utils'); $util->shouldReceive('staticFunction')->withAnyArgs(); $out->bar(); // do another mock and test } } We use mockery to mock the static function call, run the test with single function, it’s green....

July 5, 2017 · 1 min · longka