/** * @expectedException \Exception */ public function test_add_rollback() { /** === Test Data === */ $datePerformed = '2015-11-23 12:23:34'; $operTypeCode = 'code'; $trans = []; /** === Setup Mocks === */ // $def = $this->_manTrans->begin(); $mDef = $this->_mockTransactionDefinition(); $this->mManTrans->shouldReceive('begin')->once()->andReturn($mDef); // $operationTypeId = $this->_repoTypeOper->getIdByCode($operationTypeCode); $this->mRepoTypeOper->shouldReceive('getIdByCode')->once()->andThrow(\Exception::class); // $this->_manTrans->end($def); $this->mManTrans->shouldReceive('end')->once(); /** === Call and asserts === */ $req = new Request\Add(); $req->setDatePerformed($datePerformed); $req->setOperationTypeCode($operTypeCode); $req->setTransactions($trans); $resp = $this->obj->add($req); $this->assertFalse($resp->isSucceed()); }