Exemplo n.º 1
0
 public function testAddingCategories()
 {
     $categories = \App\Models\Product\Category::leavesOnly()->inRandomOrder()->take(2)->get();
     $this->visitCategoriesPage();
     foreach ($this->product->categories as $category) {
         $this->uncheckMulti('category-' . $category->id);
     }
     foreach ($categories as $category) {
         $this->checkMulti('category-' . $category->id);
     }
     $this->press('提交')->see('修改成功');
     foreach ($categories as $category) {
         $this->seeIsChecked('category-' . $category->id);
         $this->seeInDatabase('category_product', ['product_id' => $this->product->id, 'category_id' => $category->id]);
     }
 }