What setMockClassName() can do for your PHPUnit mock object

Code
<?php

use PHPUnit\Framework\TestCase;

class 
MockClassNameTest extends TestCase
{
    public function 
testMockClassName() : void
    
{
        
$mock $this->getMockBuilder('FooAbstract')
            ->
setMockClassName('Foo')
            ->
getMock();
        
$mock->expects($this->once())
            ->
method('fooey')
            ->
willReturn(2);
        
        
$foo = new Foo();
        
        
$this->assertInstanceOf('FooAbstract'$mock);
        
$this->assertInstanceOf('Foo'$mock);
        
$this->assertSame(2$mock->fooey());
        
        
$this->assertInstanceOf('FooAbstract'$foo);
        
$this->assertInstanceOf('Foo'$foo);
        
$this->assertNull($foo->fooey());
    }
}

abstract class 
FooAbstract
{
    public function 
fooey()
    {
        return 
1;
    }
}
Result
Time: 00:00.007, 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