/** * @expectedException \Exception */ public function test_add_commonNode_withCountry_exception() { /** === Test Data === */ $CUSTOMER_ID = 21; $PARENT_ID = 12; $REF_ID = '123123123'; $DATE = '2015-12-05 12:34:56'; $PATH = '/1/2/3/43/'; $DEPTH = 4; $DO_CUST = new Customer(); $DO_CUST->setPath($PATH); $DO_CUST->setDepth($DEPTH); $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); // $data = $this->_repoCustomer->getById($parentId); $this->mRepoCustomer->shouldReceive('getById')->once()->andReturn($DO_CUST); // $idLog = $this->_repoChange->create($toLog); $this->mRepoChange->shouldReceive('create')->andThrow(new \Exception()); // $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->setCountryCode($COUNTRY_CODE); $req->setDate($DATE); $this->obj->add($req); }