Added examples, improved recipe implementation

This commit is contained in:
2019-07-09 17:59:45 +02:00
parent 922d9f09dd
commit 04f357fc0a
3 changed files with 88 additions and 7 deletions

View File

@ -25,4 +25,33 @@ class RecipeTest extends \PhpUnit\Framework\TestCase
$this->assertEquals([$ingredient1, $ingredient2], $recipe->getIngredients());
}
public function testManipulatingRecipeTags()
{
$recipe = new Recipe();
$recipe
->addTag("foo")
->addTag("bar");
$this->assertCount(2, $recipe->getTags());
$this->assertTrue($recipe->hasTag("foo"));
$this->assertTrue($recipe->hasTag("bar"));
$recipe->removeTag("foo");
$this->assertCount(1, $recipe->getTags());
$this->assertTrue($recipe->hasTag("bar"));
$recipe->addTag("baz");
$this->assertCount(2, $recipe->getTags());
$this->assertFalse($recipe->hasTag("foo"));
$this->assertTrue($recipe->hasTag("bar"));
$this->assertTrue($recipe->hasTag("baz"));
$recipe->setTags(["baz"]);
$this->assertCount(1, $recipe->getTags());
$this->assertFalse($recipe->hasTag("foo"));
$this->assertFalse($recipe->hasTag("bar"));
$this->assertTrue($recipe->hasTag("baz"));
}
}