/** * @group category */ public function testDetachFromCurrentToAnotherParent() { $anotherParentId = $this->handler->add('NewParentCategory', null, [], true, true); $childId = $this->handler->add('ChildCategory', null, [], true, true); $this->handler->add('CurrentCategory')->attachChild([$childId]); $entity = Veer\Models\Category::find($this->handler->getId()); $this->assertTrue(in_array('ChildCategory', $entity->subcategories->lists('title', 'id')->toArray())); $this->handler->updateChildParent($childId, $anotherParentId); $entity = Veer\Models\Category::find($this->handler->getId()); $this->assertFalse(in_array('ChildCategory', $entity->subcategories->lists('title', 'id')->toArray())); $entity = Veer\Models\Category::find($anotherParentId); $this->assertTrue(in_array('ChildCategory', $entity->subcategories->lists('title', 'id')->toArray())); }