Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PHPUnit: Mock abstract class
use PHPUnit\Framework\TestCase;

abstract class Greeting
{
    public function hello($name)
    {
        return 'Hello '.$name;
    }
}

class GreetingTest extends TestCase
{
    public function testSayHello()
    {
        $greeting = $this->getMockForAbstractClass(Greeting::class);

        $this->assertEquals('Hello Lucas', $greeting->hello('Lucas'));
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.