<?php
use PHPUnit\Framework\TestCase;
class Foo
{
public static function one() : int
{
return 1;
}
}
class Static3Test extends TestCase
{
public function testOne() : void
{
$foo = new Foo();
// PHP allows to call static methods like this
$this->assertSame(1, $foo->one());
}
public function testOneMock() : void
{
$foo = $this->createMock('Foo');
$foo->expects($this->once())
->method('one')
->will($this->returnValue(1));
// the same as before with a mock
// phpunit's way to say "your code suck"
$this->assertSame(1, $foo->one());
}
}