Skip to content
Snippets Groups Projects
Commit 1b9f328e authored by Stephen Mustgrave's avatar Stephen Mustgrave
Browse files

Resolve #2040845 "Write tour integration"

parent 3f301c75
No related branches found
No related tags found
1 merge request!7Resolve #2040845 "Write tour integration"
Pipeline #161863 passed
langcode: en
status: true
dependencies:
module:
- user
id: people
label: People
module: user
routes:
- route_name: entity.user.collection
tips:
people-main:
id: people-main
plugin: text
label: 'Managing users'
body: 'View and edit user accounts.'
weight: 1
people-add:
id: people-add
plugin: text
label: 'Add a user'
body: 'Create a new user account.'
weight: 2
selector: '.button--primary'
people-filter:
id: people-filter
plugin: text
label: 'Search for users'
body: 'Find users by applying filters.'
weight: 3
selector: '#views-exposed-form-user-admin-people-page-1'
people-operations:
id: people-operations
plugin: text
label: 'Update accounts'
body: 'Apply changes after selecting one or more accounts via the checkboxes.'
weight: 4
selector: '#edit-submit--2'
people-edit:
id: people-edit
plugin: text
label: 'Edit user account'
body: 'Make changes to one user account.'
weight: 5
position: left
selector: '.dropbutton-widget'
<?php
namespace Drupal\Tests\user\Functional;
use Drupal\Tests\tour\Functional\TourTestBase;
use Drupal\user\UserInterface;
/**
* Tests tour functionality.
*
* @group user
*/
class UserAdminTourTest extends TourTestBase {
/**
* An admin user with administrative permissions for views.
*
* @var \Drupal\user\UserInterface
*/
protected UserInterface $adminUser;
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = ['block', 'tour', 'user', 'views'];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
$this->adminUser = $this->drupalCreateUser([
'administer users',
'access tour',
]);
$this->drupalLogin($this->adminUser);
$this->drupalPlaceBlock('local_actions_block');
}
/**
* Tests user tour tip availability.
*/
public function testAdminPeopleTour(): void {
$this->drupalGet('admin/people');
$this->assertTourTips();
}
}
<?php
/**
* @file
* Install, update and uninstall functions for the tour module.
*/
use Drupal\Component\Serialization\Yaml;
use Drupal\tour\Entity\Tour;
/**
* Import people tour configuration.
*/
function tour_update_10300(): void {
/** @var \Drupal\Core\Config\ConfigManagerInterface $config_manager */
$config_manager = \Drupal::service('config.manager');
try {
// First check that this config doesn't already exist.
$people = Tour::load('people');
if ($people) {
return;
}
$file = \Drupal::service('extension.list.module')->getPath('tour') . '/config/optional/tour.tour.people.yml';
$raw = file_get_contents($file);
$value = Yaml::decode($raw);
if (!is_array($value)) {
throw new \RuntimeException('Invalid YAML file %s', $file);
}
$type = $config_manager->getEntityTypeIdByName(basename($file));
$entity_manager = $config_manager->getEntityTypeManager();
$definition = $entity_manager->getDefinition($type);
$id_key = $definition->getKey('id');
$id = $value[$id_key];
/** @var \Drupal\Core\Config\Entity\ConfigEntityStorage $entity_storage */
$entity_storage = $entity_manager->getStorage($type);
$entity = $entity_storage->load($id);
if (!$entity) {
$entity = $entity_storage->createFromStorageRecord($value);
$entity->save();
}
}
catch (Exception) {
throw new \RuntimeException('Error running tour_update_10300');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment