You are here

public function OrderIntegrationTest::testPlaceValidateFulfillLogs in Commerce Core 8.2

Tests that a log is generated for place, validate, and fulfill transitions.

File

modules/log/tests/src/Kernel/OrderIntegrationTest.php, line 130

Class

OrderIntegrationTest
Tests integration with order events.

Namespace

Drupal\Tests\commerce_log\Kernel

Code

public function testPlaceValidateFulfillLogs() {

  // Draft -> Placed.
  $this->order
    ->getState()
    ->applyTransitionById('place');
  $this->order
    ->save();
  $logs = $this->logStorage
    ->loadMultipleByEntity($this->order);
  $this
    ->assertEquals(1, count($logs));
  $log = reset($logs);
  $build = $this->logViewBuilder
    ->view($log);
  $this
    ->render($build);
  $this
    ->assertText('Order moved from Draft to Validation by the Place order transition.');

  // Placed -> Validated.
  $this->order
    ->getState()
    ->applyTransitionById('validate');
  $this->order
    ->save();
  $logs = $this->logStorage
    ->loadMultipleByEntity($this->order);
  $this
    ->assertEquals(2, count($logs));
  $log = $logs[2];
  $build = $this->logViewBuilder
    ->view($log);
  $this
    ->render($build);
  $this
    ->assertText('Order moved from Validation to Fulfillment by the Validate order transition.');

  // Validated -> Fulfilled.
  $this->order
    ->getState()
    ->applyTransitionById('fulfill');
  $this->order
    ->save();
  $logs = $this->logStorage
    ->loadMultipleByEntity($this->order);
  $this
    ->assertEquals(3, count($logs));
  $log = $logs[3];
  $build = $this->logViewBuilder
    ->view($log);
  $this
    ->render($build);
  $this
    ->assertText('Order moved from Fulfillment to Completed by the Fulfill order transition.');
}