Skip to content

Commit aff2aa5

Browse files
committed
fixed integration test
1 parent 10cbd63 commit aff2aa5

File tree

4 files changed

+40
-8
lines changed

4 files changed

+40
-8
lines changed

app/code/Magento/Backend/Test/Unit/Model/Search/Config/Result/BuilderTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
use Magento\Config\Model\Config\StructureElementInterface;
1212
use PHPUnit\Framework\TestCase;
1313

14+
/**
15+
* @SuppressWarnings(PHPMD.LongVariable)
16+
*/
1417
class BuilderTest extends TestCase
1518
{
1619
/**
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Backend\Model\Search;
8+
9+
class AuthorizationMock extends \Magento\Framework\Authorization
10+
{
11+
/**
12+
* Check current user permission on resource and privilege
13+
*
14+
* @param string $resource
15+
* @param string $privilege
16+
* @return boolean
17+
*/
18+
public function isAllowed($resource, $privilege = null)
19+
{
20+
return true;
21+
}
22+
}

dev/tests/integration/testsuite/Magento/Backend/Model/Search/ConfigTest.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
use Magento\Framework\App\AreaList;
1212
use Magento\Framework\App\Cache\State;
1313
use Magento\Framework\App\Config\FileResolver;
14+
use Magento\Framework\AuthorizationInterface;
1415
use Magento\Framework\Config\FileIteratorFactory;
1516
use Magento\Framework\Config\ScopeInterface;
1617
use Magento\TestFramework\Helper\Bootstrap;
1718

1819
/**
1920
* @magentoAppArea adminhtml
21+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2022
*/
2123
class ConfigTest extends \PHPUnit\Framework\TestCase
2224
{
@@ -39,9 +41,8 @@ public function testLoad($query, $expectedResult)
3941
foreach ($expectedResult as $itemIndex => $expectedItem) {
4042
/** Validate URL to item */
4143
$elementPathParts = explode('/', $expectedItem['id']);
42-
array_filter($elementPathParts, function ($value) {
43-
return $value !== '';
44-
});
44+
// filter empty values
45+
$elementPathParts = array_values(array_filter($elementPathParts));
4546
foreach ($elementPathParts as $elementPathPart) {
4647
$this->assertContains($elementPathPart, $searchResults[$itemIndex]['url'], 'Item URL is invalid.');
4748
}
@@ -67,6 +68,12 @@ private function getConfigSearchInstance()
6768
->getArea(FrontNameResolver::AREA_CODE)
6869
->load(Area::PART_CONFIG);
6970

71+
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->configure([
72+
'preferences' => [
73+
AuthorizationInterface::class => \Magento\Backend\Model\Search\AuthorizationMock::class
74+
]
75+
]);
76+
7077
$fileResolverMock = $this->getMockBuilder(FileResolver::class)->disableOriginalConstructor()->getMock();
7178
$fileIteratorFactory = Bootstrap::getObjectManager()->get(FileIteratorFactory::class);
7279
$fileIterator = $fileIteratorFactory->create(
@@ -110,13 +117,13 @@ public static function loadDataProvider()
110117
'id' => 'test_section/test_group/test_field_1',
111118
'type' => null,
112119
'name' => 'Test Field',
113-
'description' => '/ Test Tab / Test Section / Test Group',
120+
'description' => ' / Test Tab / Test Section / Test Group',
114121
],
115122
[
116123
'id' => 'test_section/test_group/test_field_2',
117124
'type' => null,
118125
'name' => 'Test Field',
119-
'description' => '/ Test Tab / Test Section / Test Group',
126+
'description' => ' / Test Tab / Test Section / Test Group',
120127
],
121128
],
122129
],
@@ -127,7 +134,7 @@ public static function loadDataProvider()
127134
'id' => 'test_section/test_group',
128135
'type' => null,
129136
'name' => 'Test Group',
130-
'description' => '/ Test Tab / Test Section',
137+
'description' => ' / Test Tab / Test Section',
131138
],
132139
],
133140
],
@@ -138,7 +145,7 @@ public static function loadDataProvider()
138145
'id' => '/test_section',
139146
'type' => null,
140147
'name' => 'Test Section',
141-
'description' => '/ Test Tab',
148+
'description' => ' / Test Tab',
142149
],
143150
],
144151
],

dev/tests/integration/testsuite/Magento/Backend/Model/Search/_files/test_config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<section id="test_section" translate="label" showInDefault="1" showInWebsite="1" showInStore="1" type="text" sortOrder="0">
1414
<label>Test Section</label>
1515
<tab>test</tab>
16-
16+
<resource>Magento_Backend::test</resource>
1717
<group id="test_group" translate="label" showInDefault="1" showInWebsite="1" showInStore="1" type="text" sortOrder="10">
1818
<label>Test Group</label>
1919
<field id="test_field_1" translate="label" showInDefault="1" showInWebsite="1" showInStore="1" type="text" sortOrder="20">

0 commit comments

Comments
 (0)