Skip to content

Commit b5882dc

Browse files
committed
Merge branch '2.4-develop' of https://github.com/magento/magento2ce into MC-38263
2 parents d162792 + 8b56d34 commit b5882dc

File tree

942 files changed

+109409
-32644
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

942 files changed

+109409
-32644
lines changed

app/code/Magento/Authorization/Model/Role.php

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,32 @@
55
*/
66
namespace Magento\Authorization\Model;
77

8+
use Magento\Authorization\Model\ResourceModel\Role\Collection;
9+
use Magento\Framework\App\ObjectManager;
10+
use Magento\Framework\Model\AbstractModel;
11+
812
/**
913
* Admin Role Model
1014
*
1115
* @api
1216
* @method int getParentId()
13-
* @method \Magento\Authorization\Model\Role setParentId(int $value)
17+
* @method Role setParentId(int $value)
1418
* @method int getTreeLevel()
15-
* @method \Magento\Authorization\Model\Role setTreeLevel(int $value)
19+
* @method Role setTreeLevel(int $value)
1620
* @method int getSortOrder()
17-
* @method \Magento\Authorization\Model\Role setSortOrder(int $value)
21+
* @method Role setSortOrder(int $value)
1822
* @method string getRoleType()
19-
* @method \Magento\Authorization\Model\Role setRoleType(string $value)
23+
* @method Role setRoleType(string $value)
2024
* @method int getUserId()
21-
* @method \Magento\Authorization\Model\Role setUserId(int $value)
25+
* @method Role setUserId(int $value)
2226
* @method string getUserType()
23-
* @method \Magento\Authorization\Model\Role setUserType(string $value)
27+
* @method Role setUserType(string $value)
2428
* @method string getRoleName()
25-
* @method \Magento\Authorization\Model\Role setRoleName(string $value)
29+
* @method Role setRoleName(string $value)
2630
* @api
2731
* @since 100.0.2
2832
*/
29-
class Role extends \Magento\Framework\Model\AbstractModel
33+
class Role extends AbstractModel
3034
{
3135
/**
3236
* @var string
@@ -38,23 +42,6 @@ class Role extends \Magento\Framework\Model\AbstractModel
3842
*/
3943
protected $_cacheTag = 'user_assigned_role';
4044

41-
/**
42-
* @param \Magento\Framework\Model\Context $context
43-
* @param \Magento\Framework\Registry $registry
44-
* @param \Magento\Authorization\Model\ResourceModel\Role $resource
45-
* @param \Magento\Authorization\Model\ResourceModel\Role\Collection $resourceCollection
46-
* @param array $data
47-
*/
48-
public function __construct( //phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod
49-
\Magento\Framework\Model\Context $context,
50-
\Magento\Framework\Registry $registry,
51-
\Magento\Authorization\Model\ResourceModel\Role $resource,
52-
\Magento\Authorization\Model\ResourceModel\Role\Collection $resourceCollection,
53-
array $data = []
54-
) {
55-
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
56-
}
57-
5845
/**
5946
* @inheritDoc
6047
*/
@@ -70,31 +57,30 @@ public function __sleep()
7057
public function __wakeup()
7158
{
7259
parent::__wakeup();
73-
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
74-
$this->_resource = $objectManager->get(\Magento\Authorization\Model\ResourceModel\Role::class);
75-
$this->_resourceCollection = $objectManager->get(
76-
\Magento\Authorization\Model\ResourceModel\Role\Collection::class
77-
);
60+
$objectManager = ObjectManager::getInstance();
61+
$this->_resource = $objectManager->get(ResourceModel\Role::class);
62+
$this->_resourceCollection = $objectManager->get(Collection::class);
7863
}
7964

8065
/**
81-
* Class constructor
82-
*
83-
* @return void
66+
* @inheritdoc
8467
*/
8568
protected function _construct()
8669
{
87-
$this->_init(\Magento\Authorization\Model\ResourceModel\Role::class);
70+
$this->_init(ResourceModel\Role::class);
8871
}
8972

9073
/**
91-
* Update object into database
74+
* Obsolete method of update
9275
*
9376
* @return $this
77+
* @deprecated Method was never implemented and used.
9478
*/
9579
public function update()
9680
{
97-
$this->getResource()->update($this);
81+
// phpcs:disable Magento2.Functions.DiscouragedFunction
82+
trigger_error('Method was never implemented and used.', E_USER_DEPRECATED);
83+
9884
return $this;
9985
}
10086

app/code/Magento/AwsS3/Test/Mftf/Helper/S3FileAssertions.php

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,49 @@ public function deleteFileIfExists($filePath): void
9292
}
9393
}
9494

95+
/**
96+
* Copy source into destination
97+
*
98+
* @param string $source
99+
* @param string $destination
100+
* @return void
101+
*
102+
* @throws \Magento\Framework\Exception\FileSystemException
103+
*/
104+
public function copy($source, $destination): void
105+
{
106+
$this->driver->copy($source, $destination);
107+
}
108+
109+
/**
110+
* Create directory in the S3 bucket
111+
*
112+
* @param string $path
113+
* @param int $permissions
114+
* @return void
115+
*
116+
* @throws \Magento\Framework\Exception\FileSystemException
117+
*/
118+
public function createDirectory($path, $permissions = 0777): void
119+
{
120+
$this->driver->createDirectory($path, $permissions);
121+
}
122+
123+
/**
124+
* Recursive delete directory in the S3 bucket
125+
*
126+
* @param string $path
127+
* @return void
128+
*
129+
* @throws \Magento\Framework\Exception\FileSystemException
130+
*/
131+
public function deleteDirectory($path): void
132+
{
133+
if ($this->driver->isExists($path)) {
134+
$this->driver->deleteDirectory($path);
135+
}
136+
}
137+
95138
/**
96139
* Assert a file exists on the remote storage system
97140
*
@@ -106,6 +149,21 @@ public function assertFileExists($filePath, $message = ''): void
106149
$this->assertTrue($this->driver->isExists($filePath), $message);
107150
}
108151

152+
/**
153+
* Asserts that a file with the given glob pattern exists in the given path on the remote storage system
154+
*
155+
* @param string $path
156+
* @param string $pattern
157+
* @param string $message
158+
*
159+
* @throws \Magento\Framework\Exception\FileSystemException
160+
*/
161+
public function assertGlobbedFileExists($path, $pattern, $message = ""): void
162+
{
163+
$files = $this->driver->search($pattern, $path);
164+
$this->assertNotEmpty($files, $message);
165+
}
166+
109167
/**
110168
* Assert a file does not exist on the remote storage system
111169
*
@@ -163,6 +221,24 @@ public function assertFileContainsString($filePath, $text, $message = ""): void
163221
$this->assertStringContainsString($text, $this->driver->fileGetContents($filePath), $message);
164222
}
165223

224+
/**
225+
* Asserts that a file with the given glob pattern at the given path on the remote storage system contains a given string
226+
*
227+
* @param string $path
228+
* @param string $pattern
229+
* @param string $text
230+
* @param int $fileIndex
231+
* @param string $message
232+
* @return void
233+
*
234+
* @throws \Magento\Framework\Exception\FileSystemException
235+
*/
236+
public function assertGlobbedFileContainsString($path, $pattern, $text, $fileIndex = 0, $message = ""): void
237+
{
238+
$files = $this->driver->search($pattern, $path);
239+
$this->assertStringContainsString($text, $this->driver->fileGetContents($files[$fileIndex] ?? ''), $message);
240+
}
241+
166242
/**
167243
* Assert a file on the remote storage system does not contain a given string
168244
*
@@ -177,4 +253,18 @@ public function assertFileDoesNotContain($filePath, $text, $message = ""): void
177253
{
178254
$this->assertStringNotContainsString($text, $this->driver->fileGetContents($filePath), $message);
179255
}
256+
257+
/**
258+
* Asserts that a directory on the remote storage system is empty
259+
*
260+
* @param string $path
261+
* @param string $message
262+
* @return void
263+
*
264+
* @throws \Magento\Framework\Exception\FileSystemException
265+
*/
266+
public function assertDirectoryEmpty($path, $message = ""): void
267+
{
268+
$this->assertEmpty($this->driver->readDirectory($path), $message);
269+
}
180270
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminAwsS3ExportTaxRatesTest" extends="AdminExportTaxRatesTest">
12+
<annotations>
13+
<features value="AwsS3"/>
14+
<stories value="Export Tax"/>
15+
<title value="S3 - Export Tax Rates"/>
16+
<description value="Exports tax rates from the System > Data Transfer > Import/Export Tax Rates page, from
17+
the Tax Rule page, from the Tax Rates grid page as a .csv, and from the Tax Rates grid page as an .xml.
18+
Validates contents in downloaded file for each export area. Note that MFTF cannot simply click export and
19+
have access to the file that is downloaded in the browser due to the test not having access to the server
20+
that is running the test browser. Therefore, this test verifies that the Export button can be successfully
21+
clicked, grabs the request URL from the Export button's form, executes the request on the magento machine
22+
via a curl request, and verifies the contents of the exported file. Uses S3 for the file system."/>
23+
<severity value="MAJOR"/>
24+
<testCaseId value="MC-38621"/>
25+
<group value="importExport"/>
26+
<group value="tax"/>
27+
</annotations>
28+
29+
<before>
30+
<!-- Enable AWS S3 Remote Storage -->
31+
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.enable_options}}" stepKey="enableRemoteStorage" before="revertInitialTaxRateCA"/>
32+
</before>
33+
34+
<after>
35+
<!-- Disable AWS S3 Remote Storage -->
36+
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.disable_options}}" stepKey="disableRemoteStorage" after="logoutFromAdmin"/>
37+
</after>
38+
</test>
39+
</tests>
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminAwsS3ImportBundleProductTest" extends="AdminImportBundleProductTest">
12+
<annotations>
13+
<features value="AwsS3"/>
14+
<stories value="Import Products"/>
15+
<title value="S3 - Import Bundle Product"/>
16+
<description value="Imports a .csv file containing a bundle product. Verifies that product is imported
17+
successfully and can be purchased."/>
18+
<severity value="MAJOR"/>
19+
<group value="importExport"/>
20+
<group value="Bundle"/>
21+
<group value="remote_storage_aws_s3"/>
22+
</annotations>
23+
24+
<before>
25+
<!-- Locally Copy Import Files to Unique Media Import Directory -->
26+
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="createDirectory" stepKey="createDirectoryForImportFiles" after="createCustomer">
27+
<argument name="path">pub/media/import/{{ImportProduct_Bundle.name}}</argument>
28+
</helper>
29+
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copyImportFile" after="createDirectoryForImportFiles">
30+
<argument name="source">dev/tests/acceptance/tests/_data/{{ImportProduct_Bundle.fileName}}</argument>
31+
<argument name="destination">pub/media/import/{{ImportProduct_Bundle.name}}/{{ImportProduct_Bundle.fileName}}</argument>
32+
</helper>
33+
<remove keyForRemoval="createDirectoryForImportImages"/>
34+
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copyProduct1BaseImage">
35+
<argument name="source">dev/tests/acceptance/tests/_data/{{ImportProductSimple1_Bundle.baseImage}}</argument>
36+
<argument name="destination">pub/media/import/{{ImportProduct_Bundle.name}}/{{ImportProductSimple1_Bundle.baseImage}}</argument>
37+
</helper>
38+
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copyProduct2BaseImage">
39+
<argument name="source">dev/tests/acceptance/tests/_data/{{ImportProductSimple2_Bundle.smallImage}}</argument>
40+
<argument name="destination">pub/media/import/{{ImportProduct_Bundle.name}}/{{ImportProductSimple2_Bundle.smallImage}}</argument>
41+
</helper>
42+
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="copy" stepKey="copyProduct3BaseImage">
43+
<argument name="source">dev/tests/acceptance/tests/_data/{{ImportProductSimple3_Bundle.thumbnailImage}}</argument>
44+
<argument name="destination">pub/media/import/{{ImportProduct_Bundle.name}}/{{ImportProductSimple3_Bundle.thumbnailImage}}</argument>
45+
</helper>
46+
47+
<!-- Enable AWS S3 Remote Storage & Sync -->
48+
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.enable_options}}" stepKey="enableRemoteStorage" after="copyProduct3BaseImage"/>
49+
<magentoCLI command="remote-storage:sync" timeout="120" stepKey="syncRemoteStorage" after="enableRemoteStorage"/>
50+
51+
<!-- Copy to Import Directory in AWS S3 -->
52+
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="createDirectory" stepKey="createDirectoryForImportFilesInS3" after="syncRemoteStorage">
53+
<argument name="path">var/import/images/{{ImportProduct_Bundle.name}}</argument>
54+
</helper>
55+
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="copy" stepKey="copyProduct1BaseImageInS3" after="createDirectoryForImportFilesInS3">
56+
<argument name="source">media/import/{{ImportProduct_Bundle.name}}/{{ImportProductSimple1_Bundle.baseImage}}</argument>
57+
<argument name="destination">var/import/images/{{ImportProduct_Bundle.name}}/{{ImportProductSimple1_Bundle.baseImage}}</argument>
58+
</helper>
59+
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="copy" stepKey="copyProduct2BaseImageInS3" after="copyProduct1BaseImageInS3">
60+
<argument name="source">media/import/{{ImportProduct_Bundle.name}}/{{ImportProductSimple2_Bundle.smallImage}}</argument>
61+
<argument name="destination">var/import/images/{{ImportProduct_Bundle.name}}/{{ImportProductSimple2_Bundle.smallImage}}</argument>
62+
</helper>
63+
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="copy" stepKey="copyProduct3BaseImageInS3" after="copyProduct2BaseImageInS3">
64+
<argument name="source">media/import/{{ImportProduct_Bundle.name}}/{{ImportProductSimple3_Bundle.thumbnailImage}}</argument>
65+
<argument name="destination">var/import/images/{{ImportProduct_Bundle.name}}/{{ImportProductSimple3_Bundle.thumbnailImage}}</argument>
66+
</helper>
67+
</before>
68+
69+
<after>
70+
<!-- Delete S3 Data -->
71+
<remove keyForRemoval="deleteProductImageDirectory"/>
72+
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="deleteDirectory" stepKey="deleteImportFilesDirectoryS3" after="deleteCustomer">
73+
<argument name="path">media/import/{{ImportProduct_Bundle.name}}</argument>
74+
</helper>
75+
<helper class="\Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="deleteDirectory" stepKey="deleteImportImagesFilesDirectoryS3" after="deleteImportFilesDirectoryS3">
76+
<argument name="path">var/import/images/{{ImportProduct_Bundle.name}}</argument>
77+
</helper>
78+
79+
<!-- Disable AWS S3 Remote Storage & Delete Local Data -->
80+
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.disable_options}}" stepKey="disableRemoteStorage" after="logoutFromAdmin"/>
81+
<helper class="\Magento\Catalog\Test\Mftf\Helper\LocalFileAssertions" method="deleteDirectory" stepKey="deleteImportFilesDirectoryLocal" after="disableRemoteStorage">
82+
<argument name="path">pub/media/import/{{ImportProduct_Bundle.name}}</argument>
83+
</helper>
84+
</after>
85+
86+
<!-- Import Bundle Product -->
87+
<actionGroup ref="AdminFillImportFormActionGroup" stepKey="fillImportForm">
88+
<argument name="importFile" value="{{ImportProduct_Bundle.fileName}}"/>
89+
<argument name="imagesFileDirectory" value="{{ImportProduct_Bundle.name}}"/>
90+
</actionGroup>
91+
</test>
92+
</tests>

0 commit comments

Comments
 (0)