diff --git a/shipping/uc_quote/src/Tests/QuoteTest.php b/shipping/uc_quote/src/Tests/QuoteTest.php
index 1306549..8e003ef 100644
--- a/shipping/uc_quote/src/Tests/QuoteTest.php
+++ b/shipping/uc_quote/src/Tests/QuoteTest.php
@@ -201,10 +201,13 @@ class QuoteTest extends UbercartTestBase {
 
     // Submit the review order page.
     $this->drupalPostForm(NULL, [], t('Submit order'));
-    $order_id = db_query("SELECT order_id FROM {uc_orders} WHERE delivery_first_name = :name", [':name' => $edit['panes[delivery][first_name]']])->fetchField();
+    $order_ids = \Drupal::entityQuery('uc_order')
+      ->condition('delivery_first_name', $edit['panes[delivery][first_name]'])
+      ->execute();
+    $order_id = reset($order_ids);
 
     if ($order_id) {
-      $order = uc_order_load($order_id);
+      $order = \Drupal\uc_order\Entity\Order::load($order_id);
       foreach ($order->line_items as $line) {
         if ($line['type'] == 'shipping') {
           break;
diff --git a/uc_cart/src/Tests/CartCheckoutTest.php b/uc_cart/src/Tests/CartCheckoutTest.php
index 1bb021c..6231132 100644
--- a/uc_cart/src/Tests/CartCheckoutTest.php
+++ b/uc_cart/src/Tests/CartCheckoutTest.php
@@ -450,7 +450,10 @@ class CartCheckoutTest extends UbercartTestBase {
     $oldname = $edit['panes[delivery][first_name]'];
     $this->drupalPostForm('cart/checkout', $edit, t('Review order'));
 
-    $order_id = db_query("SELECT order_id FROM {uc_orders} WHERE delivery_first_name = :name", [':name' => $oldname])->fetchField();
+    $order_ids = \Drupal::entityQuery('uc_order')
+      ->condition('delivery_first_name', $oldname)
+      ->execute();
+    $order_id = reset($order_ids);
     if ($order_id) {
       // Go to a different page, then back to order - make sure order_id is the same.
       $this->drupalGet('<front>');
@@ -458,10 +461,14 @@ class CartCheckoutTest extends UbercartTestBase {
       $this->drupalPostForm('cart', [], 'Checkout');
       $this->assertRaw($oldname, 'Customer name was unchanged.');
       $this->drupalPostForm('cart/checkout', $edit, t('Review order'));
-      $new_order_id = db_query("SELECT order_id FROM {uc_orders} WHERE delivery_first_name = :name", [':name' => $edit['panes[delivery][first_name]']])->fetchField();
+      $new_order_ids = \Drupal::entityQuery('uc_order')
+        ->condition('delivery_first_name', $edit['panes[delivery][first_name]'])
+        ->execute();
+      $new_order_id = reset($new_order_ids);
       $this->assertEqual($order_id, $new_order_id, 'Original order_id was reused.');
 
       // Jump 10 minutes into the future.
+      // @todo: Can we set modified through the Entity API rather than DBTNG?
       db_update('uc_orders')
         ->fields(array(
             'modified' => time() - Cart::ORDER_TIMEOUT - 1,
@@ -476,11 +483,16 @@ class CartCheckoutTest extends UbercartTestBase {
       $newname = $this->randomMachineName(10);
       $edit['panes[delivery][first_name]'] = $newname;
       $this->drupalPostForm('cart/checkout', $edit, t('Review order'));
-      $new_order_id = db_query("SELECT order_id FROM {uc_orders} WHERE delivery_first_name = :name", [':name' => $newname])->fetchField();
+
+      $new_order_ids = \Drupal::entityQuery('uc_order')
+        ->condition('delivery_first_name', $newname)
+        ->execute();
+      $new_order_id = reset($new_order_ids);
       $this->assertNotEqual($order_id, $new_order_id, 'New order was created after timeout.');
 
+      // Force the order to load from the DB instead of the entity cache.
+      $old_order = \Drupal::entityManager()->getStorage('uc_order')->loadUnchanged($order_id);
       // Verify that the status of old order is abandoned.
-      $old_order = uc_order_load($order_id, TRUE);
       $this->assertEqual($old_order->getStatusId(), 'abandoned', 'Original order was marked abandoned.');
     }
     else {
diff --git a/uc_order/src/Tests/OrderTest.php b/uc_order/src/Tests/OrderTest.php
index a3d1b47..4fc3632 100644
--- a/uc_order/src/Tests/OrderTest.php
+++ b/uc_order/src/Tests/OrderTest.php
@@ -82,7 +82,7 @@ class OrderTest extends UbercartTestBase {
     $this->assertHookMessage('entity_crud_hook_test_entity_insert called for type uc_order');
 
     $GLOBALS['entity_crud_hook_test'] = [];
-    $order = uc_order_load($order->id());
+    $order = \Drupal\uc_order\Entity\Order::load($order->id());
 
     $this->assertHookMessage('entity_crud_hook_test_entity_load called for type uc_order');
 
@@ -112,7 +112,10 @@ class OrderTest extends UbercartTestBase {
     $this->assertText(t('Order created by the administration.'), 'Order created by the administration.');
     $this->assertFieldByName('uid_text', $this->customer->id(), 'The customer UID appears on the page.');
 
-    $order_id = db_query("SELECT order_id FROM {uc_orders} WHERE uid = :uid", [':uid' => $this->customer->id()])->fetchField();
+    $order_ids = \Drupal::entityQuery('uc_order')
+      ->condition('uid', $this->customer->id())
+      ->execute();
+    $order_id = reset($order_ids);
     $this->assertTrue($order_id, t('Found order ID @order_id', ['@order_id' => $order_id]));
 
     $this->drupalGet('admin/store/orders/view');
@@ -220,8 +223,10 @@ class OrderTest extends UbercartTestBase {
     $order = uc_order_new($customer->id());
     uc_order_comment_save($order->id(), 0, t('Order created programmatically.'), 'admin');
 
-    $order_exists = db_query("SELECT 1 FROM {uc_orders} WHERE order_id = :order_id", [':order_id' => $order->id()])->fetchField();
-    $this->assertTrue($order_exists, t('Found order ID @order_id', ['@order_id' => $order->id()]));
+    $order_ids = \Drupal::entityQuery('uc_order')
+      ->condition('order_id', $order->id())
+      ->execute();
+    $this->assertTrue(in_array($order->id(), $order_ids), t('Found order ID @order_id', ['@order_id' => $order->id()]));
 
     $country_manager = \Drupal::service('country_manager');
     $country = array_rand($country_manager->getEnabledList());
@@ -251,24 +256,13 @@ class OrderTest extends UbercartTestBase {
       ->setAddress('billing', $billing_address)
       ->save();
 
-    $db_order = db_query("SELECT * FROM {uc_orders} WHERE order_id = :order_id", [':order_id' => $order->id()])->fetchObject();
-    $this->assertEqual($delivery_address->first_name, $db_order->delivery_first_name);
-    $this->assertEqual($delivery_address->last_name, $db_order->delivery_last_name);
-    $this->assertEqual($delivery_address->street1, $db_order->delivery_street1);
-    $this->assertEqual($delivery_address->street2, $db_order->delivery_street2);
-    $this->assertEqual($delivery_address->city, $db_order->delivery_city);
-    $this->assertEqual($delivery_address->zone, $db_order->delivery_zone);
-    $this->assertEqual($delivery_address->postal_code, $db_order->delivery_postal_code);
-    $this->assertEqual($delivery_address->country, $db_order->delivery_country);
-
-    $this->assertEqual($billing_address->first_name, $db_order->billing_first_name);
-    $this->assertEqual($billing_address->last_name, $db_order->billing_last_name);
-    $this->assertEqual($billing_address->street1, $db_order->billing_street1);
-    $this->assertEqual($billing_address->street2, $db_order->billing_street2);
-    $this->assertEqual($billing_address->city, $db_order->billing_city);
-    $this->assertEqual($billing_address->zone, $db_order->billing_zone);
-    $this->assertEqual($billing_address->postal_code, $db_order->billing_postal_code);
-    $this->assertEqual($billing_address->country, $db_order->billing_country);
+    // Force the order to load from the DB instead of the entity cache.
+    $db_order = \Drupal::entityManager()->getStorage('uc_order')->loadUnchanged($order->id());
+    // Compare delivery and billing addresses to those loaded from the database.
+    $db_delivery_address = $db_order->getAddress('delivery');
+    $db_billing_address = $db_order->getAddress('billing');
+    $this->assertEqual($delivery_address, $db_delivery_address, 'Delivery address is equal to delivery address in database.');
+    $this->assertEqual($billing_address, $db_billing_address, 'Billing address is equal to billing address in database.');
 
     return $order;
   }
diff --git a/uc_store/src/Tests/UbercartTestBase.php b/uc_store/src/Tests/UbercartTestBase.php
index 6358b0d..a7a8114 100644
--- a/uc_store/src/Tests/UbercartTestBase.php
+++ b/uc_store/src/Tests/UbercartTestBase.php
@@ -253,12 +253,15 @@ abstract class UbercartTestBase extends WebTestBase {
     // Complete the review page.
     $this->drupalPostForm(NULL, [], t('Submit order'));
 
-    $order_id = db_query("SELECT order_id FROM {uc_orders} WHERE billing_first_name = :name", [':name' => $edit['panes[billing][first_name]']])->fetchField();
+    $order_ids = \Drupal::entityQuery('uc_order')
+      ->condition('billing_first_name', $edit['panes[billing][first_name]'])
+      ->execute();
+    $order_id = reset($order_ids);
     if ($order_id) {
       $this->pass(
         t('Order %order_id has been created', ['%order_id' => $order_id])
       );
-      $order = uc_order_load($order_id);
+      $order = \Drupal\uc_order\Entity\Order::load($order_id);
     }
     else {
       $this->fail(t('No order was created.'));
diff --git a/uc_tax/src/Tests/InclusiveTaxTest.php b/uc_tax/src/Tests/InclusiveTaxTest.php
index b539df2..1db2677 100644
--- a/uc_tax/src/Tests/InclusiveTaxTest.php
+++ b/uc_tax/src/Tests/InclusiveTaxTest.php
@@ -112,7 +112,10 @@ class InclusiveTaxTest extends UbercartTestBase {
     $this->assertText('$16.80' . $rate->inclusion_text, 'Tax inclusive price appears in cart pane on checkout review page');
 
     // Ensure the tax-inclusive price is listed on the order admin page.
-    $order_id = db_query("SELECT order_id FROM {uc_orders} WHERE delivery_first_name = :name", [':name' => $edit['panes[delivery][first_name]']])->fetchField();
+    $order_ids = \Drupal::entityQuery('uc_order')
+      ->condition('delivery_first_name', $edit['panes[delivery][first_name]'])
+      ->execute();
+    $order_id = reset($order_ids);
     $this->assertTrue($order_id, 'Order was created successfully');
     $this->drupalGet('admin/store/orders/' . $order_id);
     $this->assertText('$16.80' . $rate->inclusion_text, 'Tax inclusive price appears on the order view page.');
diff --git a/uc_tax/src/Tests/StoredTaxTest.php b/uc_tax/src/Tests/StoredTaxTest.php
index 2364c53..e6cfbf5 100644
--- a/uc_tax/src/Tests/StoredTaxTest.php
+++ b/uc_tax/src/Tests/StoredTaxTest.php
@@ -84,7 +84,10 @@ class StoredTaxTest extends UbercartTestBase {
     // Complete the review page.
     $this->drupalPostForm(NULL, array(), t('Submit order'));
 
-    $order_id = db_query("SELECT order_id FROM {uc_orders} WHERE delivery_first_name = :name", [':name' => $edit['panes[delivery][first_name]']])->fetchField();
+    $order_ids = \Drupal::entityQuery('uc_order')
+      ->condition('delivery_first_name', $edit['panes[delivery][first_name]'])
+      ->execute();
+    $order_id = reset($order_ids);
     if ($order_id) {
       $this->pass(
         t('Order %order_id has been created', ['%order_id' => $order_id])
