<?php
use PHPUnit\Framework\TestCase;
/**
* final class that should be a mock in a test
*/
final class Foo
{
public function bar()
{
return 5;
}
}
class FinalTest extends TestCase
{
/**
* final class Foo is mocked
*/
public function testFinalClassMock() : void
{
$foo = new Foo();
$mock = Mockery::mock($foo);
$mock->shouldReceive('bar')
->andReturn(1);
$this->assertEquals(1, $mock->bar());
}
/**
* asserts that mock is NOT an instance of Foo
*/
public function testFinalMockExtend() : void
{
$foo = new Foo();
$mock = Mockery::mock($foo);
// Mock doesn't extend Foo
$this->assertNotInstanceOf(Foo::CLASS, $mock);
}
protected function tearDown() : void
{
Mockery::close();
}
}