You are here

public function USPSRateRequestTest::testGetPackages in Commerce USPS 8

Test package setup.

@covers ::getPackages

File

tests/src/Unit/USPSRateRequestTest.php, line 158

Class

USPSRateRequestTest
Class USPSRateRequestTest.

Namespace

Drupal\Tests\commerce_usps\Unit

Code

public function testGetPackages() {
  $this->rateRequest
    ->setShipment($this
    ->mockShipment());
  $packages = $this->rateRequest
    ->getPackages();

  // TODO: Support multiple packages.

  /** @var \USPS\RatePackage $package */
  $package = reset($packages);
  $info = $package
    ->getPackageInfo();
  $this
    ->assertEquals(28806, $info['ZipOrigination']);
  $this
    ->assertEquals(80465, $info['ZipDestination']);
  $this
    ->assertEquals('ALL', $info['Service']);
  $this
    ->assertEquals(10, $info['Pounds']);
  $this
    ->assertEquals(0, $info['Ounces']);
  $this
    ->assertEquals('VARIABLE', $info['Container']);
  $this
    ->assertEquals('REGULAR', $info['Size']);
  $this
    ->assertEquals(3, $info['Width']);
  $this
    ->assertEquals(10, $info['Length']);
  $this
    ->assertEquals(10, $info['Height']);
  $this
    ->assertEquals(0, $info['Girth']);
  $this
    ->assertEquals(TRUE, $info['Machinable']);
  $this
    ->assertEquals(date('Y-m-d'), $info['ShipDate']);
}