Skip to content

Instantly share code, notes, and snippets.

@flyingluscas
Created March 14, 2017 02:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flyingluscas/d55c37d5ff59751e73c9a88f14f619c6 to your computer and use it in GitHub Desktop.
Save flyingluscas/d55c37d5ff59751e73c9a88f14f619c6 to your computer and use it in GitHub Desktop.
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