public function test_assigning_categories()
 {
     list($seller, $product) = $this->visitProductCategories();
     // assign from scratch
     $categories = Category::allLeaves()->get()->random(2);
     foreach ($categories as $category) {
         $this->checkMulti($this->getCategoryInputId($category));
     }
     $this->press('提交')->seeSuccessMessage();
     foreach ($categories as $category) {
         $this->seeIsChecked($this->getCategoryInputId($category));
     }
     // change categories
     $newCategories = Category::allLeaves()->whereNotIn('id', $categories->pluck('id')->toArray())->get()->random(2);
     foreach ($categories as $category) {
         $this->uncheckMulti($this->getCategoryInputId($category));
     }
     foreach ($newCategories as $category) {
         $this->checkMulti($this->getCategoryInputId($category));
     }
     $this->press('提交')->seeSuccessMessage();
     foreach ($newCategories as $category) {
         $this->seeIsChecked($this->getCategoryInputId($category));
     }
     // remove all categories
     foreach ($newCategories as $category) {
         $this->uncheckMulti($this->getCategoryInputId($category));
     }
     $this->press('提交')->seeSuccessMessage();
     foreach ($newCategories as $category) {
         $this->dontSeeIsChecked($this->getCategoryInputId($category));
     }
 }