View source
<?php
namespace Drupal\Tests\commerce_shipping\Unit\Plugin\Commerce\PackageType;
use Drupal\commerce_shipping\Plugin\Commerce\PackageType\PackageType;
use Drupal\physical\Length;
use Drupal\physical\Weight;
use Drupal\Tests\UnitTestCase;
class PackageTypeTest extends UnitTestCase {
protected $packageType;
protected function setUp() : void {
parent::setUp();
$plugin_definition = [
'id' => 'test id',
'remote_id' => 'test remote id',
'label' => 'test label',
'dimensions' => [
'length' => '1',
'width' => '2',
'height' => '3',
'unit' => 'mm',
],
'weight' => [
'number' => '4',
'unit' => 'kg',
],
];
$this->packageType = new PackageType([], 'test', $plugin_definition);
}
public function testGetId() {
$this
->assertEquals('test id', $this->packageType
->getId());
}
public function testGetRemoteId() {
$this
->assertEquals('test remote id', $this->packageType
->getRemoteId());
}
public function testGetLabel() {
$this
->assertEquals('test label', $this->packageType
->getLabel());
}
public function testGetDimensions() {
$this
->assertEquals(new Length('1', 'mm'), $this->packageType
->getLength());
$this
->assertEquals(new Length('2', 'mm'), $this->packageType
->getWidth());
$this
->assertEquals(new Length('3', 'mm'), $this->packageType
->getHeight());
}
public function testGetWeight() {
$this
->assertEquals(new Weight('4', 'kg'), $this->packageType
->getWeight());
}
}