コード例 #1
0
 private function _createOperation()
 {
     $req = new OperationAddRequest();
     $req->setOperationTypeId($this->typeOperId);
     $req->setDatePerformed(self::DATA_DATE_PERFORMED);
     $req->setTransactions([[Transaction::ATTR_DEBIT_ACC_ID => $this->acc1[Account::ATTR_ID], Transaction::ATTR_CREDIT_ACC_ID => $this->acc2[Account::ATTR_ID], Transaction::ATTR_VALUE => 5], [Transaction::ATTR_DEBIT_ACC_ID => $this->acc1[Account::ATTR_ID], Transaction::ATTR_CREDIT_ACC_ID => $this->acc2[Account::ATTR_ID], Transaction::ATTR_VALUE => 10], [Transaction::ATTR_DEBIT_ACC_ID => $this->acc1[Account::ATTR_ID], Transaction::ATTR_CREDIT_ACC_ID => $this->acc2[Account::ATTR_ID], Transaction::ATTR_VALUE => 15]]);
     $this->_amount = 5 + 10 + 15;
     /** @var  $resp OperationAddResponse */
     $resp = $this->_callOperation->add($req);
     $this->assertTrue($resp->isSucceed());
     $this->_logger->debug("New operation with 3 transactions is created.");
 }
コード例 #2
0
 /**
  * @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());
 }