public function test_changeParent() { $obm = \Magento\Framework\App\ObjectManager::getInstance(); /** @var $call \Praxigento\Downline\Service\ICustomer */ $call = $obm->get(\Praxigento\Downline\Service\ICustomer::class); $request = new Request\ChangeParent(); $request->setCustomerId(6); $request->setNewParentId(1); $response = $call->changeParent($request); $this->assertTrue($response->isSucceed()); }
public function test_changeParent_rootNode() { /** === Test Data === */ $DATE = '2015-12-05 12:34:56'; $CUSTOMER_ID = 21; $PARENT_ID_CUR = 43; $PATH_CUR = '/1/2/3/43/'; $DEPTH_CUR = 4; $PARENT_ID_NEW = $CUSTOMER_ID; $PATH_NEW = '/1/2/55/'; $DEPTH_NEW = 3; $DO_CUST = new Customer(); $DO_CUST->setParentId($PARENT_ID_CUR); $DO_CUST->setPath($PATH_CUR); $DO_CUST->setDepth($DEPTH_CUR); $DO_PARENT = new Customer(); $DO_PARENT->setPath($PATH_NEW); $DO_PARENT->setDepth($DEPTH_NEW); /** === Setup Mocks === */ // $def = $this->_manTrans->begin(); $mDef = $this->_mockTransactionDefinition(); $this->mManTrans->shouldReceive('begin')->once()->andReturn($mDef); // $data = $this->_repoCustomer->getById($customerId); $this->mRepoCustomer->shouldReceive('getById')->once()->andReturn($DO_CUST); // $updateRows = $this->_repoCustomer->updateById($customerId, $bind); $this->mRepoCustomer->shouldReceive('updateById')->once()->andReturn(1); // $rowsUpdated = $this->_repoCustomer->updateChildrenPath($pathKey, $pathReplace, $deltaDepth); $this->mRepoCustomer->shouldReceive('updateChildrenPath')->once()->andReturn(2); // $insertedId = $this->_repoChange->create($bind); $this->mRepoChange->shouldReceive('create')->once()->andReturn(433); // $this->_manTrans->commit($def); $this->mManTrans->shouldReceive('commit')->once(); // $this->_manTrans->end($def); $this->mManTrans->shouldReceive('end')->once(); /** === Call and asserts === */ $req = new Request\ChangeParent(); $req->setCustomerId($CUSTOMER_ID); $req->setNewParentId($PARENT_ID_NEW); $req->setDate($DATE); $resp = $this->obj->changeParent($req); $this->assertTrue($resp->isSucceed()); }