public function USPSRateRequestTest::testGetRates in Commerce USPS 8
Tests getRates().
@covers ::getRates @covers ::buildRate @covers ::setMode @covers ::setShipment @covers ::resolveRates
File
- tests/
src/ Unit/ USPSRateRequestTest.php, line 44
Class
- USPSRateRequestTest
- Class USPSRateRequestTest.
Namespace
Drupal\Tests\commerce_usps\UnitCode
public function testGetRates() {
$config = $this
->getConfig();
$shipment = $this
->mockShipment();
$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());
}
}