You are here

public function OrderTest::testEntityHooks in Ubercart 8.4

Tests order entity CRUD hooks.

File

uc_order/tests/src/Functional/OrderTest.php, line 94

Class

OrderTest
Tests for Ubercart orders.

Namespace

Drupal\Tests\uc_order\Functional

Code

public function testEntityHooks() {
  \Drupal::service('module_installer')
    ->install([
    'entity_crud_hook_test',
  ]);
  $GLOBALS['entity_crud_hook_test'] = [];
  $order = Order::create();
  $order
    ->save();
  $this
    ->assertHookMessage('entity_crud_hook_test_entity_presave called for type uc_order');
  $this
    ->assertHookMessage('entity_crud_hook_test_entity_insert called for type uc_order');
  $GLOBALS['entity_crud_hook_test'] = [];
  $order = Order::load($order
    ->id());
  $this
    ->assertHookMessage('entity_crud_hook_test_entity_load called for type uc_order');
  $GLOBALS['entity_crud_hook_test'] = [];
  $order
    ->save();
  $this
    ->assertHookMessage('entity_crud_hook_test_entity_presave called for type uc_order');
  $this
    ->assertHookMessage('entity_crud_hook_test_entity_update called for type uc_order');
  $GLOBALS['entity_crud_hook_test'] = [];
  $order
    ->delete();
  $this
    ->assertHookMessage('entity_crud_hook_test_entity_delete called for type uc_order');
}