You are here

public function CasAttributesSubscriberTest::testRoleMappingComparisonMethodsOnRegistration in CAS Attributes 8

Same name and namespace in other branches
  1. 2.x tests/src/Unit/Subscriber/CasAttributesSubscriberTest.php \Drupal\Tests\cas_attributes\Unit\Subscriber\CasAttributesSubscriberTest::testRoleMappingComparisonMethodsOnRegistration()

Tests role mapping comparison methods work as expected on registration.

@dataProvider roleMappingComparisonMethodsDataProvider

File

tests/src/Unit/Subscriber/CasAttributesSubscriberTest.php, line 309

Class

CasAttributesSubscriberTest
CasAttributesSubscriber unit tests.

Namespace

Drupal\Tests\cas_attributes\Unit\Subscriber

Code

public function testRoleMappingComparisonMethodsOnRegistration($scenarioData) {
  $config_factory = $this
    ->getConfigFactoryStub([
    'cas_attributes.settings' => [
      'role.sync_frequency' => CasAttributesSettings::SYNC_FREQUENCY_EVERY_LOGIN,
      'role.mappings' => $scenarioData['mappings'],
    ],
  ]);
  $this->propertyBag
    ->method('getAttributes')
    ->willReturn($scenarioData['attributes_user_has']);
  $event = new CasPreRegisterEvent($this->propertyBag);
  $event
    ->setPropertyValue('roles', $scenarioData['roles_before']);
  $subscriber = new CasAttributesSubscriber($config_factory, $this->tokenService, $this->requestStack);
  $subscriber
    ->onPreRegister($event);
  $this
    ->assertEquals($scenarioData['roles_after'], $event
    ->getPropertyValues()['roles']);
}