public function test_afterGetRateRequest() { /** === Test Data === */ $STORE_ID = 2; $STOCK_ID = 4; $COUNTRY_CODE = 'LV'; $RESULT = $this->_mock(\Magento\Framework\DataObject::class); /** === Setup Mocks === */ // $storeId = $result->getStore(); $RESULT->shouldReceive('getStore')->once()->andReturn($STORE_ID); // $stockId = $this->_manStock->getStockIdByStoreId($storeId); $this->mManStock->shouldReceive('getStockIdByStoreId')->once()->andReturn($STOCK_ID); // $wrhs = $this->_repoWrhs->getById($stockId); $mWrhs = $this->_mock(\Praxigento\Warehouse\Data\Entity\Warehouse::class); $this->mRepoWrhs->shouldReceive('getById')->once()->andReturn($mWrhs); // $countryCode = $wrhs->getCountryCode(); $mWrhs->shouldReceive('getCountryCode')->once()->andReturn($COUNTRY_CODE); // $result->setCountryId($countryCode); $RESULT->shouldReceive('setCountryId')->once()->with($COUNTRY_CODE); /** === Call and asserts === */ $res = $this->obj->afterGetRateRequest($this->mSubject, $RESULT); $this->assertEquals($RESULT, $res); }