/** * @test * @expectedException \InvalidArgumentException */ public function throws_an_exception_when_adding_a_child_whose_name_already_exists_in_its_children() { $category = new Category(); $child = (new Category())->setTitle('foo'); $duplicate = (new Category())->setTitle('foo'); $category->addChild($child); $category->addChild($duplicate); }