Skip to content

Commit 66d8fde

Browse files
authored
Merge pull request #6580 from magento-lynx/MC-39898
[lynx] MC-39898: Stabilize Integration Tests
2 parents bfd1cb9 + ef6729b commit 66d8fde

File tree

459 files changed

+1472
-1942
lines changed

Some content is hidden

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

459 files changed

+1472
-1942
lines changed

dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
use Magento\Framework\App\Response\Http as HttpResponse;
1919

2020
/**
21+
* Set of methods useful for performing requests to Controllers.
22+
*
2123
* @SuppressWarnings(PHPMD.NumberOfChildren)
2224
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2325
*/
@@ -148,7 +150,7 @@ public function getResponse()
148150
public function assert404NotFound()
149151
{
150152
$this->assertEquals('noroute', $this->getRequest()->getControllerName());
151-
$this->assertContains('404 Not Found', $this->getResponse()->getBody());
153+
$this->assertStringContainsString('404 Not Found', $this->getResponse()->getBody());
152154
}
153155

154156
/**

dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Annotation/AppAreaTest.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,11 @@ public function getTestAppAreaDataProvider()
6262
];
6363
}
6464

65-
/**
66-
*/
6765
public function testGetTestAppAreaWithInvalidArea()
6866
{
6967
$this->expectException(\Magento\Framework\Exception\LocalizedException::class);
70-
7168
$annotations = ['method' => ['magentoAppArea' => ['some_invalid_area']]];
72-
$this->_testCaseMock->expects($this->once())->method('getAnnotations')->willReturn($annotations);
69+
$this->_testCaseMock->expects($this->once())->method('getAnnotations')->will($this->returnValue($annotations));
7370
$this->_object->startTest($this->_testCaseMock);
7471
}
7572

