tour_test.module

Provides tests for tour module

File

drupal/core/modules/tour/tests/tour_test/tour_test.module
View source
<?php

/**
 * @file
 * Provides tests for tour module
 */
use Drupal\Core\Entity\EntityInterface;

/**
 * Implements hook_menu().
 */
function tour_test_menu() {
  $items['tour-test-1'] = array(
    'route_name' => 'tour_test_1',
    'title' => 'Tour test 1',
  );
  $items['tour-test-2/subpath'] = array(
    'route_name' => 'tour_test_2',
    'title' => 'Tour test 2',
  );
  return $items;
}

/**
 * Implements hook_ENTITY_TYPE_load() for tour.
 */
function tour_test_tour_load($entities) {
  if (isset($entities['tour-entity-create-test-en'])) {
    $entities['tour-entity-create-test-en']->loaded = 'Load hooks work';
  }
}

/**
 * Implements hook_ENTITY_TYPE_presave() for tour.
 */
function tour_test_tour_presave($entity) {
  if ($entity
    ->id() == 'tour-entity-create-test-en') {
    $entity
      ->set('label', $entity
      ->label() . ' alter');
  }
}

/**
 * Implements hook_tour_tips_alter().
 */
function tour_test_tour_tips_alter(array &$tour_tips, EntityInterface $entity) {
  foreach ($tour_tips as $tour_tip) {
    if ($tour_tip
      ->get('id') == 'tour-code-test-1') {
      $tour_tip
        ->set('body', 'Altered by hook_tour_tips_alter');
    }
  }
}

Functions

Namesort descending Description
tour_test_menu Implements hook_menu().
tour_test_tour_load Implements hook_ENTITY_TYPE_load() for tour.
tour_test_tour_presave Implements hook_ENTITY_TYPE_presave() for tour.
tour_test_tour_tips_alter Implements hook_tour_tips_alter().