Exemplo n.º 1
0
 /**
  * @SuppressWarnings(PHPMD.ShortVariable)
  */
 public function test_save()
 {
     /** === Test Data === */
     $operId = 21;
     $datePaid = 'paid';
     $prodId = 32;
     $stockId = 4;
     $itemId = 64;
     $pv = 12.44;
     $qty = 4;
     $item = $this->_mock(\Praxigento\Pv\Service\Sale\Data\Item::class);
     $items = [$item];
     /** === Setup Mocks === */
     // $def = $this->_manTrans->begin();
     $mDef = $this->_mockTransactionDefinition();
     $this->mManTrans->shouldReceive('begin')->once()->andReturn($mDef);
     //
     // FIRST ITERATION
     //
     // $prodId = $item->getProductId();
     $item->shouldReceive('getProductId')->once()->andReturn($prodId);
     // $stockId = $item->getStockId();
     $item->shouldReceive('getStockId')->once()->andReturn($stockId);
     // $itemId = $item->getItemId();
     $item->shouldReceive('getItemId')->once()->andReturn($itemId);
     // $pv = $this->_repoStockItem->getPvByProductAndStock($prodId, $stockId);
     $this->mRepoStockItem->shouldReceive('getPvByProductAndStock')->once()->with($prodId, $stockId)->andReturn($pv);
     // $qty = $item->getQuantity();
     $item->shouldReceive('getQuantity')->once()->andReturn($qty);
     // $this->_repoSaleItem->replace($eItem);
     $this->mRepoSaleItem->shouldReceive('replace')->once();
     //
     // $this->_repoSale->replace($orderData);
     $this->mRepoSale->shouldReceive('replace')->once();
     // $this->_manTrans->commit($def);
     $this->mManTrans->shouldReceive('commit')->once();
     // $this->_manTrans->end($def);
     $this->mManTrans->shouldReceive('end')->once();
     /** === Call and asserts  === */
     $req = new Request\Save();
     $req->setSaleOrderId($operId);
     $req->setSaleOrderDatePaid($datePaid);
     $req->setOrderItems($items);
     $resp = $this->obj->save($req);
     $this->assertTrue($resp->isSucceed());
 }
Exemplo n.º 2
0
 public function test_main()
 {
     $this->_logger->debug('Story01 in PV Integration tests is started.');
     $this->_callSale->cacheReset();
     $this->_conn->beginTransaction();
     try {
         $this->_createMageCustomer();
         $this->_createMageProducts();
         $this->_createWarehousePv();
         $this->_createMageSaleOrder();
         $this->_savePv();
         $this->_accountPv();
         $this->_checkOperation();
     } finally {
         //         $this->_conn->commit();
         $this->_conn->rollBack();
     }
     $this->_logger->debug('Story01 in PV Integration tests is completed, all transactions are rolled back.');
 }