public function test_get_paramIsInt()
 {
     /** === Test Data === */
     $PARAM = 43;
     $DATA = 'data';
     $RESULT = 'result';
     /** === Setup Mocks === */
     // $cover = $this->_rest->request($params, self::ROUTE);
     $mCover = $this->_mock(ICover::class);
     $this->mRest->shouldReceive('request')->once()->with([Inventory::ODOO_IDS => [$PARAM]], Inventory::ROUTE)->andReturn($mCover);
     $mCover->shouldReceive('getResultData')->once()->andReturn($DATA);
     // $result = $this->_mageSrvInProc->convertValue($data, IBundle::class);
     $this->mMageSrvInProc->shouldReceive('convertValue')->once()->with($DATA, \Praxigento\Odoo\Data\Odoo\Inventory::class)->andReturn($RESULT);
     /** === Call and asserts  === */
     $res = $this->obj->get($PARAM);
     $this->assertEquals($RESULT, $res);
 }
Ejemplo n.º 2
0
 public function productsFromOdoo(Request\ProductsFromOdoo $req)
 {
     $result = new Response\ProductsFromOdoo();
     /* replicate all data in one transaction */
     $def = $this->_manTrans->begin();
     try {
         $ids = $req->getOdooIds();
         /** @var  $inventory Inventory */
         $inventory = $this->_repoOdooInventory->get($ids);
         $this->_doProductReplication($inventory);
         $this->_manTrans->commit($def);
         $result->markSucceed();
     } catch (\Exception $e) {
         $msg = 'Product replication from Odoo is failed. Error: ' . $e->getMessage();
         $this->_logger->emergency($msg);
         $traceStr = $e->getTraceAsString();
         $this->_logger->emergency($traceStr);
         throw $e;
     } finally {
         // transaction will be rolled back if commit is not done (otherwise - do nothing)
         $this->_manTrans->end($def);
     }
     return $result;
 }