Skip to content

Commit 25d77b8

Browse files
committed
Merge branch 'ACP2E-3208' of https://github.com/adobe-commerce-tier-4/magento2ce into PR-08-29-2024
2 parents 772140e + 553acda commit 25d77b8

File tree

2 files changed

+58
-1
lines changed
  • app/code/Magento/Paypal/etc
  • dev/tests/integration/testsuite/Magento/Paypal/etc

2 files changed

+58
-1
lines changed

app/code/Magento/Paypal/etc/acl.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
<resource id="Magento_Backend::stores">
1313
<resource id="Magento_Backend::stores_settings">
1414
<resource id="Magento_Config::config">
15-
<resource id="Magento_Paypal::paypal" title="PayPal Section" translate="title" sortOrder="50" />
15+
<resource id="Magento_Payment::payment">
16+
<resource id="Magento_Paypal::paypal" title="PayPal Section" translate="title" sortOrder="50" />
17+
</resource>
1618
</resource>
1719
</resource>
1820
</resource>
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)