Skip to content

Commit bf45681

Browse files
committed
Merge remote-tracking branch 'origin/develop' into MQE-1581
2 parents 3eadcc1 + 264aaea commit bf45681

File tree

14 files changed

+143
-58
lines changed

14 files changed

+143
-58
lines changed

Diff for: .travis.yml

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
language: php
22
php:
3-
- 7.0
4-
- 7.1
53
- 7.2
64
- 7.3
75
install: composer install --no-interaction --prefer-source

Diff for: composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
"name": "magento/magento2-functional-testing-framework",
33
"description": "Magento2 Functional Testing Framework",
44
"type": "library",
5-
"version": "2.6.3",
5+
"version": "3.0.0",
66
"license": "AGPL-3.0",
77
"keywords": ["magento", "automation", "functional", "testing"],
88
"config": {
99
"sort-packages": true
1010
},
1111
"require": {
12-
"php": "7.0.2||7.0.4||~7.0.6||~7.1.0||~7.2.0||~7.3.0",
12+
"php": "~7.2.0||~7.3.0",
1313
"ext-curl": "*",
1414
"ext-json": "*",
1515
"ext-openssl": "*",

Diff for: composer.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dev/tests/functional/standalone_bootstrap.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
$env->setEnvironmentVariable('DEFAULT_TIMEZONE', DEFAULT_TIMEZONE);
5252

5353
defined('WAIT_TIMEOUT') || define('WAIT_TIMEOUT', 30);
54-
$env->setEnvironmentVariable('WAIT_TIMEOUT', 30);
54+
$env->setEnvironmentVariable('WAIT_TIMEOUT', WAIT_TIMEOUT);
5555

5656
try {
5757
new DateTimeZone(DEFAULT_TIMEZONE);

Diff for: dev/tests/unit/Magento/FunctionalTestFramework/Util/ModuleResolverTest.php

-14
Original file line numberDiff line numberDiff line change
@@ -146,20 +146,6 @@ function ($arg) {
146146
'Test' . DIRECTORY_SEPARATOR .'Mftf'
147147
]
148148
);
149-
$mockResolver->verifyInvoked(
150-
'globRelevantPaths',
151-
[
152-
$magentoBaseCodePath
153-
. DIRECTORY_SEPARATOR . "dev"
154-
. DIRECTORY_SEPARATOR . "tests"
155-
. DIRECTORY_SEPARATOR . "acceptance"
156-
. DIRECTORY_SEPARATOR . "tests"
157-
. DIRECTORY_SEPARATOR . "functional"
158-
. DIRECTORY_SEPARATOR . "Magento"
159-
. DIRECTORY_SEPARATOR . "FunctionalTest"
160-
, ''
161-
]
162-
);
163149
}
164150

