Commit 7a099e82 authored by alexpott's avatar alexpott
Browse files

Issue #2531258 by neclimdul: Improve...

Issue #2531258 by neclimdul: Improve \Drupal\Tests\user\Unit\PermissionHandlerTest::testBuildPermissionsSortPerModule
parent 1bb4e43d
...@@ -168,35 +168,41 @@ public function testBuildPermissionsSortPerModule() { ...@@ -168,35 +168,41 @@ public function testBuildPermissionsSortPerModule() {
->method('getModuleDirectories') ->method('getModuleDirectories')
->willReturn([ ->willReturn([
'module_a' => vfsStream::url('modules/module_a'), 'module_a' => vfsStream::url('modules/module_a'),
'module_b' => vfsStream::url('modules/module_b'),
'module_c' => vfsStream::url('modules/module_c'),
]); ]);
$this->moduleHandler->expects($this->exactly(3))
->method('getName')
->will($this->returnValueMap([
['module_a', 'Module a'],
['module_b', 'Module b'],
['module_c', 'A Module'],
]));
$url = vfsStream::url('modules'); $url = vfsStream::url('modules');
mkdir($url . '/module_a'); mkdir($url . '/module_a');
file_put_contents($url . '/module_a/module_a.permissions.yml', file_put_contents($url . '/module_a/module_a.permissions.yml',
"access_module_a2: single_description "access_module_a2: single_description2
access_module_a1: single_description" access_module_a1: single_description1"
);
mkdir($url . '/module_b');
file_put_contents($url . '/module_b/module_b.permissions.yml',
"access_module_a3: single_description"
);
mkdir($url . '/module_c');
file_put_contents($url . '/module_c/module_c.permissions.yml',
"access_module_a4: single_description"
); );
$modules = ['module_a'];
$extensions = [
'module_a' => $this->mockModuleExtension('module_a', 'Module a'),
];
$this->moduleHandler->expects($this->any())
->method('getImplementations')
->with('permission')
->willReturn([]);
$this->moduleHandler->expects($this->any()) $modules = ['module_a', 'module_b', 'module_c'];
$this->moduleHandler->expects($this->once())
->method('getModuleList') ->method('getModuleList')
->willReturn(array_flip($modules)); ->willReturn(array_flip($modules));
$this->permissionHandler = new TestPermissionHandler($this->moduleHandler, $this->stringTranslation, $this->controllerResolver); $permissionHandler = new TestPermissionHandler($this->moduleHandler, $this->stringTranslation, $this->controllerResolver);
$actual_permissions = $permissionHandler->getPermissions();
// Setup system_rebuild_module_data(). $this->assertEquals(['access_module_a4', 'access_module_a1', 'access_module_a2', 'access_module_a3'],
$this->permissionHandler->setSystemRebuildModuleData($extensions); array_keys($actual_permissions));
$actual_permissions = $this->permissionHandler->getPermissions();
$this->assertEquals(['access_module_a1', 'access_module_a2'], array_keys($actual_permissions));
} }
/** /**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment