-
-
Save siabuba121/b8bb7b53c6439e423798bd576ffec17a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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