PHP code example of awesomite / mock-finals

1. Go to this page and download the library: Download awesomite/mock-finals library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

awesomite / mock-finals example snippets


class Greeter
{
    final public function sayHello(): string
    {
        return 'hello';
    }
}

class MyTest extends \PHPUnit\Framework\TestCase
{
    public function testSayHello(): void
    {
        $mock = $this->getMockBuilder(Greeter::class)->getMock();
        $mock
            ->expects($this->once())
            ->method('sayHello')
            ->willReturn('goodbye')
        ;
        $this->assertSame('goodbye', $mock->sayHello());
    }
}