You are here

public function OrderEventsTransactionsTest::testWorkflowCancelEventNotModifyStockWithDefaultSettings in Commerce Stock 8

Tests that transactions are not created on cancel events with default configuration.

File

modules/local_storage/tests/src/Kernel/OrderEventsTransactionsTest.php, line 316

Class

OrderEventsTransactionsTest
Ensure the stock transactions are performed on order events.

Namespace

Drupal\Tests\commerce_stock_local\Kernel

Code

public function testWorkflowCancelEventNotModifyStockWithDefaultSettings() {
  $this
    ->assertEquals(10, $this->checker
    ->getTotalStockLevel($this->variation, $this->locations));
  $transition = $this->order
    ->getState()
    ->getTransitions();
  $this->order
    ->setOrderNumber('2017/01');
  $this->order
    ->getState()
    ->applyTransition($transition['place']);
  $this->order
    ->save();
  $this
    ->assertEquals(9, $this->checker
    ->getTotalStockLevel($this->variation, $this->locations));
  $this->order
    ->getState()
    ->applyTransition($transition['cancel']);
  $this->order
    ->save();
  $query = \Drupal::database()
    ->select('commerce_stock_transaction', 'txn')
    ->fields('txn')
    ->condition('entity_id', $this->variation
    ->id())
    ->condition('transaction_type_id', StockTransactionsInterface::STOCK_RETURN);
  $result = $query
    ->execute()
    ->fetchAll();
  $this
    ->assertCount(0, $result);
  $this
    ->assertEquals(9, $this->checker
    ->getTotalStockLevel($this->variation, $this->locations));
}