165151
/**

Diff for: docs/metadata.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ The following diagram demonstrates the XML structure of a metadata file:
6767
## Principles {#principles}
6868

6969
1. A `dataType` value must match the `type` value of the corresponding entity.
70-
2. A file name should contain data type split with `_` and must end with `-meta`.
71-
Example: `product_attribute-meta.xml`.
70+
2. A file name should be PascalCase and end with `Meta.xml`.
71+
Example: `ProductAttributeMeta.xml`.
7272
3. A metadata file may contain different types of operations (`type`) with the same data entity (`dataType`).
7373

7474
Example:
@@ -139,7 +139,7 @@ _Catalog/Data/CategoryData.xml_:
139139
Here, `type` is equal to `"category"`, which instructs the MFTF to search an operation with `dataType="category"`.
140140
Since the action is __to create__ a category, the MFTF will also search for operation with `type="create"` in _Metadata_ for `dataType="category"`.
141141

142-
_Catalog/Metadata/category-meta.xml_:
142+
_Catalog/Metadata/CategoryMeta.xml_:
143143

144144
```xml
145145
<operation name="CreateCategory" dataType="category" type="create" auth="adminOauth" url="/V1/categories" method="POST">
@@ -187,10 +187,10 @@ Comments in the example below are used to demonstrate relation between JSON requ
187187
JSON does not support comments.
188188
</div>
189189

190-
Model schema for _catalogCategoryRepositoryV1SavePostBody_ with XML representation of _Catalog/Metadata/category-meta.xml_ in comments:
190+
Model schema for _catalogCategoryRepositoryV1SavePostBody_ with XML representation of _Catalog/Metadata/CategoryMeta.xml_ in comments:
191191

192192
```json
193-
{ // XML representation in the MFTF metadata format (see 'Catalog/Metadata/category-meta.xml')
193+
{ // XML representation in the MFTF metadata format (see 'Catalog/Metadata/CategoryMeta.xml')
194194
"category": { // <object key="category" dataType="category">
195195
"id": 0, // Skipped, because Category ID is not available on UI when you create a new category.
196196
"parent_id": 0, // <field key="parent_id">integer</field>
@@ -206,9 +206,9 @@ Model schema for _catalogCategoryRepositoryV1SavePostBody_ with XML representati
206206
"string" // <value>string</value>
207207
], // </array>
208208
"include_in_menu": true, // <field key="include_in_menu">boolean</field>
209-
"extension_attributes": {}, // <field key="extension_attributes">empty_extension_attribute</field>, where 'empty_extension_attribute' is a reference to operation with 'dataType="empty_extension_attribute"' (see 'Catalog/Metadata/empty_extension_attribute-meta.xml')
209+
"extension_attributes": {}, // <field key="extension_attributes">empty_extension_attribute</field>, where 'empty_extension_attribute' is a reference to operation with 'dataType="empty_extension_attribute"' (see 'Catalog/Metadata/EmptyExtensionAttributeMeta.xml')
210210
"custom_attributes": [ // <array key="custom_attributes">
211-
{ // <value>custom_attribute</value>, where 'custom_attribute' is a reference to operation with 'dataType="custom_attribute"' (see 'Catalog/Metadata/custom_attribute-meta.xml')
211+
{ // <value>custom_attribute</value>, where 'custom_attribute' is a reference to operation with 'dataType="custom_attribute"' (see 'Catalog/Metadata/CustomAttributeMeta.xml')
212212
"attribute_code": "string",
213213
"value": "string"
214214
}
@@ -343,7 +343,7 @@ You are able to create assurances with `successRegex`, and, optionally, return v
343343

344344
The `CreateStoreGroup` operation is used to persist a store group:
345345

346-
Source file is _Store/Metadata/store_group-meta.xml_:
346+
Source file is _Store/Metadata/StoreGroupMeta.xml_:
347347

348348
```xml
349349
<operation name="CreateStoreGroup" dataType="group" type="create" auth="adminFormKey" url="/admin/system_store/save" method="POST" successRegex="/messages-message-success/" >
@@ -379,7 +379,7 @@ The operation enables you to assign the following form fields:
379379

380380
The MFTF uses the `CreateWishlist` operation to create a wish list on storefront:
381381

382-
Source file is _Wishlist/Metadata/wishlist-meta.xml_
382+
Source file is _Wishlist/Metadata/WishlistMeta.xml_
383383

384384
```xml
385385
<operation name="CreateWishlist" dataType="wishlist" type="create" auth="customerFormKey" url="/wishlist/index/add/" method="POST" successRegex="" returnRegex="~\/wishlist_id\/(\d*?)\/~" >

Diff for: docs/mftf-tests-packaging.md

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<style>
2+
.mftf-dl {
3+
margin-bottom: 2.5em;
4+
}
5+
dl dt{
6+
font-weight:400;
7+
}
8+
</style>
9+
10+
# MFTF functional test modules and packaging
11+
12+
## MFTF predefined test module paths
13+
The Magento Functional Testing Framework can run tests from predefined paths and custom paths. The predefined paths are:
14+
```
15+
app/code/<Vendor>/<Module>/Test/Mftf
16+
dev/tests/acceptance/tests/functional/<Vendor>/<TestModule>
17+
vendor/<Vendor>/<Module>/Test/Mftf
18+
vendor/<Vendor>/<TestModule>
19+
```
20+
21+
To support future service isolation, Test module in `dev/tests/acceptance/tests/functional/<Vendor>/<TestModule>` and
22+
`vendor/<Vendor>/<TestModule>` must define the module type as `magento2-functional-test-module` in its `composer.json` file.
23+
No `composer.json` file is required for tests in `app/code/<Vendor>/<Module>/Test/Mftf` and `vendor/<Vendor>/<Module>/Test/Mftf`
24+
as they are part of the Magento modules.
25+
26+
Test module for a specific Magento module can only be in one of the paths.
27+
28+
## Test module composer.json format
29+
30+
Test module `composer.json` file should use type `magento2-functional-test-module`.
31+
32+
Test module `composer.json` file should define Magento module dependencies in suggests block.
33+
MFTF will recognize the dependency if the suggest message of a module specifies `type` using `magento2-module` and `name`
34+
using module name registered with Magento.
35+
36+
Here is an example `composer.json` file for the test module `dev/tests/acceptance/tests/functional/Magento/ConfigurableProductCatalogSearch`:
37+
38+
```json
39+
{
40+
"name": "magento/module-configurable-product-catalog-search-functional-test",
41+
"description": "MFTF test module for Magento_ConfigurableProduct and Magento_CatalogSearch",
42+
"type": "magento2-functional-test-module",
43+
"config": {
44+
"sort-packages": true
45+
},
46+
"require": {
47+
"magento/magento2-functional-testing-framework": ">=2.5"
48+
},
49+
"suggest": {
50+
"magento/module-configurable-product": "type: magento2-module, name: Magento_ConfigurableProduct, version: *",
51+
"magento/module-catalog-search": "type: magento2-module, name: Magento_CatalogSearch, version: *"
52+
},
53+
"license": [
54+
"OSL-3.0",
55+
"AFL-3.0"
56+
]
57+
}
58+
```

Diff for: etc/config/functional.suite.dist.yml

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ modules:
2929
username: "%MAGENTO_ADMIN_USERNAME%"
3030
password: "%MAGENTO_ADMIN_PASSWORD%"
3131
pageload_timeout: "%WAIT_TIMEOUT%"
32+
request_timeout: "%WAIT_TIMEOUT%"
33+
connection_timeout: "%WAIT_TIMEOUT%"
3234
host: "%SELENIUM_HOST%"
3335
port: "%SELENIUM_PORT%"
3436
protocol: "%SELENIUM_PROTOCOL%"

Diff for: etc/di.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@
198198
<argument name="mergeablePaths" xsi:type="array">
199199
<item name="/operations/operation/object" xsi:type="string"/>
200200
</argument>
201-
<argument name="fileName" xsi:type="string">*-meta.xml</argument>
201+
<argument name="fileName" xsi:type="string">*Meta.xml</argument>
202202
<argument name="defaultScope" xsi:type="string">Metadata</argument>
203203
</arguments>
204204
</virtualType>

Diff for: src/Magento/FunctionalTestingFramework/DataGenerator/etc/dataOperation.xsd

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,4 @@
109109
<xs:enumeration value="DELETE" />
110110
</xs:restriction>
111111
</xs:simpleType>
112-
</xs:schema>
112+
</xs:schema>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\FunctionalTestingFramework\Upgrade;
8+
9+
use Symfony\Component\Console\Input\InputInterface;
10+
use Symfony\Component\Finder\Finder;
11+
12+
/**
13+
* Class RenameMetadataFiles
14+
* @package Magento\FunctionalTestingFramework\Upgrade
15+
*/
16+
class RenameMetadataFiles implements UpgradeInterface
17+
{
18+
/**
19+
* Upgrades all test xml files
20+
*
21+
* @param InputInterface $input
22+
* @return string
23+
*/
24+
public function execute(InputInterface $input)
25+
{
26+
$path = $input->getArgument("path");
27+
$finder = new Finder();
28+
$finder->files()->in($path)->name("*-meta.xml");
29+
30+
foreach ($finder->files() as $file) {
31+
$oldFileName = $file->getFileName();
32+
$newFileName = $this->convertFileName($oldFileName);
33+
$oldPath = $file->getPathname();
34+
$newPath = $file->getPath() . "/" . $newFileName;
35+
print("Renaming " . $oldPath . " => " . $newPath . "\n");
36+
rename($oldPath, $newPath);
37+
}
38+
39+
return "Finished renaming -meta.xml files.";
40+
}
41+
42+
/**
43+
* Convert filenames like:
44+
* user_role-meta.xml => UserRoleMeta.xml
45+
* store-meta.xml => StoreMeta.xml
46+
*
47+
* @param string $oldFileName
48+
* @return string
49+
*/
50+
private function convertFileName(string $oldFileName)
51+
{
52+
$stripEnding = preg_replace("/-meta.xml/", "", $oldFileName);
53+
$hyphenToUnderscore = str_replace("-", "_", $stripEnding);
54+
$parts = explode("_", $hyphenToUnderscore);
55+
$ucParts = [];
56+
foreach ($parts as $part) {
57+
$ucParts[] = ucfirst($part);
58+
}
59+
$recombine = join("", $ucParts);
60+
$addEnding = $recombine . "Meta.xml";
61+
return $addEnding;
62+
}
63+
}

