Skip to content

Commit 5d6ffcb

Browse files
authored
Merge branch 'develop' into custom-domain-backend
2 parents 942979f + bf2143d commit 5d6ffcb

File tree

21 files changed

+233
-95
lines changed

21 files changed

+233
-95
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"require": {
1212
"php": "7.0.2|7.0.4|~7.0.6|~7.1.0|~7.2.0",
13+
"ext-curl": "*",
1314
"allure-framework/allure-codeception": "~1.2.6",
1415
"codeception/codeception": "~2.3.4",
1516
"consolidation/robo": "^1.0.0",

dev/tests/unit/Magento/FunctionalTestFramework/Suite/Handlers/SuiteObjectHandlerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private function setMockTestAndSuiteParserOutput($testData, $suiteData)
8585
$property->setValue(null);
8686

8787
// clear suite object handler value to inject parsed content
88-
$property = new \ReflectionProperty(SuiteObjectHandler::class, 'SUITE_OBJECT_HANLDER_INSTANCE');
88+
$property = new \ReflectionProperty(SuiteObjectHandler::class, 'instance');
8989
$property->setAccessible(true);
9090
$property->setValue(null);
9191

dev/tests/unit/Magento/FunctionalTestFramework/Suite/SuiteGeneratorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public function testGenerateEmptySuite()
149149
*/
150150
private function setMockTestAndSuiteParserOutput($testData, $suiteData)
151151
{
152-
$property = new \ReflectionProperty(SuiteGenerator::class, 'SUITE_GENERATOR_INSTANCE');
152+
$property = new \ReflectionProperty(SuiteGenerator::class, 'instance');
153153
$property->setAccessible(true);
154154
$property->setValue(null);
155155

@@ -159,7 +159,7 @@ private function setMockTestAndSuiteParserOutput($testData, $suiteData)
159159
$property->setValue(null);
160160

161161
// clear suite object handler value to inject parsed content
162-
$property = new \ReflectionProperty(SuiteObjectHandler::class, 'SUITE_OBJECT_HANLDER_INSTANCE');
162+
$property = new \ReflectionProperty(SuiteObjectHandler::class, 'instance');
163163
$property->setAccessible(true);
164164
$property->setValue(null);
165165

dev/tests/unit/Magento/FunctionalTestFramework/Test/Util/ObjectExtensionUtilTest.php

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace tests\unit\Magento\FunctionalTestFramework\Test\Util;
78

89
use AspectMock\Proxy\Verifier;
@@ -31,26 +32,35 @@ public function setUp()
3132
TestLoggingUtil::getInstance()->setMockLoggingUtil();
3233
}
3334

35+
/**
36+
* After class functionality
37+
* @return void
38+
*/
39+
public static function tearDownAfterClass()
40+
{
41+
TestLoggingUtil::getInstance()->clearMockLoggingUtil();
42+
}
43+
3444
/**
3545
* Tests generating a test that extends another test
3646
* @throws \Exception
3747
*/
3848
public function testGenerateExtendedTest()
3949
{
4050
$mockActions = [
41-
"mockStep" => ["nodeName" => "mockNode", "stepKey" => "mockStep"]
51+
"mockStep" => ["nodeName" => "mockNode", "stepKey" => "mockStep"]
4252
];
4353

4454
$testDataArrayBuilder = new TestDataArrayBuilder();
4555
$mockSimpleTest = $testDataArrayBuilder
4656
->withName('simpleTest')
47-
->withAnnotations(['title'=>[['value' => 'simpleTest']]])
57+
->withAnnotations(['title' => [['value' => 'simpleTest']]])
4858
->withTestActions($mockActions)
4959
->build();
5060

5161
$mockExtendedTest = $testDataArrayBuilder
5262
->withName('extendedTest')
53-
->withAnnotations(['title'=>[['value' => 'extendedTest']]])
63+
->withAnnotations(['title' => [['value' => 'extendedTest']]])
5464
->withTestReference("simpleTest")
5565
->build();
5666

@@ -88,14 +98,14 @@ public function testGenerateExtendedWithHooks()
8898
$testDataArrayBuilder = new TestDataArrayBuilder();
8999
$mockSimpleTest = $testDataArrayBuilder
90100
->withName('simpleTest')
91-
->withAnnotations(['title'=>[['value' => 'simpleTest']]])
101+
->withAnnotations(['title' => [['value' => 'simpleTest']]])
92102
->withBeforeHook($mockBeforeHooks)
93103
->withAfterHook($mockAfterHooks)
94104
->build();
95105

96106
$mockExtendedTest = $testDataArrayBuilder
97107
->withName('extendedTest')
98-
->withAnnotations(['title'=>[['value' => 'extendedTest']]])
108+
->withAnnotations(['title' => [['value' => 'extendedTest']]])
99109
->withTestReference("simpleTest")
100110
->build();
101111

@@ -117,7 +127,7 @@ public function testGenerateExtendedWithHooks()
117127
$this->assertArrayHasKey("mockStepBefore", $testObject->getHooks()['before']->getActions());
118128
$this->assertArrayHasKey("mockStepAfter", $testObject->getHooks()['after']->getActions());
119129
}
120-
130+
121131
/**
122132
* Tests generating a test that extends another test
123133
* @throws \Exception
@@ -158,14 +168,14 @@ public function testExtendingExtendedTest()
158168

159169
$mockSimpleTest = $testDataArrayBuilder
160170
->withName('simpleTest')
161-
->withAnnotations(['title'=>[['value' => 'simpleTest']]])
171+
->withAnnotations(['title' => [['value' => 'simpleTest']]])
162172
->withTestActions()
163173
->withTestReference("anotherTest")
164174
->build();
165175

166176
$mockExtendedTest = $testDataArrayBuilder
167177
->withName('extendedTest')
168-
->withAnnotations(['title'=>[['value' => 'extendedTest']]])
178+
->withAnnotations(['title' => [['value' => 'extendedTest']]])
169179
->withTestReference("simpleTest")
170180
->build();
171181

@@ -347,7 +357,7 @@ private function setMockTestOutput($testData = null, $actionGroupData = null)
347357
$property->setValue(null);
348358

349359
// clear test object handler value to inject parsed content
350-
$property = new \ReflectionProperty(ActionGroupObjectHandler::class, 'ACTION_GROUP_OBJECT_HANDLER');
360+
$property = new \ReflectionProperty(ActionGroupObjectHandler::class, 'instance');
351361
$property->setAccessible(true);
352362
$property->setValue(null);
353363

@@ -358,28 +368,21 @@ private function setMockTestOutput($testData = null, $actionGroupData = null)
358368
)->make();
359369
$instance = AspectMock::double(
360370
ObjectManager::class,
361-
['create' => function ($clazz) use (
362-
$mockDataParser,
363-
$mockActionGroupParser
364-
) {
365-
if ($clazz == TestDataParser::class) {
366-
return $mockDataParser;
371+
[
372+
'create' => function ($className) use (
373+
$mockDataParser,
374+
$mockActionGroupParser
375+
) {
376+
if ($className == TestDataParser::class) {
377+
return $mockDataParser;
378+
}
379+
if ($className == ActionGroupDataParser::class) {
380+
return $mockActionGroupParser;
381+
}
367382
}
368-
if ($clazz == ActionGroupDataParser::class) {
369-
return $mockActionGroupParser;
370-
}
371-
}]
383+
]
372384
)->make();
373385
// bypass the private constructor
374386
AspectMock::double(ObjectManagerFactory::class, ['getObjectManager' => $instance]);
375387
}
376-
377-
/**
378-
* After class functionality
379-
* @return void
380-
*/
381-
public static function tearDownAfterClass()
382-
{
383-
TestLoggingUtil::getInstance()->clearMockLoggingUtil();
384-
}
385388
}

dev/tests/unit/Util/TestLoggingUtil.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class TestLoggingUtil extends Assert
1818
/**
1919
* @var TestLoggingUtil
2020
*/
21-
private static $INSTANCE;
21+
private static $instance;
2222

2323
/**
2424
* @var TestHandler
@@ -40,11 +40,11 @@ private function __construct()
4040
*/
4141
public static function getInstance()
4242
{
43-
if (self::$INSTANCE == null) {
44-
self::$INSTANCE = new TestLoggingUtil();
43+
if (self::$instance == null) {
44+
self::$instance = new TestLoggingUtil();
4545
}
4646

47-
return self::$INSTANCE;
47+
return self::$instance;
4848
}
4949

5050
/**
@@ -61,7 +61,7 @@ public function setMockLoggingUtil()
6161
LoggingUtil::class,
6262
['getLogger' => $testLogger]
6363
)->make();
64-
$property = new \ReflectionProperty(LoggingUtil::class, 'INSTANCE');
64+
$property = new \ReflectionProperty(LoggingUtil::class, 'instance');
6565
$property->setAccessible(true);
6666
$property->setValue($mockLoggingUtil);
6767
}

dev/tests/verification/Resources/SectionReplacementTest.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,7 @@ class SectionReplacementTestCest
6868
$I->click("#stringLiteral1-" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test') . " .Doe" . msq("uniqueData"));
6969
$I->click("#element .1#element .2");
7070
$I->click("#element .1#element .{$data}");
71+
$I->click("(//div[@data-role='slide'])[1]/a[@data-element='link'][contains(@href,'')]");
72+
$I->click("(//div[@data-role='slide'])[1]/a[@data-element='link'][contains(@href,' ')]");
7173
}
7274
}

dev/tests/verification/Resources/functionalSuiteHooks.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class functionalSuiteHooks extends \Codeception\GroupObject
3030

3131
if ($this->preconditionFailure != null) {
3232
//if our preconditions fail, we need to mark all the tests as incomplete.
33-
$e->getTest()->getMetadata()->setIncomplete($this->preconditionFailure);
33+
$e->getTest()->getMetadata()->setIncomplete("SUITE PRECONDITION FAILED:" . PHP_EOL . $this->preconditionFailure);
3434
}
3535
}
3636

dev/tests/verification/TestModule/Section/SampleSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@
1818
<element name="threeOneDuplicateParamElement" type="button" selector="#{{var1}}-{{var2}} .{{var1}} [{{var3}}]" parameterized="true"/>
1919
<element name="timeoutElement" type="button" selector="#foo" timeout="30"/>
2020
<element name="mergeElement" type="button" selector="#unMerge"/>
21+
<element name="anotherTwoParamsElement" type="button" selector="(//div[@data-role='slide'])[{{arg1}}]/a[@data-element='link'][contains(@href,'{{arg2}}')]" parameterized="true"/>
2122
</section>
2223
</sections>

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,8 @@
5050

5151
<click stepKey="selectorReplaceTwoParamElements" selector="{{SampleSection.oneParamElement('1')}}{{SampleSection.oneParamElement('2')}}"/>
5252
<click stepKey="selectorReplaceTwoParamMixedTypes" selector="{{SampleSection.oneParamElement('1')}}{{SampleSection.oneParamElement({$data})}}"/>
53+
54+
<click stepKey="selectorParamWithEmptyString" selector="{{SampleSection.anotherTwoParamsElement('1', '')}}"/>
55+
<click stepKey="selectorParamWithASpace" selector="{{SampleSection.anotherTwoParamsElement('1', ' ')}}"/>
5356
</test>
5457
</tests>

etc/config/codeception.dist.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ settings:
1212
memory_limit: 1024M
1313
extensions:
1414
enabled:
15-
- Codeception\Extension\RunFailed
1615
- Magento\FunctionalTestingFramework\Extension\TestContextExtension
1716
- Magento\FunctionalTestingFramework\Allure\Adapter\MagentoAllureAdapter
1817
config:

src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
use Yandex\Allure\Adapter\Event\StepStartedEvent;
1111
use Yandex\Allure\Adapter\Event\StepFinishedEvent;
1212
use Yandex\Allure\Adapter\Event\StepFailedEvent;
13+
use Yandex\Allure\Adapter\Event\TestCaseFailedEvent;
14+
use Codeception\Event\FailEvent;
1315
use Codeception\Event\SuiteEvent;
1416
use Codeception\Event\StepEvent;
1517

@@ -132,4 +134,18 @@ public function stepAfter(StepEvent $stepEvent = null)
132134
}
133135
$this->getLifecycle()->fire(new StepFinishedEvent());
134136
}
137+
138+
/**
139+
* Override of parent method, fires a TestCaseFailedEvent if a test is marked as incomplete.
140+
*
141+
* @param FailEvent $failEvent
142+
* @return void
143+
*/
144+
public function testIncomplete(FailEvent $failEvent)
145+
{
146+
$event = new TestCaseFailedEvent();
147+
$e = $failEvent->getFail();
148+
$message = $e->getMessage();
149+
$this->getLifecycle()->fire($event->withException($e)->withMessage($message));
150+
}
135151
}

