You are here

public function OrderShipmentSummaryTest::testBuild in Commerce Shipping 8.2

Tests the order shipment summary build method.

File

tests/src/Kernel/OrderShipmentSummaryTest.php, line 155

Class

OrderShipmentSummaryTest
Tests the order shipment summary.

Namespace

Drupal\Tests\commerce_shipping\Kernel

Code

public function testBuild() {

  // User display rendered by default.
  $build = $this->orderShipmentSummary
    ->build($this->order);
  $this
    ->render($build);
  $this
    ->assertUniqueText('John');

  // Default view mode includes shipping profile and state (as transition form).
  $default_view_display = EntityViewDisplay::load('commerce_shipment.default.default');
  $this
    ->assertNotEmpty($default_view_display);

  // Change transition form to list_default formatter.
  $default_view_display
    ->setComponent('state', [
    'label' => 'hidden',
    'type' => 'list_default',
    'weight' => 7,
    'region' => 'content',
    'settings' => [],
    'third_party_settings' => [],
  ]);
  $default_view_display
    ->save();
  $this
    ->assertNotNull($default_view_display
    ->getComponent('state'));
  $build = $this->orderShipmentSummary
    ->build($this->order, 'default');
  $this
    ->render($build);
  $this
    ->assertUniqueText('John');
  $this
    ->assertText('ABC123');
  $this
    ->assertText('Draft');
}