Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vitorjustin's avatar

vitorjustin wrote a reply+100 XP

5mos ago

This worked for me, tks!!

vitorjustin's avatar

vitorjustin liked a comment+100 XP

5mos ago

I came across this problem recently and i have found the solution in mockery DOC not calling the Original constructor you can use this code if you like

public function PartialMockWithRunningConstructor(string $abstract, array|string $trackedMethods)
    {
        if (is_string($trackedMethods))
            $trackedMethods = Arr::wrap($trackedMethods);

        $mock = Mockery::mock($abstract . '[' .  implode(',', $trackedMethods) . ']');
        $this->instance($abstract, $mock);
        return $mock;
    }