Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
PHPUnit: Mocking Interface
use PHPUnit\Framework\TestCase;

interface Greeting
    public function hello($name);

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

        $greeting->method('hello')->will($this->returnValue('Hello Lucas'));

        $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.