Skip to content

Commit 8efe995

Browse files
committed
Merge remote-tracking branch 'origin/develop' into MQE-1354
# Conflicts: # src/Magento/FunctionalTestingFramework/DataGenerator/Persist/Curl/WebapiExecutor.php
2 parents 092634a + 4522886 commit 8efe995

19 files changed

+200
-81
lines changed

dev/tests/static/Magento/Sniffs/Commenting/FunctionCommentSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ protected function processReturn(File $phpcsFile, $stackPtr, $commentStart)
6868
$phpcsFile->addError($error, $return, 'MissingReturnType');
6969
} else {
7070
// Support both a return type and a description.
71-
$split = preg_match('`^((?:\|?(?:array\([^\)]*\)|[\\\\a-z0-9\[\]]+))*)( .*)?`i', $content, $returnParts);
71+
preg_match('`^((?:\|?(?:array\([^\)]*\)|[\\\\a-z0-9\[\]]+))*)( .*)?`i', $content, $returnParts);
7272
if (isset($returnParts[1]) === false) {
7373
return;
7474
}
@@ -78,7 +78,7 @@ protected function processReturn(File $phpcsFile, $stackPtr, $commentStart)
7878
// Check return type (can be multiple, separated by '|').
7979
$typeNames = explode('|', $returnType);
8080
$suggestedNames = array();
81-
foreach ($typeNames as $i => $typeName) {
81+
foreach ($typeNames as $typeName) {
8282
$suggestedName = Common::suggestType($typeName);
8383
if (in_array($suggestedName, $suggestedNames) === false) {
8484
$suggestedNames[] = $suggestedName;

dev/tests/verification/Resources/ActionGroupWithSectionAndDataAsArguments.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ class ActionGroupWithSectionAndDataAsArgumentsCest
2727
*/
2828
public function ActionGroupWithSectionAndDataAsArguments(AcceptanceTester $I)
2929
{
30-
$I->waitForElementVisible("#element .John");
30+
$I->waitForElementVisible("#element .John", 10);
3131
}
3232
}

dev/tests/verification/Resources/BasicFunctionalTest.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class BasicFunctionalTestCest
126126
$I->moveMouseOver(".functionalTestSelector");
127127
$I->openNewTab();
128128
$I->pauseExecution();
129-
$I->performOn("#selector", function(\WebDriverElement $el) {return $el->isDisplayed();});
129+
$I->performOn("#selector", function(\WebDriverElement $el) {return $el->isDisplayed();}, 10);
130130
$I->pressKey("#page", "a");
131131
$I->pressKey("#page", ['ctrl', 'a'],'new');
132132
$I->pressKey("#page", ['shift', '111'],'1','x');
@@ -165,7 +165,7 @@ class BasicFunctionalTestCest
165165
$I->waitForElement(".functionalTestSelector", 30);
166166
$I->waitForElementNotVisible(".functionalTestSelector", 30);
167167
$I->waitForElementVisible(".functionalTestSelector", 30);
168-
$I->waitForElementChange("#selector", function(\WebDriverElement $el) {return $el->isDisplayed();});
168+
$I->waitForElementChange("#selector", function(\WebDriverElement $el) {return $el->isDisplayed();}, 10);
169169
$I->waitForJS("someJsFunction", 30);
170170
$I->waitForText("someInput", 30, ".functionalTestSelector");
171171
}

dev/tests/verification/Resources/ExtendedTestInSuiteChildTestCest.txt renamed to dev/tests/verification/Resources/ExtendedChildTestInSuiteCest.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ use Yandex\Allure\Adapter\Model\SeverityLevel;
1515
use Yandex\Allure\Adapter\Annotation\TestCaseId;
1616

1717
/**
18-
* @Title("[NO TESTCASEID]: ExtendedTestInSuiteChildTest")
19-
* @group ExtendedTestInSuiteChildTest
18+
* @Title("[NO TESTCASEID]: ExtendedChildTestInSuite")
19+
* @group ExtendedTestInSuite
2020
*/
21-
class ExtendedTestInSuiteChildTestCest
21+
class ExtendedChildTestInSuiteCest
2222
{
2323
/**
2424
* @param AcceptanceTester $I
@@ -50,13 +50,13 @@ class ExtendedTestInSuiteChildTestCest
5050
/**
5151
* @Severity(level = SeverityLevel::TRIVIAL)
5252
* @Features({"TestModule"})
53-
* @Stories({"ExtendedTestInSuiteChildTest"})
53+
* @Stories({"ExtendedChildTestInSuite"})
5454
* @Parameter(name = "AcceptanceTester", value="$I")
5555
* @param AcceptanceTester $I
5656
* @return void
5757
* @throws \Exception
5858
*/
59-
public function ExtendedTestInSuiteChildTest(AcceptanceTester $I)
59+
public function ExtendedChildTestInSuite(AcceptanceTester $I)
6060
{
6161
$I->comment("Different Input");
6262
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
namespace Magento\AcceptanceTest\_default\Backend;
3+
4+
use Magento\FunctionalTestingFramework\AcceptanceTester;
5+
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore;
6+
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler;
7+
use \Codeception\Util\Locator;
8+
use Yandex\Allure\Adapter\Annotation\Features;
9+
use Yandex\Allure\Adapter\Annotation\Stories;
10+
use Yandex\Allure\Adapter\Annotation\Title;
11+
use Yandex\Allure\Adapter\Annotation\Description;
12+
use Yandex\Allure\Adapter\Annotation\Parameter;
13+
use Yandex\Allure\Adapter\Annotation\Severity;
14+
use Yandex\Allure\Adapter\Model\SeverityLevel;
15+
use Yandex\Allure\Adapter\Annotation\TestCaseId;
16+
17+
/**
18+
* @Title("[NO TESTCASEID]: ExtendedChildTestNotInSuite")
19+
*/
20+
class ExtendedChildTestNotInSuiteCest
21+
{
22+
/**
23+
* @param AcceptanceTester $I
24+
* @throws \Exception
25+
*/
26+
public function _before(AcceptanceTester $I)
27+
{
28+
$I->amOnPage("/beforeUrl");
29+
}
30+
31+
/**
32+
* @param AcceptanceTester $I
33+
* @throws \Exception
34+
*/
35+
public function _after(AcceptanceTester $I)
36+
{
37+
$I->amOnPage("/afterUrl");
38+
}
39+
40+
/**
41+
* @param AcceptanceTester $I
42+
* @throws \Exception
43+
*/
44+
public function _failed(AcceptanceTester $I)
45+
{
46+
$I->saveScreenshot();
47+
}
48+
49+
/**
50+
* @Severity(level = SeverityLevel::TRIVIAL)
51+
* @Features({"TestModule"})
52+
* @Stories({"ExtendedChildTestNotInSuite"})
53+
* @Parameter(name = "AcceptanceTester", value="$I")
54+
* @param AcceptanceTester $I
55+
* @return void
56+
* @throws \Exception
57+
*/
58+
public function ExtendedChildTestNotInSuite(AcceptanceTester $I)
59+
{
60+
$I->comment("Different Input");
61+
}
62+
}

dev/tests/verification/TestModule/Test/ExtendedFunctionalTest.xml

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,13 @@
159159
<comment userInput="child" stepKey="replaceMe"/>
160160
</test>
161161

162-
<test name="ExtendedTestInSuiteParentTest">
162+
<test name="ExtendedTestRelatedToSuiteParentTest">
163163
<annotations>
164164
<severity value="AVERAGE"/>
165-
<title value="ExtendedTestInSuiteParentTest"/>
166-
<group value="ExtendedTestInSuite"/>
167-
<features value="ExtendedTestInSuite"/>
168-
<stories value="ExtendedTestInSuite"/>
165+
<title value="ExtendedTestRelatedToSuiteParentTest"/>
166+
<group value="ExtendedTestRelatedToSuite"/>
167+
<features value="ExtendedTestRelatedToSuiteParentTest"/>
168+
<stories value="ExtendedTestRelatedToSuiteParentTest"/>
169169
</annotations>
170170
<before>
171171
<amOnPage url="/beforeUrl" stepKey="beforeAmOnPageKey"/>
@@ -174,16 +174,28 @@
174174
<amOnPage url="/afterUrl" stepKey="afterAmOnPageKey"/>
175175
</after>
176176
<comment stepKey="basicCommentWithNoData" userInput="Parent Comment"/>
177+
<amOnPage url="/url/in/parent" stepKey="amOnPageInParent"/>
177178
</test>
178179

179-
<test name="ExtendedTestInSuiteChildTest" extends="ExtendedTestInSuiteParentTest">
180+
<test name="ExtendedChildTestInSuite" extends="ExtendedTestRelatedToSuiteParentTest">
181+
<annotations>
182+
<severity value="MINOR"/>
183+
<title value="ExtendedChildTestInSuite"/>
184+
<group value="ExtendedTestInSuite"/>
185+
<features value="ExtendedChildTestInSuite"/>
186+
<stories value="ExtendedChildTestInSuite"/>
187+
</annotations>
188+
<comment stepKey="basicCommentWithNoData" userInput="Different Input"/>
189+
<remove keyForRemoval="amOnPageInParent"/>
190+
</test>
191+
<test name="ExtendedChildTestNotInSuite" extends="ExtendedTestRelatedToSuiteParentTest">
180192
<annotations>
181193
<severity value="MINOR"/>
182-
<title value="ExtendedTestInSuiteChildTest"/>
183-
<group value="ExtendedTestInSuiteChildTest"/>
184-
<features value="ExtendedTestInSuiteChildTest"/>
185-
<stories value="ExtendedTestInSuiteChildTest"/>
194+
<title value="ExtendedChildTestNotInSuite"/>
195+
<features value="ExtendedChildTestNotInSuite"/>
196+
<stories value="ExtendedChildTestNotInSuite"/>
186197
</annotations>
187198
<comment stepKey="basicCommentWithNoData" userInput="Different Input"/>
199+
<remove keyForRemoval="amOnPageInParent"/>
188200
</test>
189201
</tests>

dev/tests/verification/Tests/ExtendedGenerationTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,15 @@ public function testExtendingSkippedGeneration()
118118
{
119119
$this->generateAndCompareTest('ExtendingSkippedTest');
120120
}
121+
122+
/**
123+
* Tests extending and removing parent steps test generation.
124+
*
125+
* @throws \Exception
126+
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
127+
*/
128+
public function testExtendingAndRemovingStepsGeneration()
129+
{
130+
$this->generateAndCompareTest('ExtendedChildTestNotInSuite');
131+
}
121132
}

dev/tests/verification/Tests/SuiteGenerationTest.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ public function testSuiteGenerationWithExtends()
292292
{
293293
$groupName = 'suiteExtends';
294294

295-
$expectedContents = [
296-
'ExtendedTestInSuiteChildTestCest.php'
295+
$expectedFileNames = [
296+
'ExtendedChildTestInSuiteCest'
297297
];
298298

299299
// Generate the Suite
@@ -312,15 +312,18 @@ public function testSuiteGenerationWithExtends()
312312
$this->assertArrayHasKey($groupName, $yml['groups']);
313313

314314
$suiteResultBaseDir = self::GENERATE_RESULT_DIR .
315-
DIRECTORY_SEPARATOR .
316315
$groupName .
317316
DIRECTORY_SEPARATOR;
318317

319318
// Validate tests have been generated
320319
$dirContents = array_diff(scandir($suiteResultBaseDir), ['..', '.']);
321320

322-
foreach ($expectedContents as $expectedFile) {
323-
$this->assertTrue(in_array($expectedFile, $dirContents));
321+
foreach ($expectedFileNames as $expectedFileName) {
322+
$this->assertTrue(in_array($expectedFileName . ".php", $dirContents));
323+
$this->assertFileEquals(
324+
self::RESOURCES_PATH . DIRECTORY_SEPARATOR . $expectedFileName . ".txt",
325+
$suiteResultBaseDir . $expectedFileName . ".php"
326+
);
324327
}
325328
}
326329

dev/tests/verification/_suite/functionalSuiteExtends.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<suites xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../src/Magento/FunctionalTestingFramework/Suite/etc/suiteSchema.xsd">
1010
<suite name="suiteExtends">
1111
<include>
12-
<group name="ExtendedTestInSuiteChildTest"/>
12+
<group name="ExtendedTestInSuite"/>
1313
</include>
1414
</suite>
1515
</suites>

etc/config/.env.example

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
#*** Set the base URL for your Magento instance ***#
55
MAGENTO_BASE_URL=http://devdocs.magento.com/
66

7+
#*** Uncomment if you are running Admin Panel on separate domain (used with MAGENTO_BACKEND_NAME) ***#
8+
# MAGENTO_BACKEND_BASE_HOST=http://admin.example.com/
9+
710
#*** Set the Admin Username and Password for your Magento instance ***#
811
MAGENTO_BACKEND_NAME=admin
912
MAGENTO_ADMIN_USERNAME=admin
@@ -23,8 +26,9 @@ MAGENTO_ADMIN_PASSWORD=123123q
2326
BROWSER=chrome
2427

2528
#*** Uncomment and set host & port if your dev environment needs different value other than MAGENTO_BASE_URL for Rest API Requests ***#
26-
#MAGENTO_RESTAPI_SERVER_HOST=
27-
#MAGENTO_RESTAPI_SERVER_PORT=
29+
#MAGENTO_RESTAPI_SERVER_HOST=restapi.magento.com
30+
#MAGENTO_RESTAPI_SERVER_PORT=8080
31+
#MAGENTO_RESTAPI_SERVER_PROTOCOL=https
2832

2933
#*** Uncomment these properties to set up a dev environment with symlinked projects ***#
3034
#TESTS_BP=
@@ -40,4 +44,7 @@ MODULE_WHITELIST=Magento_Framework,Magento_ConfigurableProductWishlist,Magento_C
4044

4145
#*** Bool property which allows the user to toggle debug output during test execution
4246
#MFTF_DEBUG=
47+
48+
#*** Default timeout for wait actions
49+
#WAIT_TIMEOUT=10
4350
#*** End of .env ***#

etc/config/functional.suite.dist.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ modules:
2020
config:
2121
\Magento\FunctionalTestingFramework\Module\MagentoWebDriver:
2222
url: "%MAGENTO_BASE_URL%"
23+
backend_url: "%MAGENTO_BACKEND_BASE_URL%"
2324
backend_name: "%MAGENTO_BACKEND_NAME%"
2425
browser: 'chrome'
2526
restart: true

src/Magento/FunctionalTestingFramework/DataGenerator/Persist/Curl/AbstractExecutor.php

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,18 @@
1414
abstract class AbstractExecutor implements CurlInterface
1515
{
1616
/**
17-
* Base url.
17+
* Returns Magento base URL. Used as a fallback for other services (eg. WebApi, Backend)
1818
*
1919
* @var string
2020
*/
2121
protected static $baseUrl = null;
2222

2323
/**
24-
* Resolve base url.
25-
*
26-
* @return void
24+
* Returns base URL for Magento instance
25+
* @return string
2726
*/
28-
protected static function resolveBaseUrl()
27+
public function getBaseUrl(): string
2928
{
30-
31-
if ((getenv('MAGENTO_RESTAPI_SERVER_HOST') !== false)
32-
&& (getenv('MAGENTO_RESTAPI_SERVER_HOST') !== '') ) {
33-
self::$baseUrl = getenv('MAGENTO_RESTAPI_SERVER_HOST');
34-
} else {
35-
self::$baseUrl = getenv('MAGENTO_BASE_URL');
36-
}
37-
38-
if ((getenv('MAGENTO_RESTAPI_SERVER_PORT') !== false)
39-
&& (getenv('MAGENTO_RESTAPI_SERVER_PORT') !== '')) {
40-
self::$baseUrl .= ':' . getenv('MAGENTO_RESTAPI_SERVER_PORT');
41-
}
42-
43-
self::$baseUrl = rtrim(self::$baseUrl, '/') . '/';
29+
return getenv('MAGENTO_BASE_URL');
4430
}
4531
}

src/Magento/FunctionalTestingFramework/DataGenerator/Persist/Curl/AdminExecutor.php

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,11 @@ class AdminExecutor extends AbstractExecutor implements CurlInterface
3737
private $response;
3838

3939
/**
40-
* Should executor remove backend_name from api url
40+
* Flag describes whether the request is to Magento Base URL, removes backend_name from api url
4141
* @var boolean
4242
*/
4343
private $removeBackend;
4444

45-
/**
46-
* Backend url.
47-
*
48-
* @var string
49-
*/
50-
private static $adminUrl;
51-
5245
/**
5346
* Constructor.
5447
* @param boolean $removeBackend
@@ -58,15 +51,21 @@ class AdminExecutor extends AbstractExecutor implements CurlInterface
5851
*/
5952
public function __construct($removeBackend)
6053
{
61-
if (!isset(parent::$baseUrl)) {
62-
parent::resolveBaseUrl();
63-
}
64-
self::$adminUrl = parent::$baseUrl . getenv('MAGENTO_BACKEND_NAME') . '/';
6554
$this->removeBackend = $removeBackend;
6655
$this->transport = new CurlTransport();
6756
$this->authorize();
6857
}
6958

59+
/**
60+
* Returns base URL for Magento backend instance
61+
* @return string
62+
*/
63+
public function getBaseUrl(): string
64+
{
65+
$backendHost = getenv('MAGENTO_BACKEND_BASE_URL') ?: parent::getBaseUrl();
66+
return $backendHost . getenv('MAGENTO_BACKEND_NAME') . '/';
67+
}
68+
7069
/**
7170
* Authorize admin on backend.
7271
*
@@ -76,11 +75,11 @@ public function __construct($removeBackend)
7675
private function authorize()
7776
{
7877
// Perform GET to backend url so form_key is set
79-
$this->transport->write(self::$adminUrl, [], CurlInterface::GET);
78+
$this->transport->write($this->getBaseUrl(), [], CurlInterface::GET);
8079
$this->read();
8180

8281
// Authenticate admin user
83-
$authUrl = self::$adminUrl . 'admin/auth/login/';
82+
$authUrl = $this->getBaseUrl() . 'admin/auth/login/';
8483
$data = [
8584
'login[username]' => getenv('MAGENTO_ADMIN_USERNAME'),
8685
'login[password]' => getenv('MAGENTO_ADMIN_PASSWORD'),
@@ -119,10 +118,10 @@ private function setFormKey()
119118
public function write($url, $data = [], $method = CurlInterface::POST, $headers = [])
120119
{
121120
$url = ltrim($url, "/");
122-
$apiUrl = self::$adminUrl . $url;
121+
$apiUrl = $this->getBaseUrl() . $url;
123122

124123
if ($this->removeBackend) {
125-
$apiUrl = parent::$baseUrl . $url;
124+
$apiUrl = parent::getBaseUrl() . $url;
126125
}
127126

128127
if ($this->formKey) {

0 commit comments

Comments
 (0)