PHPUnit: Unit Testing with a Bite!
Mocking: Test Doubles
  Start your All-Access Pass to unlock this challenge
Buy Access Login

Challenge 1 / 1

Suppose we have the following class:

class DinosaurHatcher
{
    public function __construct(private LoggerInterface $logger)
    {
    }

    public function getProgressTowardsHatching(): int
    {
        // ...
    }

    public function warmEgg(): void
    {
        // ...
    }
}

In a test for a different class, we decide to mock this:

$hatcher = $this->createMock(DinosaurHatcher::class);

What will happen if we call $hatcher->getProgressTowardsHatching() or $hatcher->warmEgg()?

Skip challenges and go to theNext Chapter

Turn Challenges Off?

All further challenges will be skipped automatically.
You can re-enable challenges at any time on this page or from your account page.