Skip to content

Commit c817aea

Browse files
MFTF-33780: Changed loose comparisons into strict
1 parent 6fdd6db commit c817aea

File tree

76 files changed

+229
-223
lines changed

Some content is hidden

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

76 files changed

+229
-223
lines changed

dev/tests/static/Magento/Sniffs/NamingConventions/InterfaceNameSniff.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ public function process(File $sourceFile, $stackPtr)
2929
$declarationLine = $tokens[$stackPtr]['line'];
3030
$suffixLength = strlen(self::INTERFACE_SUFFIX);
3131
// Find first T_STRING after 'interface' keyword in the line and verify it
32-
while ($tokens[$stackPtr]['line'] == $declarationLine) {
33-
if ($tokens[$stackPtr]['type'] == 'T_STRING') {
34-
if (substr($tokens[$stackPtr]['content'], 0 - $suffixLength) != self::INTERFACE_SUFFIX) {
32+
while ($tokens[$stackPtr]['line'] === $declarationLine) {
33+
if ($tokens[$stackPtr]['type'] === 'T_STRING') {
34+
if (substr($tokens[$stackPtr]['content'], 0 - $suffixLength) !== self::INTERFACE_SUFFIX) {
3535
$sourceFile->addError(
3636
'Interface should have name that ends with "Interface" suffix.',
3737
$stackPtr,

dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Persist/OperationDataArrayResolverTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -306,15 +306,15 @@ public function testNestedMetadataArrayOfValue(): void
306306
$callback = function ($name) {
307307
$entityDataObjectBuilder = new EntityDataObjectBuilder();
308308

309-
if ($name == 'childObject1') {
309+
if ($name === 'childObject1') {
310310
return $entityDataObjectBuilder
311311
->withName('childObject1')
312312
->withType('childType')
313313
->withDataFields(['city' => 'Hawkins', 'state' => 'Indiana', 'zip' => '78758'])
314314
->build();
315315
};
316316

317-
if ($name == 'childObject2') {
317+
if ($name === 'childObject2') {
318318
return $entityDataObjectBuilder
319319
->withName('childObject2')
320320
->withType('childType')

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,11 @@ private function setMockTestAndSuiteParserOutput(array $testData, array $suiteDa
113113
->will(
114114
$this->returnCallback(
115115
function ($clazz) use ($mockDataParser, $mockSuiteDataParser) {
116-
if ($clazz == TestDataParser::class) {
116+
if ($clazz === TestDataParser::class) {
117117
return $mockDataParser;
118118
}
119119

120-
if ($clazz == SuiteDataParser::class) {
120+
if ($clazz === SuiteDataParser::class) {
121121
return $mockSuiteDataParser;
122122
}
123123

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -347,13 +347,13 @@ function (
347347
$mockGroupClass,
348348
$objectManager
349349
) {
350-
if ($class == TestDataParser::class) {
350+
if ($class === TestDataParser::class) {
351351
return $mockDataParser;
352352
}
353-
if ($class == SuiteDataParser::class) {
353+
if ($class === SuiteDataParser::class) {
354354
return $mockSuiteDataParser;
355355
}
356-
if ($class == GroupClassGenerator::class) {
356+
if ($class === GroupClassGenerator::class) {
357357
return $mockGroupClass;
358358
}
359359

dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function testGetStepsWithDefaultCase(): void
6161
public function testGetStepsWithCustomArgs(): void
6262
{
6363
$this->setEntityObjectHandlerReturn(function ($entityName) {
64-
if ($entityName == "data2") {
64+
if ($entityName === 'data2') {
6565
return (new EntityDataObjectBuilder())->withDataFields(['field2' => 'testValue2'])->build();
6666
}
6767
});
@@ -128,7 +128,7 @@ public function testGetStepsWithPersistedArgs(): void
128128
public function testGetStepsWithNoFieldArg(): void
129129
{
130130
$this->setEntityObjectHandlerReturn(function ($entityName) {
131-
if ($entityName == "data2") {
131+
if ($entityName === 'data2') {
132132
return (new EntityDataObjectBuilder())->withDataFields(['field2' => 'testValue2'])->build();
133133
}
134134
});
@@ -151,7 +151,7 @@ public function testGetStepsWithNoFieldArg(): void
151151
public function testGetStepsWithNoArgs(): void
152152
{
153153
$this->setEntityObjectHandlerReturn(function ($entityName) {
154-
if ($entityName == "data1") {
154+
if ($entityName === 'data1') {
155155
return (new EntityDataObjectBuilder())->withDataFields(['field1' => 'testValue'])->build();
156156
}
157157
});
@@ -174,7 +174,7 @@ public function testGetStepsWithParameterizedArg(): void
174174
{
175175
// Mock Entity Object Handler
176176
$this->setEntityObjectHandlerReturn(function ($entityName) {
177-
if ($entityName == "data2") {
177+
if ($entityName === 'data2') {
178178
return (new EntityDataObjectBuilder())->withDataFields(['field2' => 'testValue2'])->build();
179179
}
180180
});
@@ -216,7 +216,7 @@ public function testGetStepsWithParameterizedSimpleArg(): void
216216
{
217217
// Mock Entity Object Handler
218218
$this->setEntityObjectHandlerReturn(function ($entityName) {
219-
if ($entityName == "data2") {
219+
if ($entityName === 'data2') {
220220
return (new EntityDataObjectBuilder())->withDataFields(['field2' => 'testValue2'])->build();
221221
}
222222
});

dev/tests/unit/Util/SuiteDataArrayBuilder.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ private function appendEntriesToSuiteContents($currentContents, $type, $contents
181181
*/
182182
public function withAfterHook($afterHook = null)
183183
{
184-
if ($afterHook == null) {
184+
if ($afterHook === null) {
185185
$this->afterHook = [$this->testActionAfterName => [
186186
ActionObjectExtractor::NODE_NAME => $this->testActionType,
187187
ActionObjectExtractor::TEST_STEP_MERGE_KEY => $this->testActionAfterName
@@ -202,7 +202,7 @@ public function withAfterHook($afterHook = null)
202202
*/
203203
public function withBeforeHook($beforeHook = null)
204204
{
205-
if ($beforeHook == null) {
205+
if ($beforeHook === null) {
206206
$this->beforeHook = [$this->testActionBeforeName => [
207207
ActionObjectExtractor::NODE_NAME => $this->testActionType,
208208
ActionObjectExtractor::TEST_STEP_MERGE_KEY => $this->testActionBeforeName

dev/tests/unit/Util/TestDataArrayBuilder.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function withName($name)
109109
*/
110110
public function withAnnotations($annotations = null)
111111
{
112-
if ($annotations == null) {
112+
if ($annotations === null) {
113113
$this->annotations = ['group' => [['value' => 'test']]];
114114
} else {
115115
$this->annotations = $annotations;
@@ -126,7 +126,7 @@ public function withAnnotations($annotations = null)
126126
*/
127127
public function withBeforeHook($beforeHook = null)
128128
{
129-
if ($beforeHook == null) {
129+
if ($beforeHook === null) {
130130
$this->beforeHook = [$this->testActionBeforeName => [
131131
ActionObjectExtractor::NODE_NAME => $this->testActionType,
132132
ActionObjectExtractor::TEST_STEP_MERGE_KEY => $this->testActionBeforeName
@@ -146,7 +146,7 @@ public function withBeforeHook($beforeHook = null)
146146
*/
147147
public function withAfterHook($afterHook = null)
148148
{
149-
if ($afterHook == null) {
149+
if ($afterHook === null) {
150150
$this->afterHook = [$this->testActionAfterName => [
151151
ActionObjectExtractor::NODE_NAME => $this->testActionType,
152152
ActionObjectExtractor::TEST_STEP_MERGE_KEY => $this->testActionAfterName
@@ -167,7 +167,7 @@ public function withAfterHook($afterHook = null)
167167
*/
168168
public function withFailedHook($failedHook = null)
169169
{
170-
if ($failedHook == null) {
170+
if ($failedHook === null) {
171171
$this->failedHook = [$this->testActionFailedName => [
172172
ActionObjectExtractor::NODE_NAME => $this->testActionType,
173173
ActionObjectExtractor::TEST_STEP_MERGE_KEY => $this->testActionFailedName
@@ -188,7 +188,7 @@ public function withFailedHook($failedHook = null)
188188
*/
189189
public function withTestActions($actions = null)
190190
{
191-
if ($actions == null) {
191+
if ($actions === null) {
192192
$this->testActions = [$this->testTestActionName => [
193193
ActionObjectExtractor::NODE_NAME => $this->testActionType,
194194
ActionObjectExtractor::TEST_STEP_MERGE_KEY => $this->testTestActionName
@@ -207,7 +207,7 @@ public function withTestActions($actions = null)
207207
*/
208208
public function withFileName($filename = null)
209209
{
210-
if ($filename == null) {
210+
if ($filename === null) {
211211
$this->filename =
212212
"/magento2-functional-testing-framework/dev/tests/verification/TestModule/Test/BasicFunctionalTest.xml";
213213
} else {

dev/tests/unit/Util/TestLoggingUtil.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private function __construct()
4040
*/
4141
public static function getInstance(): TestLoggingUtil
4242
{
43-
if (self::$instance == null) {
43+
if (self::$instance === null) {
4444
self::$instance = new TestLoggingUtil();
4545
}
4646
return self::$instance;

dev/tests/verification/Tests/ResilientGenerationTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function testGenerateAllSuites()
123123
SuiteGenerator::getInstance()->generateAllSuites($testManifest);
124124

125125
foreach (SuiteTestReferences::$data as $groupName => $expectedContents) {
126-
if (substr($groupName, 0, 11) != 'NotGenerate') {
126+
if (substr($groupName, 0, 11) !== 'NotGenerate') {
127127
// Validate Yaml file updated
128128
$yml = Yaml::parse(file_get_contents(self::CONFIG_YML_FILE));
129129
$this->assertArrayHasKey($groupName, $yml['groups']);
@@ -175,7 +175,7 @@ function () use ($groupName) {
175175
);
176176
}
177177

178-
if (substr($groupName, 0, 11) != 'NotGenerate') {
178+
if (substr($groupName, 0, 11) !== 'NotGenerate') {
179179
// Validate Yaml file updated
180180
$yml = Yaml::parse(file_get_contents(self::CONFIG_YML_FILE));
181181
$this->assertArrayHasKey($groupName, $yml['groups']);
@@ -199,7 +199,7 @@ function () use ($groupName) {
199199
}
200200

201201
// Validate log message
202-
if (substr($groupName, 0, 11) != 'NotGenerate'
202+
if (substr($groupName, 0, 11) !== 'NotGenerate'
203203
&& !in_array($groupName, array_keys(self::$exceptionGrpLogs))) {
204204
$type = 'info';
205205
$message = '/suite generated/';

etc/config/command.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
// Token returned will be null if the token we passed in is invalid
2020
$tokenFromMagento = $tokenModel->loadByToken($tokenPassedIn)->getToken();
21-
if (!empty($tokenFromMagento) && ($tokenFromMagento == $tokenPassedIn)) {
21+
if (!empty($tokenFromMagento) && ($tokenFromMagento === $tokenPassedIn)) {
2222
$php = PHP_BINDIR ? PHP_BINDIR . '/php' : 'php';
2323
$magentoBinary = $php . ' -f ../../../../bin/magento';
2424
$valid = validateCommand($magentoBinary, $command);
@@ -52,7 +52,7 @@
5252

5353
$exitCode = $process->getExitCode();
5454

55-
if ($exitCode == 0 || $idleTimeout) {
55+
if ($process->isSuccessful() || $idleTimeout) {
5656
http_response_code(202);
5757
} else {
5858
http_response_code(500);

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class MagentoAllureAdapter extends AllureCodeception
6363
*/
6464
private function getGroup()
6565
{
66-
if ($this->options['groups'] != null) {
66+
if ($this->options['groups'] !== null) {
6767
return $this->options['groups'][0];
6868
}
6969
return null;
@@ -79,7 +79,7 @@ public function suiteBefore(SuiteEvent $suiteEvent)
7979
{
8080
$changeSuiteEvent = $suiteEvent;
8181

82-
if ($this->getGroup() != null) {
82+
if ($this->getGroup() !== null) {
8383
$suite = $suiteEvent->getSuite();
8484
$suiteName = ($suite->getName()) . "\\" . $this->sanitizeGroupName($this->getGroup());
8585

@@ -414,8 +414,8 @@ private function removeAttachments($step, $testFailed)
414414
private function formatAllureTestClassName($test)
415415
{
416416
if ($this->getGroup() !== null) {
417-
foreach ($test->getLabels() as $name => $label) {
418-
if ($label->getName() == 'testClass') {
417+
foreach ($test->getLabels() as $label) {
418+
if ($label->getName() === 'testClass') {
419419
$originalTestClass = $this->sanitizeTestClassLabel($label->getValue());
420420
call_user_func(\Closure::bind(
421421
function () use ($label, $originalTestClass) {

src/Magento/FunctionalTestingFramework/Allure/AllureHelper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static function addAttachmentToLastStep($data, $caption): void
5050
$rootStep = Allure::lifecycle()->getStepStorage()->getLast();
5151
$trueLastStep = array_last($rootStep->getSteps());
5252

53-
if ($trueLastStep == null) {
53+
if ($trueLastStep === null) {
5454
// Nothing to attach to; do not fire off allure event
5555
return;
5656
}

src/Magento/FunctionalTestingFramework/Codeception/Subscriber/Console.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function beforeStep(StepEvent $e)
119119
}
120120

121121
$metaStep = $e->getStep()->getMetaStep();
122-
if ($metaStep and $this->metaStep != $metaStep) {
122+
if ($metaStep and $this->metaStep !== $metaStep) {
123123
$this->message(' ' . $metaStep->getPrefix())
124124
->style('bold')
125125
->append($metaStep->__toString())
@@ -158,7 +158,7 @@ public function afterStep(StepEvent $e)
158158
*/
159159
private function printStepKeys(Step $step)
160160
{
161-
if ($step instanceof Comment and $step->__toString() == '') {
161+
if ($step instanceof Comment and $step->__toString() === '') {
162162
return; // don't print empty comments
163163
}
164164

src/Magento/FunctionalTestingFramework/Composer/ComposerInstall.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function isInstalledPackageOfType($packageName, $packageType)
5050
{
5151
/** @var CompletePackageInterface $package */
5252
foreach ($this->getLocker()->getLockedRepository()->getPackages() as $package) {
53-
if (($package->getName() == $packageName) && ($package->getType() == $packageType)) {
53+
if (($package->getName() === $packageName) && ($package->getType() === $packageType)) {
5454
return true;
5555
}
5656
}
@@ -67,7 +67,7 @@ public function getInstalledTestPackages()
6767
$packages = [];
6868
/** @var CompletePackageInterface $package */
6969
foreach ($this->getLocker()->getLockedRepository()->getPackages() as $package) {
70-
if ($package->getType() == self::TEST_MODULE_PACKAGE_TYPE) {
70+
if ($package->getType() === self::TEST_MODULE_PACKAGE_TYPE) {
7171
$packages[$package->getName()] = [
7272
self::PACKAGE_NAME => $package->getName(),
7373
self::PACKAGE_TYPE => $package->getType(),

src/Magento/FunctionalTestingFramework/Composer/ComposerPackage.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function getSuggestedMagentoModules()
116116
*/
117117
public function isMftfTestPackage()
118118
{
119-
return ($this->getType() == self::TEST_MODULE_PACKAGE_TYPE) ? true : false;
119+
return $this->getType() === self::TEST_MODULE_PACKAGE_TYPE;
120120
}
121121

122122
/**

src/Magento/FunctionalTestingFramework/Config/Converter.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected function convertXml($elements)
9191

9292
foreach ($elements as $element) {
9393
if ($element instanceof \DOMElement) {
94-
if ($element->getAttribute('remove') == 'true') {
94+
if ($element->getAttribute('remove') === 'true') {
9595
// Remove element
9696
continue;
9797
}
@@ -119,7 +119,7 @@ protected function convertXml($elements)
119119
} elseif (!empty($elementData)) {
120120
$result[$element->nodeName][] = $elementData;
121121
}
122-
} elseif ($element->nodeType == XML_TEXT_NODE && trim($element->nodeValue) != '') {
122+
} elseif ($element->nodeType === XML_TEXT_NODE && trim($element->nodeValue) !== '') {
123123
return ['value' => $element->nodeValue];
124124
}
125125
}
@@ -156,9 +156,9 @@ protected function getElementKey(\DOMElement $element)
156156
protected function isKeyAttribute(\DOMElement $element, \DOMAttr $attribute)
157157
{
158158
if (isset($this->idAttributes[$element->nodeName])) {
159-
return $attribute->name == $this->idAttributes[$element->nodeName];
159+
return $attribute->name === $this->idAttributes[$element->nodeName];
160160
} else {
161-
return $attribute->name == self::NAME_ATTRIBUTE;
161+
return $attribute->name === self::NAME_ATTRIBUTE;
162162
}
163163
}
164164

@@ -174,7 +174,7 @@ protected function getAttributes(\DOMElement $element)
174174
if ($element->hasAttributes()) {
175175
/** @var \DomAttr $attribute */
176176
foreach ($element->attributes as $attribute) {
177-
if (trim($attribute->nodeValue) != '' && !$this->isKeyAttribute($element, $attribute)) {
177+
if (trim($attribute->nodeValue) !== '' && !$this->isKeyAttribute($element, $attribute)) {
178178
$attributes[$attribute->nodeName] = $this->castNumeric($attribute->nodeValue);
179179
}
180180
}

src/Magento/FunctionalTestingFramework/Config/Converter/Dom/Flat.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ protected function getNodeAttributes(\DOMNode $node)
4141
$attributes = $node->attributes ?: [];
4242
/** @var \DOMNode $attribute */
4343
foreach ($attributes as $attribute) {
44-
if ($attribute->nodeType == XML_ATTRIBUTE_NODE) {
44+
if ($attribute->nodeType === XML_ATTRIBUTE_NODE) {
4545
$result[$attribute->nodeName] = $attribute->nodeValue;
4646
}
4747
}
@@ -77,7 +77,7 @@ public function convert(\DOMNode $source, $basePath = '')
7777
$value = [];
7878
/** @var \DOMNode $node */
7979
foreach ($source->childNodes as $node) {
80-
if ($node->nodeType == XML_ELEMENT_NODE) {
80+
if ($node->nodeType === XML_ELEMENT_NODE) {
8181
$nodeName = $node->nodeName;
8282
$nodePath = $basePath . '/' . $nodeName;
8383

@@ -107,8 +107,8 @@ public function convert(\DOMNode $source, $basePath = '')
107107
} else {
108108
$value[$nodeName] = $nodeData;
109109
}
110-
} elseif ($node->nodeType == XML_CDATA_SECTION_NODE
111-
|| ($node->nodeType == XML_TEXT_NODE && trim($node->nodeValue) != '')
110+
} elseif ($node->nodeType === XML_CDATA_SECTION_NODE
111+
|| ($node->nodeType === XML_TEXT_NODE && trim($node->nodeValue) !== '')
112112
) {
113113
$value = $node->nodeValue;
114114
break;

0 commit comments

Comments
 (0)