This course will be retired on June 1, 2025.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
Fixtures allow you to setup all the code and data you'll need to run your test and share that set up across multiple tests.
Documentation for Fixtures
tests/FullRecipeTest.php
<?php
use the PHPUnit\Framework\TestCase;
class FullRecipeTest extends TestCase
{
protected $recipe;
protected function setUp(): void
{
$this->recipe = new Recipe("Belgian Waffles");
$this->recipe->addIngredient("Egg", 2);
$this->recipe->addIngredient("Butter", 1, "Cup");
$this->recipe->addIngredient("sugar", .5, "Cup");
$this->recipe->addIngredient("milk", 1.5, "cup");
$this->recipe->addIngredient("vanilla", 2, "tsp");
$this->recipe->addIngredient("flour", 2, "cup");
$this->recipe->addIngredient("baking powder", 1, "tbsp");
$this->recipe->addInstruction("Separate eggs. Whip egg whites until stiff peaks form. Set asside.");
$this->recipe->addInstruction("Melt butter, and combine with sugar. Add egg yokes and mix well.");
$this->recipe->addInstruction("Add milk and vanilla and mix well.");
$this->recipe->addInstruction("Add flour and sugar until just combined. ");
$this->recipe->addInstruction("Fold in egg whites.");
$this->recipe->addInstruction("Follow instructions on waffle maker or add .5 cup of batter to waffle iron and cook for 4 minutes.");
$this->recipe->setYield("10 waffles");
$this->recipe->setSource("Alena Holligan");
$this->recipe->addTag("breakfast, quick bread");
}
/** @test */
function hasTitle()
{
$this->assertEquals(
"Belgian Waffles",
$this->recipe->getTitle()
);
}
}
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up