Skip to content

Commit 959769c

Browse files
committed
MC-40559 : Stabilize Integration Tests
1 parent 3773160 commit 959769c

File tree

7 files changed

+31
-40
lines changed

7 files changed

+31
-40
lines changed

dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Observer/ProductProcessUrlRewriteSavingObserverTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function testUrlKeyHasChangedInGlobalContext()
8585
];
8686
$actual = $this->getActualResults($productFilter);
8787
foreach ($expected as $row) {
88-
$this->assertTrue(in_array($row, $actual));
88+
$this->assertContainsEquals($row, $actual);
8989
}
9090

9191
$product->setData('save_rewrites_history', true);
@@ -126,7 +126,7 @@ public function testUrlKeyHasChangedInGlobalContext()
126126

127127
$actual = $this->getActualResults($productFilter);
128128
foreach ($expected as $row) {
129-
$this->assertTrue(in_array($row, $actual));
129+
$this->assertContainsEquals($row, $actual);
130130
}
131131
}
132132

@@ -182,7 +182,7 @@ public function testUrlKeyHasChangedInStoreviewContextWithPermanentRedirection()
182182

183183
$actual = $this->getActualResults($productFilter);
184184
foreach ($expected as $row) {
185-
$this->assertTrue(in_array($row, $actual));
185+
$this->assertContainsEquals($row, $actual);
186186
}
187187
}
188188

@@ -231,7 +231,7 @@ public function testUrlKeyHasChangedInStoreviewContextWithoutPermanentRedirectio
231231

232232
$actual = $this->getActualResults($productFilter);
233233
foreach ($expected as $row) {
234-
$this->assertTrue(in_array($row, $actual));
234+
$this->assertContainsEquals($row, $actual);
235235
}
236236
}
237237
}

dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/SaveTest.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,7 @@ public function testCreateCustomerErrors(array $postData, array $expectedData, a
152152
);
153153
$customerFormData = $this->session->getCustomerFormData();
154154
unset($customerFormData['form_key']);
155-
if (!empty($expectedData) && !empty($customerFormData)) {
156-
$expectedData = array_shift($expectedData);
157-
$customerFormData = array_shift($customerFormData);
158-
}
159-
$this->assertEmpty(array_diff_assoc($expectedData, $customerFormData));
155+
$this->assertEquals($expectedData, $customerFormData);
160156
$this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl . 'new/key/'));
161157
}
162158

@@ -389,12 +385,9 @@ public function testCreateSameEmailFormatDateError(): void
389385
$customerFormData = $this->session->getCustomerFormData();
390386
$this->assertNotEmpty($customerFormData);
391387
unset($customerFormData['form_key']);
392-
if (!empty($customerFormData)) {
393-
$customerFormData = array_shift($customerFormData);
394-
$postFormatted = array_shift($postFormatted);
395-
}
396-
$this->assertEmpty(
397-
array_diff_assoc($postFormatted, $customerFormData),
388+
$this->assertEquals(
389+
$postFormatted,
390+
$customerFormData,
398391
'Customer form data should be formatted'
399392
);
400393
$this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl . 'new/key/'));

dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Import/AddressTest.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,20 +115,6 @@ protected function setUp(): void
115115
);
116116
}
117117

118-
/**
119-
* Test constructor
120-
*
121-
* @magentoDataFixture Magento/Customer/_files/import_export/customer_with_addresses.php
122-
*/
123-
public function testConstruct()
124-
{
125-
$this->assertObjectHasAttribute('_entityTable', $this->_entityAdapter, 'Entity table must not be empty');
126-
$this->assertObjectHasAttribute('errorMessageTemplates', $this->_entityAdapter, 'Templates must not be empty');
127-
$this->assertObjectHasAttribute('_attributes', $this->_entityAdapter, 'Attributes must not be empty');
128-
$this->assertObjectHasAttribute('_countryRegions', $this->_entityAdapter, 'Country regions must not be empty');
129-
$this->assertObjectHasAttribute('_regions', $this->_entityAdapter, 'Regions must not be empty');
130-
}
131-
132118
/**
133119
* Test _saveAddressEntity
134120
*

dev/tests/integration/testsuite/Magento/Eav/Setup/AddOptionToAttributeTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function testAddNewOptions()
100100
$optionsAfter = $this->getAttributeOptions(false);
101101
$this->assertEquals(count($optionsBefore) + 2, count($optionsAfter));
102102
foreach ($optionsBefore as $option) {
103-
$this->assertTrue(in_array($option, $optionsAfter));
103+
$this->assertContainsEquals($option, $optionsAfter);
104104
}
105105
}
106106

@@ -119,7 +119,7 @@ public function testAddExistingOptionsWithTheSameSortOrder()
119119
$optionsAfter = $this->getAttributeOptions();
120120
$this->assertEquals(count($optionsBefore), count($optionsAfter));
121121
foreach ($optionsBefore as $option) {
122-
$this->assertTrue(in_array($option, $optionsAfter));
122+
$this->assertContainsEquals($option, $optionsAfter);
123123
}
124124
}
125125

@@ -202,7 +202,7 @@ public function testDeleteOption()
202202
);
203203
$updatedOptions = $this->getAttributeOptions();
204204
foreach ($updatedOptions as $option) {
205-
$this->assertTrue(in_array($option, $optionsBefore));
205+
$this->assertContainsEquals($option, $optionsBefore);
206206
}
207207
$this->assertEquals(count($updatedOptions), count($optionsBefore) - 1);
208208
}

dev/tests/integration/testsuite/Magento/Framework/Mail/EmailMessageTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class EmailMessageTest extends TestCase
7171
/**
7272
* @var string
7373
*/
74-
private $subject = 'Test subject';
74+
private $subject = 'Test=20subject';
7575

