/**
  * @test
  */
 public function machine_name_is_title_converted_to_lower_case_and_hyphens()
 {
     $category = new Category();
     // 'foo' => 'foo'
     $category->setTitle('foo');
     $this->assertEquals('foo', $category->getMachineName());
     // 'FooBar' => 'foobar'
     $category->setTitle('FooBar');
     $this->assertEquals('foobar', $category->getMachineName());
     // 'Foo Bar Baz' => 'foo-bar-baz'
     $category->setTitle('Foo Bar Baz');
     $this->assertEquals('foo-bar-baz', $category->getMachineName());
 }
 /**
  * @param Category $category
  * @return $this
  */
 public function addChild(Category $category)
 {
     $key = $category->getMachineName();
     if ($this->children->containsKey($key)) {
         throw new \InvalidArgumentException('This Category already has a child Category of that name');
     }
     $this->children->set($key, $category);
     return $this;
 }