Handling fluid interfaces with a Mockery mock objects

Code
<?php

use Symfony\Component\Finder\Finder;
use 
PHPUnit\Framework\TestCase;

/**
 * The class to test
 */
class Foo
{
    public function 
configureFinder(Finder $finder)
    {
        return 
$finder->files()
            ->
useBestAdapter()
            ->
sortByName();
    }
}

class 
FluidTest extends TestCase
{
    public function 
testConfigureFinder() : void
    
{
        
// mock of Finder and its fluid method usage
        
$finder Mockery::mock(Finder::CLASS);
        
$finder->shouldReceive('files->useBestAdapter->sortByName')
            ->
andReturn($finder);
        
        
$foo = new Foo();
        
$actual $foo->configureFinder($finder);
        
        
// do your assertions for your test
        
$this->assertInstanceOf(Finder::CLASS, $actual);
    }
    
    protected function 
tearDown() : void
    
{
        
Mockery::close();
    }
}
Result
Time: 00:00.011, Memory: 4.00 MB

OK (1 test, 0 assertions)
Used Versions
PHP 8.2, Laminas MVC 3.2, Symfony 5.2, Laravel 8.28, PHPUnit 9.5, Doctrine ORM 2.8