public function USPSInternationalRateRequestTest::testGetRates in Commerce USPS 8
Tests getRates().
@covers ::getRates @covers ::buildRate @covers ::setMode @covers ::setShipment @covers ::resolveRates
File
- tests/
src/ Unit/ USPSInternationalRateRequestTest.php, line 44
Class
- USPSInternationalRateRequestTest
- Class USPSInternationalRateRequestTest.
Namespace
Drupal\Tests\commerce_usps\UnitCode
public function testGetRates() {
$config = $this
->getConfig();
$shipment = $this
->mockShipment([
'unit' => 'lb',
], [
'unit' => 'in',
], FALSE);
$shipping_method = $this
->prophesize(ShippingMethodInterface::class);
$shipping_method
->id()
->willReturn('123456789');
// Fetch rates from the USPS api.
$rates = $this->rateRequest
->getRates($shipment, $shipping_method
->reveal());
// Make sure the same number of rates requested
// is returned.
$this
->assertEquals(count($config['services']), count($rates));
/** @var \Drupal\commerce_shipping\ShippingRate $rate */
foreach ($rates as $rate) {
$this
->assertInstanceOf(ShippingRate::class, $rate);
$this
->assertNotEmpty($rate
->getAmount()
->getNumber());
}
}