/** * Returns array to be used in multiselect on back-end * * @return array */ public function toOptionArray() { $configData = $this->_shippingFedex->getCode($this->_code); $arr = []; foreach ($configData as $code => $title) { $arr[] = ['value' => $code, 'label' => $title]; } return $arr; }
public function testCollectRatesErrorMessage() { $this->scope->expects($this->once())->method('isSetFlag')->willReturn(false); $this->error->expects($this->once())->method('setCarrier')->with('fedex'); $this->error->expects($this->once())->method('setCarrierTitle'); $this->error->expects($this->once())->method('setErrorMessage'); $request = new RateRequest(); $request->setPackageWeight(1); $this->assertSame($this->error, $this->_model->collectRates($request)); }
/** * @dataProvider collectRatesDataProvider */ public function testCollectRatesRateAmountOriginBased($amount, $rateType, $expected) { // @codingStandardsIgnoreStart $netAmount = new \Magento\Framework\Object([]); $netAmount->Amount = $amount; $totalNetCharge = new \Magento\Framework\Object([]); $totalNetCharge->TotalNetCharge = $netAmount; $totalNetCharge->RateType = $rateType; $ratedShipmentDetail = new \Magento\Framework\Object([]); $ratedShipmentDetail->ShipmentRateDetail = $totalNetCharge; $rate = new \Magento\Framework\Object([]); $rate->ServiceType = 'ServiceType'; $rate->RatedShipmentDetails = [$ratedShipmentDetail]; $response = new \Magento\Framework\Object([]); $response->HighestSeverity = 'SUCCESS'; $response->RateReplyDetails = $rate; $this->_model->expects($this->any())->method('_getCachedQuotes')->will($this->returnValue(serialize($response))); $request = $this->getMock('Magento\\Quote\\Model\\Quote\\Address\\RateRequest', [], [], '', false); foreach ($this->_model->collectRates($request)->getAllRates() as $allRates) { $this->assertEquals($expected, $allRates->getData('cost')); } // @codingStandardsIgnoreEnd }
/** * @dataProvider getCodeUnitOfMeasureDataProvider * @param string $code */ public function testGetCodeUnitOfMeasure($code) { $result = $this->_model->getCode('unit_of_measure', $code); $this->assertNotEmpty($result); }