Skip to content

Commit

Permalink
Test fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish committed Sep 19, 2023
1 parent 2a0eb6c commit a349365
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
15 changes: 7 additions & 8 deletions src/EventSubscriber/EventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Drupal\default_content\Event\DefaultContentEvents;
use Drupal\default_content\Event\ImportEvent;
use Drupal\file\FileInterface;
use Drupal\user\UserInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
Expand Down Expand Up @@ -76,6 +75,7 @@ public function onEntityInsert(EntityInsertEvent $event) {
self::updateSamlauthRoles();
}
}

/**
* On entity delete event.
*
Expand All @@ -96,14 +96,13 @@ protected static function updateSamlauthRoles() {
return;
}

$roles = user_role_names(TRUE);
unset($roles[UserInterface::AUTHENTICATED_ROLE]);
$role_ids = array_keys(user_role_names(TRUE));
$role_ids = array_combine($role_ids, $role_ids);
unset($role_ids[RoleInterface::AUTHENTICATED_ID]);
asort($role_ids);

$config = \Drupal::configFactory()->getEditable('samlauth.authentication');
ksort($roles);
foreach ($roles as $role_id => &$label) {
$label = $role_id;
}
$config->set('map_users_roles', $roles)->save();
$config->set('map_users_roles', $role_ids)->save();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion stanford_profile.post_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,5 @@ function stanford_profile_post_update_samlauth() {
$ignored = $ignore_settings->get('ignored_config_entities');
$ignored[] = 'samlauth.authentication:map_users_roles';
$ignore_settings->set('ignored_config_entities', $ignored)->save();
\Drupal::service('module_installer')->install(['stnaford_samlauth']);
\Drupal::service('module_installer')->install(['stanford_samlauth']);
}
5 changes: 1 addition & 4 deletions tests/src/Kernel/EventSubscriber/EventSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ protected function setUp(): void {
* Test the consumer secret is randomized.
*/
public function testConsumerSecretRandomized() {
$expected = [
'default_content.import' => 'onContentImport',
];
$this->assertEquals($expected, StanfordEventSubscriber::getSubscribedEvents());
$this->assertContains('onContentImport', StanfordEventSubscriber::getSubscribedEvents());
$consumer = Consumer::create([
'client_id' => 'foobar',
'label' => 'foobar',
Expand Down

0 comments on commit a349365

Please sign in to comment.