You are here

protected function StockTransactionQueryTrait::getLastTransaction in Commerce Stock 8

Return the last transaction in the table.

Return value

obj The transaction.

File

modules/local_storage/tests/src/Kernel/StockTransactionQueryTrait.php, line 37

Class

StockTransactionQueryTrait
Provides methods to query the transaction database.

Namespace

Drupal\Tests\commerce_stock_local\Kernel

Code

protected function getLastTransaction() {
  $connection = \Drupal::database();
  $query = $connection
    ->select('commerce_stock_transaction', 'txn')
    ->fields('txn')
    ->orderBy('id', 'DESC')
    ->range(0, 1);
  return $query
    ->execute()
    ->fetchObject();
}