public function test_add_rootNode_commit() { /** === Test Data === */ $CUSTOMER_ID = 21; $PARENT_ID = $CUSTOMER_ID; $REF_ID = '123123123'; $DATE = '2015-12-05 12:34:56'; $ID_INSERTED_LOG = 2048; $COUNTRY_CODE = 'LV'; /** === Setup Mocks === */ // $def = $this->_manTrans->begin(); $mDef = $this->_mockTransactionDefinition(); $this->mManTrans->shouldReceive('begin')->once()->andReturn($mDef); // $parentId = $this->_subReferral->getReferredParentId($customerId, $parentId); $this->mSubReferral->shouldReceive('getReferredParentId')->once()->andReturn($PARENT_ID); // $toAdd[Customer::ATTR_COUNTRY_CODE] = $this->_subReferral->getDefaultCountryCode(); $this->mSubReferral->shouldReceive('getDefaultCountryCode')->once()->andReturn($COUNTRY_CODE); // $this->_repoCustomer->create($toAdd); $this->mRepoCustomer->shouldReceive('create')->once(); // $idLog = $this->_repoChange->create($toLog); $this->mRepoChange->shouldReceive('create')->once()->andReturn($ID_INSERTED_LOG); // $this->_manTrans->commit($def); $this->mManTrans->shouldReceive('commit')->once(); // $this->_manTrans->end($def); $this->mManTrans->shouldReceive('end')->once(); /** === Call and asserts === */ $req = new Request\Add(); $req->setCustomerId($CUSTOMER_ID); $req->setParentId($PARENT_ID); $req->setReference($REF_ID); $req->setDate($DATE); $resp = $this->obj->add($req); $this->assertTrue($resp->isSucceed()); }