@@ -82,7 +79,7 @@ public function testGetTestAppAreaWithInvalidArea()
8279
public function testStartTestWithDifferentAreaCodes(string $areaCode)
8380
{
8481
$annotations = ['method' => ['magentoAppArea' => [$areaCode]]];
85-
$this->_testCaseMock->expects($this->once())->method('getAnnotations')->willReturn($annotations);
82+
$this->_testCaseMock->expects($this->once())->method('getAnnotations')->will($this->returnValue($annotations));
8683
$this->_applicationMock->expects($this->any())->method('getArea')->willReturn(null);
8784
$this->_applicationMock->expects($this->once())->method('reinitialize');
8885
$this->_applicationMock->expects($this->once())->method('loadArea')->with($areaCode);
@@ -92,19 +89,19 @@ public function testStartTestWithDifferentAreaCodes(string $areaCode)
9289
public function testStartTestPreventDoubleAreaLoadingAfterReinitialization()
9390
{
9491
$annotations = ['method' => ['magentoAppArea' => ['global']]];
95-
$this->_testCaseMock->expects($this->once())->method('getAnnotations')->willReturn($annotations);
96-
$this->_applicationMock->expects($this->at(0))->method('getArea')->willReturn('adminhtml');
92+
$this->_testCaseMock->expects($this->once())->method('getAnnotations')->will($this->returnValue($annotations));
93+
$this->_applicationMock->expects($this->at(0))->method('getArea')->will($this->returnValue('adminhtml'));
9794
$this->_applicationMock->expects($this->once())->method('reinitialize');
98-
$this->_applicationMock->expects($this->at(2))->method('getArea')->willReturn('global');
95+
$this->_applicationMock->expects($this->at(2))->method('getArea')->will($this->returnValue('global'));
9996
$this->_applicationMock->expects($this->never())->method('loadArea');
10097
$this->_object->startTest($this->_testCaseMock);
10198
}
10299

103100
public function testStartTestPreventDoubleAreaLoading()
104101
{
105102
$annotations = ['method' => ['magentoAppArea' => ['adminhtml']]];
106-
$this->_testCaseMock->expects($this->once())->method('getAnnotations')->willReturn($annotations);
107-
$this->_applicationMock->expects($this->once())->method('getArea')->willReturn('adminhtml');
103+
$this->_testCaseMock->expects($this->once())->method('getAnnotations')->will($this->returnValue($annotations));
104+
$this->_applicationMock->expects($this->once())->method('getArea')->will($this->returnValue('adminhtml'));
108105
$this->_applicationMock->expects($this->never())->method('reinitialize');
109106
$this->_applicationMock->expects($this->never())->method('loadArea');
110107
$this->_object->startTest($this->_testCaseMock);

dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Annotation/AppIsolationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,22 @@ public function testStartTestSuite()
4141

4242
/**
4343
* @magentoAppIsolation invalid
44+
*
4445
*/
4546
public function testEndTestIsolationInvalid()
4647
{
4748
$this->expectException(\Magento\Framework\Exception\LocalizedException::class);
48-
4949
$this->_object->endTest($this);
5050
}
5151

5252
/**
5353
* @magentoAppIsolation enabled
5454
* @magentoAppIsolation disabled
55+
*
5556
*/
5657
public function testEndTestIsolationAmbiguous()
5758
{
5859
$this->expectException(\Magento\Framework\Exception\LocalizedException::class);
59-
6060
$this->_object->endTest($this);
6161
}
6262

dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Annotation/DataFixtureTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,9 @@ public static function sampleFixtureTwoRollback()
3939
{
4040
}
4141

42-
/**
43-
*/
4442
public function testConstructorException()
4543
{
4644
$this->expectException(\Magento\Framework\Exception\LocalizedException::class);
47-
4845
new \Magento\TestFramework\Annotation\DataFixture(__DIR__ . '/non_existing_fixture_dir');
4946
}
5047

@@ -100,11 +97,11 @@ public function testDisabledDbIsolation()
10097

10198
/**
10299
* @magentoDataFixture fixture\path\must\not\contain\backslash.php
100+
*
103101
*/
104102
public function testStartTestTransactionRequestInvalidPath()
105103
{
106104
$this->expectException(\Magento\Framework\Exception\LocalizedException::class);
107-
108105
$this->_object->startTestTransactionRequest($this, new \Magento\TestFramework\Event\Param\Transaction());
109106
}
110107

dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Annotation/DbIsolationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,22 @@ public function testStartTestTransactionRequestMethodIsolationDisabled()
6363

6464
/**
6565
* @magentoDbIsolation invalid
66+
*
6667
*/
6768
public function testStartTestTransactionRequestInvalidAnnotation()
6869
{
6970
$this->expectException(\Magento\Framework\Exception\LocalizedException::class);
70-
7171
$this->_object->startTestTransactionRequest($this, new \Magento\TestFramework\Event\Param\Transaction());
7272
}
7373

7474
/**
7575
* @magentoDbIsolation enabled
7676
* @magentoDbIsolation disabled
77+
*
7778
*/
7879
public function testStartTestTransactionRequestAmbiguousAnnotation()
7980
{
8081
$this->expectException(\Magento\Framework\Exception\LocalizedException::class);
81-
8282
$this->_object->startTestTransactionRequest($this, new \Magento\TestFramework\Event\Param\Transaction());
8383
}
8484

dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Bootstrap/MemoryTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,10 @@ protected function tearDown(): void
4343
$this->_object = null;
4444
}
4545

46-
/**
47-
*/
4846
public function testConstructorException()
4947
{
48+
$this->expectExceptionMessage("Activation policy is expected to be a callable.");
5049
$this->expectException(\InvalidArgumentException::class);
51-
$this->expectExceptionMessage('Activation policy is expected to be a callable.');
52-
5350
new \Magento\TestFramework\Bootstrap\Memory($this->_memoryLimit, 'non_existing_callable');
5451
}
5552

@@ -61,8 +58,8 @@ public function testDisplayStats()
6158
$this->once()
6259
)->method(
6360
'printStats'
64-
)->willReturn(
65-
'Dummy Statistics'
61+
)->will(
62+
$this->returnValue('Dummy Statistics')
6663
);
6764
$this->_object->displayStats();
6865
}

dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Bootstrap/SettingsTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,10 @@ protected function tearDown(): void
6161
$this->_object = null;
6262
}
6363

64-
/**
65-
*/
6664
public function testConstructorNonExistingBaseDir()
6765
{
66+
$this->expectExceptionMessage("Base path 'non_existing_dir' has to be an existing directory.");
6867
$this->expectException(\InvalidArgumentException::class);
69-
$this->expectExceptionMessage('Base path \'non_existing_dir\' has to be an existing directory.');
70-
7168
new \Magento\TestFramework\Bootstrap\Settings('non_existing_dir', []);
7269
}
7370

dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/EntityTest.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,10 @@ public function deleteModelSuccessfully()
5050
$this->_model->setId(null);
5151
}
5252

53-
/**
54-
*/
5553
public function testConstructorIrrelevantModelClass()
5654
{
55+
$this->expectExceptionMessage("Class 'stdClass' is irrelevant to the tested model");
5756
$this->expectException(\InvalidArgumentException::class);
58-
$this->expectExceptionMessage('Class \'stdClass\' is irrelevant to the tested model');
59-
6057
new \Magento\TestFramework\Entity($this->_model, [], 'stdClass');
6158
}
6259

@@ -84,24 +81,24 @@ public function testTestCrud($saveCallback, $expectedException = null)
8481
->method('load');
8582
$this->_model->expects($this->atLeastOnce())
8683
->method('save')
87-
->willReturnCallback([$this, $saveCallback]);
84+
->will($this->returnCallback([$this, $saveCallback]));
8885
/* It's important that 'delete' should be always called to guarantee the cleanup */
8986
$this->_model->expects(
9087
$this->atLeastOnce()
9188
)->method(
9289
'delete'
93-
)->willReturnCallback(
94-
[$this, 'deleteModelSuccessfully']
90+
)->will(
91+
$this->returnCallback([$this, 'deleteModelSuccessfully'])
9592
);
9693

97-
$this->_model->expects($this->any())->method('getIdFieldName')->willReturn('id');
94+
$this->_model->expects($this->any())->method('getIdFieldName')->will($this->returnValue('id'));
9895

9996
$test = $this->getMockBuilder(\Magento\TestFramework\Entity::class)
10097
->setMethods(['_getEmptyModel'])
10198
->setConstructorArgs([$this->_model, ['test' => 'test']])
10299
->getMock();
103100

104-
$test->expects($this->any())->method('_getEmptyModel')->willReturn($this->_model);
101+
$test->expects($this->any())->method('_getEmptyModel')->will($this->returnValue($this->_model));
105102
$test->testCrud();
106103
}
107104
}

dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Event/MagentoTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ public function testConstructorDefaultEventManager()
4444

4545
/**
4646
* @dataProvider constructorExceptionDataProvider
47+
*
4748
* @param mixed $eventManager
4849
*/
4950
public function testConstructorException($eventManager)
5051
{
5152
$this->expectException(\Magento\Framework\Exception\LocalizedException::class);
52-
5353
new \Magento\TestFramework\Event\Magento($eventManager);
5454
}
5555

dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Event/PhpUnitTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,9 @@ public function testConstructorDefaultEventManager()
4242
$this->testStartTestSuiteFireEvent();
4343
}
4444

45-
/**
46-
*/
4745
public function testConstructorException()
4846
{
4947
$this->expectException(\Magento\Framework\Exception\LocalizedException::class);
50-
5148
new \Magento\TestFramework\Event\Magento();
5249
}
5350

0 commit comments

Comments
 (0)