Skip to content

Commit 789b511

Browse files
committed
ACP2E-3208: [Cloud] Users with a specific role cannot login
1 parent c2a210a commit 789b511

File tree

1 file changed

+55
-0
lines changed
  • dev/tests/integration/testsuite/Magento/Paypal/etc

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/**
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Paypal\etc;
9+
10+
use Magento\Framework\Acl\AclResource\ProviderInterface;
11+
use Magento\TestFramework\Helper\Bootstrap;
12+
use PHPUnit\Framework\TestCase;
13+
14+
class AclTest extends TestCase
15+
{
16+
/**
17+
* Check to ensure that paypal is child of payment acl
18+
*
19+
* @return void
20+
*/
21+
public function testAclInheritance()
22+
{
23+
$aclResourceProvider = Bootstrap::getObjectManager()->get(ProviderInterface::class);
24+
$resources = $aclResourceProvider->getAclResources();
25+
$admin = $this->getChildren($resources, 'Magento_Backend::admin');
26+
$stores = $this->getChildren($admin['children'], 'Magento_Backend::stores');
27+
$settings = $this->getChildren($stores['children'], 'Magento_Backend::stores_settings');
28+
$config = $this->getChildren($settings['children'], 'Magento_Config::config');
29+
$payment = $this->getChildren($config['children'], 'Magento_Payment::payment');
30+
$children = [];
31+
foreach ($payment['children'] as $child) {
32+
$children[] = $child['id'];
33+
}
34+
$this->assertContains('Magento_Paypal::paypal', $children);
35+
}
36+
37+
/**
38+
* Filters specified children branch from acl resource
39+
*
40+
* @param array $aclResource
41+
* @param string $filter
42+
* @return array
43+
*/
44+
private function getChildren(array $aclResource, string $filter) : array
45+
{
46+
$filtered = array_filter(
47+
$aclResource,
48+
function ($node) use ($filter) {
49+
return isset($node['id'])
50+
&& $node['id'] === $filter;
51+
}
52+
);
53+
return reset($filtered);
54+
}
55+
}

0 commit comments

Comments
 (0)