Jan 19, 2024
1
Level 41
Since I mocked a class my other test are not passing anymore
Hi,
Since I used Mockery::mock('overload:......'); my tests coming after those are not passing anymore.
I'm using PestPHP and I've tried to add this but it's not working.
afterEach(function() {
Mockery::close();
});
Here is a test in the BalanceTest where I mock a class
<?php
use App\Models\Lease;
use Carbon\Carbon;
use Facades\App\Classes\Balance\Balance;
use App\Models\Block;
it('calculates the balance for a block', function () {
$blockBalance = Mockery::mock('overload:App\Classes\Balance\BlockBalance');
$blockBalance->shouldReceive('fromBeginning')->once()->andReturn((object) [
'invoices' => 100,
'receipts' => 50,
'balance' => -50
]);
$balance = Balance::for(Block::factory()->create())->fromBeginning();
expect($balance->invoices)->toEqual(100)
->and($balance->receipts)->toEqual(50)
->and($balance->balance)->toEqual(-50);
});
How could I revert the overload thing ?
Here is when I test the folder

Here is when I'm testing the BlockBalanceTest alone (without BlanceTest where the mocking is)

Please or to participate in this conversation.