public function test_add_commit() { /** === Test Data === */ $datePerformed = '2015-11-23 12:23:34'; $operTypeId = 2; $trans = [[Transaction::ATTR_DEBIT_ACC_ID => '12', Transaction::ATTR_CREDIT_ACC_ID => '23', Transaction::ATTR_VALUE => 12.32]]; $operId = 42; /** === Setup Mocks === */ // $def = $this->_manTrans->begin(); $mDef = $this->_mockTransactionDefinition(); $this->mManTrans->shouldReceive('begin')->once()->andReturn($mDef); // $idCreated = $this->_repoOper->create($bindToAdd); $this->mRepoOper->shouldReceive('create')->once()->andReturn($operId); // $transIds = $this->_subAdd->transactions($idCreated, $transactions, $datePerformed, $asRef); $this->mSubAdd->shouldReceive('transactions')->once()->andReturn([]); // $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->setDatePerformed($datePerformed); $req->setOperationTypeId($operTypeId); $req->setTransactions($trans); $resp = $this->obj->add($req); $this->assertTrue($resp->isSucceed()); $this->assertEquals($operId, $resp->getOperationId()); }