Diff for: src/Magento/FunctionalTestingFramework/Upgrade/UpgradeScriptList.php

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function __construct(array $scripts = [])
2929
{
3030
$this->scripts = [
3131
'upgradeTestSchema' => new UpdateTestSchemaPaths(),
32+
'renameMetadataFiles' => new RenameMetadataFiles()
3233
] + $scripts;
3334
}
3435

Diff for: src/Magento/FunctionalTestingFramework/Util/ModuleResolver.php

+1-24
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@ class ModuleResolver
5454
. 'tests'
5555
. DIRECTORY_SEPARATOR
5656
. 'functional';
57-
const DEPRECATED_DEV_TESTS = DIRECTORY_SEPARATOR
58-
. self:: DEV_TESTS
59-
. DIRECTORY_SEPARATOR
60-
. "Magento"
61-
. DIRECTORY_SEPARATOR
62-
. "FunctionalTest";
6357

6458
/**
6559
* Enabled modules.
@@ -327,8 +321,7 @@ private function aggregateTestModulePaths()
327321
$codePathsToPattern = [
328322
$modulePath => '',
329323
$magentoBaseCodePath . $vendorCodePath => self::TEST_MFTF_PATTERN,
330-
$magentoBaseCodePath . $appCodePath => self::TEST_MFTF_PATTERN,
331-
$magentoBaseCodePath . self::DEPRECATED_DEV_TESTS => ''
324+
$magentoBaseCodePath . $appCodePath => self::TEST_MFTF_PATTERN
332325
];
333326

334327
foreach ($codePathsToPattern as $codePath => $pattern) {
@@ -374,22 +367,6 @@ private function globRelevantPaths($testPath, $pattern)
374367
}
375368
}
376369

377-
/* TODO uncomment this to show deprecation warning when we ready to fully deliver test packaging feature
378-
if (strpos($testPath, self::DEPRECATED_DEV_TESTS) !== false && !empty($modulePaths)) {
379-
$deprecatedPath = ltrim(self::DEPRECATED_DEV_TESTS, DIRECTORY_SEPARATOR);
380-
$suggestedPath = self::DEV_TESTS . DIRECTORY_SEPARATOR . 'Magento';
381-
$message = "DEPRECATION: Found MFTF test modules in the deprecated path: $deprecatedPath."
382-
. " Move these test modules to $suggestedPath.";
383-
384-
if (MftfApplicationConfig::getConfig()->verboseEnabled()) {
385-
LoggingUtil::getInstance()->getLogger(ModuleResolver::class)->warning($message);
386-
}
387-
// Suppress print during unit testing
388-
if (MftfApplicationConfig::getConfig()->getPhase() !== MftfApplicationConfig::UNIT_TEST_PHASE) {
389-
print ("\n$message\n\n");
390-
}
391-
}
392-
*/
393370
return $modulePaths;
394371
}
395372

Diff for: src/Magento/FunctionalTestingFramework/_bootstrap.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
$env->setEnvironmentVariable('DEFAULT_TIMEZONE', DEFAULT_TIMEZONE);
5252

5353
defined('WAIT_TIMEOUT') || define('WAIT_TIMEOUT', 30);
54-
$env->setEnvironmentVariable('WAIT_TIMEOUT', 30);
54+
$env->setEnvironmentVariable('WAIT_TIMEOUT', WAIT_TIMEOUT);
5555

5656
try {
5757
new DateTimeZone(DEFAULT_TIMEZONE);
@@ -66,7 +66,7 @@
6666
// define TEST_PATH and TEST_MODULE_PATH
6767
defined('TESTS_BP') || define('TESTS_BP', realpath(MAGENTO_BP . DIRECTORY_SEPARATOR . 'dev/tests/acceptance'));
6868

69-
$RELATIVE_TESTS_MODULE_PATH = '/tests/functional/Magento/FunctionalTest';
69+
$RELATIVE_TESTS_MODULE_PATH = '/tests/functional/Magento';
7070
defined('TESTS_MODULE_PATH') || define(
7171
'TESTS_MODULE_PATH',
7272
realpath(TESTS_BP . $RELATIVE_TESTS_MODULE_PATH)

0 commit comments

Comments
 (0)