src/Magento/FunctionalTestingFramework/DataGenerator/Persist/CurlHandler.php

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,33 @@ private function resolveUrlReference($urlIn, $entityObjects)
197197
{
198198
$urlOut = $urlIn;
199199
$matchedParams = [];
200+
// Find all the params ({}) references
200201
preg_match_all("/[{](.+?)[}]/", $urlIn, $matchedParams);
201202

202203
if (!empty($matchedParams)) {
203204
foreach ($matchedParams[0] as $paramKey => $paramValue) {
205+
$paramEntityParent = "";
206+
$matchedParent = [];
207+
$dataItem = $matchedParams[1][$paramKey];
208+
// Find all the parent property (Type.key) references, assuming there will be only one
209+
// parent property reference within one param
210+
preg_match_all("/(.+?)\./", $dataItem, $matchedParent);
211+
212+
if (!empty($matchedParent) && !empty($matchedParent[0])) {
213+
$paramEntityParent = $matchedParent[1][0];
214+
$dataItem = preg_replace('/^'.$matchedParent[0][0].'/', '', $dataItem);
215+
}
216+
204217
foreach ($entityObjects as $entityObject) {
205-
$param = $entityObject->getDataByName(
206-
$matchedParams[1][$paramKey],
207-
EntityDataObject::CEST_UNIQUE_VALUE
208-
);
218+
$param = null;
219+
220+
if ($paramEntityParent === "" || $entityObject->getType() == $paramEntityParent) {
221+
$param = $entityObject->getDataByName(
222+
$dataItem,
223+
EntityDataObject::CEST_UNIQUE_VALUE
224+
);
225+
}
226+
209227
if (null !== $param) {
210228
$urlOut = str_replace($paramValue, $param, $urlOut);
211229
continue;

src/Magento/FunctionalTestingFramework/DataGenerator/Persist/OperationDataArrayResolver.php

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ public function __construct($dependentEntities = null)
6666
* @return array
6767
* @throws \Exception
6868
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
69+
* @SuppressWarnings(PHPMD.NPathComplexity)
70+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
6971
*/
7072
public function resolveOperationDataArray($entityObject, $operationMetadata, $operation, $fromArray = false)
7173
{
@@ -134,6 +136,13 @@ public function resolveOperationDataArray($entityObject, $operationMetadata, $op
134136
));
135137
}
136138
} else {
139+
$operationElementProperty = null;
140+
if (strpos($operationElementType, '.') !== false) {
141+
$operationElementComponents = explode('.', $operationElementType);
142+
$operationElementType = $operationElementComponents[0];
143+
$operationElementProperty = $operationElementComponents[1];
144+
}
145+
137146
$entityNamesOfType = $entityObject->getLinkedEntitiesOfType($operationElementType);
138147

139148
// If an element is required by metadata, but was not provided in the entity, throw an exception
@@ -146,12 +155,23 @@ public function resolveOperationDataArray($entityObject, $operationMetadata, $op
146155
));
147156
}
148157
foreach ($entityNamesOfType as $entityName) {
149-
$operationDataSubArray = $this->resolveNonPrimitiveElement(
150-
$entityName,
151-
$operationElement,
152-
$operation,
153-
$fromArray
154-
);
158+
if ($operationElementProperty === null) {
159+
$operationDataSubArray = $this->resolveNonPrimitiveElement(
160+
$entityName,
161+
$operationElement,
162+
$operation,
163+
$fromArray
164+
);
165+
} else {
166+
$linkedEntityObj = $this->resolveLinkedEntityObject($entityName);
167+
$operationDataSubArray = $linkedEntityObj->getDataByName($operationElementProperty, 0);
168+
169+
if ($operationDataSubArray === null) {
170+
throw new \Exception(
171+
sprintf('Property %s not found in entity %s \n', $operationElementProperty, $entityName)
172+
);
173+
}
174+
}
155175

156176
if ($operationElement->getType() == OperationDefinitionObjectHandler::ENTITY_OPERATION_ARRAY) {
157177
$operationDataArray[$operationElement->getKey()][] = $operationDataSubArray;

0 commit comments

Comments
 (0)