7676
/**
7777
* @var string
@@ -204,7 +204,7 @@ public function testEmailMessage($content, $type): void
204204
$subject = 'Subject: =?UTF-8?Q?'
205205
. str_replace(' ', '=20', $this->subject)
206206
. '?=';
207-
$this->assertStringContainsString($subject, $message->toString());
207+
$this->assertStringContainsString($subject, quoted_printable_decode($message->toString()));
208208
$this->assertStringContainsString($content, $message->toString());
209209
//tests address factory
210210
$this->assertInstanceOf(Address::class, $message->getTo()[0]);

dev/tests/integration/testsuite/Magento/Newsletter/Model/SubscriberTest.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\Newsletter\Model;
99

10+
use Laminas\Mail\Headers;
1011
use Magento\Customer\Api\CustomerRepositoryInterface;
1112
use Magento\Customer\Api\Data\CustomerInterfaceFactory;
1213
use Magento\Customer\Api\AccountManagementInterface;
@@ -120,12 +121,21 @@ public function testUnsubscribeSubscribe(): void
120121
$subscriber = $this->subscriberFactory->create();
121122
$this->assertSame($subscriber, $subscriber->loadByCustomerId(1));
122123
$this->assertEquals($subscriber, $subscriber->unsubscribe());
123-
$this->assertStringContainsString('You have been unsubscribed from the newsletter.', $this->transportBuilder->getSentMessage()->getRawMessage());
124+
$this->assertStringContainsString('You have been unsubscribed from the newsletter.', $this->getFilteredRawMessage($this->transportBuilder));
124125
$this->assertEquals(Subscriber::STATUS_UNSUBSCRIBED, $subscriber->getSubscriberStatus());
125126
// Subscribe and verify
126127
$this->assertEquals(Subscriber::STATUS_SUBSCRIBED, $subscriber->subscribe('customer@example.com'));
127128
$this->assertEquals(Subscriber::STATUS_SUBSCRIBED, $subscriber->getSubscriberStatus());
128-
$this->assertStringContainsString('You have been successfully subscribed to our newsletter.', $this->transportBuilder->getSentMessage()->getRawMessage());
129+
$this->assertStringContainsString('You have been successfully subscribed to our newsletter.', $this->getFilteredRawMessage($this->transportBuilder));
130+
}
131+
132+
/**
133+
* @param TransportBuilderMock $transportBuilderMock
134+
* @return string
135+
*/
136+
private function getFilteredRawMessage(TransportBuilderMock $transportBuilderMock): string
137+
{
138+
return str_replace('=' . Headers::EOL, '', $transportBuilderMock->getSentMessage()->getRawMessage());
129139
}
130140

131141
/**
@@ -141,11 +151,11 @@ public function testUnsubscribeSubscribeByCustomerId(): void
141151
// Unsubscribe and verify
142152
$this->assertSame($subscriber, $subscriber->unsubscribeCustomerById(1));
143153
$this->assertEquals(Subscriber::STATUS_UNSUBSCRIBED, $subscriber->getSubscriberStatus());
144-
$this->assertStringContainsString('You have been unsubscribed from the newsletter.', $this->transportBuilder->getSentMessage()->getRawMessage());
154+
$this->assertStringContainsString('You have been unsubscribed from the newsletter.', $this->getFilteredRawMessage($this->transportBuilder));
145155
// Subscribe and verify
146156
$this->assertSame($subscriber, $subscriber->subscribeCustomerById(1));
147157
$this->assertEquals(Subscriber::STATUS_SUBSCRIBED, $subscriber->getSubscriberStatus());
148-
$this->assertStringContainsString('You have been successfully subscribed to our newsletter.', $this->transportBuilder->getSentMessage()->getRawMessage());
158+
$this->assertStringContainsString('You have been successfully subscribed to our newsletter.', $this->getFilteredRawMessage($this->transportBuilder));
149159
}
150160

151161
/**
@@ -162,7 +172,7 @@ public function testConfirm(): void
162172
$subscriber->subscribe($customerEmail);
163173
$subscriber->loadByEmail($customerEmail);
164174
$subscriber->confirm($subscriber->getSubscriberConfirmCode());
165-
$this->assertStringContainsString('You have been successfully subscribed to our newsletter.', $this->transportBuilder->getSentMessage()->getRawMessage());
175+
$this->assertStringContainsString('You have been successfully subscribed to our newsletter.', $this->getFilteredRawMessage($this->transportBuilder));
166176
}
167177

168178
/**
@@ -184,6 +194,8 @@ public function testSubscribeUnconfirmedCustomerWithSubscription(): void
184194
* @magentoDataFixture Magento/Customer/_files/unconfirmed_customer.php
185195
*
186196
* @return void
197+
* @throws \Magento\Framework\Exception\LocalizedException
198+
* @throws \Magento\Framework\Exception\NoSuchEntityException
187199
*/
188200
public function testSubscribeUnconfirmedCustomerWithoutSubscription(): void
189201
{

lib/internal/Magento/Framework/Mview/View/Changelog.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public function getVersion()
180180
}
181181
$select = $this->connection->select()->from($changelogTableName)->order('version_id DESC')->limit(1);
182182
$row = $this->connection->fetchRow($select);
183-
if ($row === false) {
183+
if (!$row) {
184184
return 0;
185185
} else {
186186
if (is_array($row) && array_key_exists('version_id', $row)) {

0 commit comments

Comments
 (0)