Skip to content

Instantly share code, notes, and snippets.

@siabuba121
Created September 19, 2021 20:22
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 siabuba121/b8bb7b53c6439e423798bd576ffec17a to your computer and use it in GitHub Desktop.
Save siabuba121/b8bb7b53c6439e423798bd576ffec17a to your computer and use it in GitHub Desktop.
<?php
declare(strict_types=1);
namespace App\Tests;
use App\Kitchen\Cook;
use App\Kitchen\Cooker;
use App\Kitchen\Dishes\Pizza;
use DG\BypassFinals;
use PHPUnit\Framework\TestCase;
class CookTest extends TestCase
{
protected function setUp(): void
{
BypassFinals::enable();
}
public function testCook(): void
{
//Given
$cooker = $this->createMock(Cooker::class);
$pizza = $this->createMock(Pizza::class);
$cook = new Cook($cooker);
//Then
$cooker
->expects(self::once())
->method('bakePepperoniPizza')
->willReturn($pizza);
//When
$resultPizza = $cook->preparePepperoniPizza();
//Then
self::assertSame($pizza, $resultPizza);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment