Skip to content

Commit 68e5a7b

Browse files
authored
Merge pull request #5649 from magento-trigger/MC-33909
[Php 7.4] integration tests fix
2 parents 81e3240 + 0849dcb commit 68e5a7b

File tree

33 files changed

+147
-111
lines changed

33 files changed

+147
-111
lines changed

app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Save.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public function __construct(
5454

5555
/**
5656
* Save creditmemo
57+
*
5758
* We can save only new creditmemo. Existing creditmemos are not editable
5859
*
5960
* @return \Magento\Backend\Model\View\Result\Redirect|\Magento\Backend\Model\View\Result\Forward
@@ -104,7 +105,8 @@ public function execute()
104105
\Magento\Sales\Api\CreditmemoManagementInterface::class
105106
);
106107
$creditmemo->getOrder()->setCustomerNoteNotify(!empty($data['send_email']));
107-
$creditmemoManagement->refund($creditmemo, (bool)$data['do_offline']);
108+
$doOffline = isset($data['do_offline']) ? (bool)$data['do_offline'] : false;
109+
$creditmemoManagement->refund($creditmemo, $doOffline);
108110

109111
if (!empty($data['send_email'])) {
110112
$this->creditmemoSender->send($creditmemo);

dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTreeTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ public function testGetParentIds()
120120
$this->assertEmpty($this->_model->getParentIds());
121121
$this->_model->unsetData();
122122
$this->_model->load(4);
123-
$this->assertTrue(in_array(3, $this->_model->getParentIds()));
124-
$this->assertFalse(in_array(4, $this->_model->getParentIds()));
123+
$this->assertContainsEquals(3, $this->_model->getParentIds());
124+
$this->assertNotContainsEquals(4, $this->_model->getParentIds());
125125
}
126126

127127
public function testGetChildren()
@@ -173,9 +173,9 @@ public function testGetLevel()
173173
public function testGetAnchorsAbove()
174174
{
175175
$this->_model->load(4);
176-
$this->assertTrue(in_array(3, $this->_model->getAnchorsAbove()));
176+
$this->assertContainsEquals(3, $this->_model->getAnchorsAbove());
177177
$this->_model->load(5);
178-
$this->assertTrue(in_array(4, $this->_model->getAnchorsAbove()));
178+
$this->assertContainsEquals(4, $this->_model->getAnchorsAbove());
179179
}
180180

181181
public function testGetParentCategories()

dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ public function testSaveCustomOptions(string $importFile, string $sku, int $expe
366366
$actualOptions = $actualData['options'];
367367
sort($expectedOptions);
368368
sort($actualOptions);
369-
$this->assertEquals($expectedOptions, $actualOptions);
369+
$this->assertSame($expectedOptions, $actualOptions);
370370

371371
// assert of options data
372372
$this->assertCount(count($expectedData['data']), $actualData['data']);
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
sku,website_code,store_view_code,attribute_set_code,product_type,name,description,short_description,weight,product_online,visibility,product_websites,categories,price,special_price,special_price_from_date,special_price_to_date,tax_class_name,url_key,meta_title,meta_keywords,meta_description,base_image,base_image_label,small_image,small_image_label,thumbnail_image,thumbnail_image_label,additional_images,additional_image_labels,configurable_variation_labels,configurable_variations,bundle_price_type,bundle_sku_type,bundle_weight_type,bundle_values,downloadble_samples,downloadble_links,associated_skus,related_skus,crosssell_skus,upsell_skus,custom_options,additional_attributes,manage_stock,is_in_stock,qty,out_of_stock_qty,is_qty_decimal,allow_backorders,min_cart_qty,max_cart_qty,notify_on_stock_below,qty_increments,enable_qty_increments,is_decimal_divided,new_from_date,new_to_date,gift_message_available,created_at,updated_at,custom_design,custom_design_from,custom_design_to,custom_layout_update,page_layout,product_options_container,msrp_price,msrp_display_actual_price_type,map_enabled
2-
simple,base,,Default,simple,New Product,,,9,1,"Catalog, Search",base,,10,,,,Taxable Goods,new-product,,,,,,,,,,,,,,,,,,,,,,,,"name=Test Field Title,type=field,required=1,sku=1-text,price=0.000,price_type=fixed,max_characters=10|name=Test Date and Time Title,type=date_time,required=1,price=2.0000,sku=2-date|name=Test Select,type=drop_down,required=1,price=3.0000,option_title=Option 1,sku=3-1-select|name=Test Select,type=drop_down,required=1,price=3.0000,option_title=Option 2,sku=3-2-select|name=Test Radio,type=radio,required=1,price=3.0000,option_title=Option 1,sku=4-1-radio|name=Test Radio,type=radio,required=1,price=3.0000,option_title=Option 2,sku=4-2-radio",,1,1,999,0,0,0,1,10000,1,1,0,0,,,,,,,,,,,Block after Info Column,,,
2+
simple,base,,Default,simple,New Product,,,9,1,"Catalog, Search",base,,10,,,,Taxable Goods,new-product,,,,,,,,,,,,,,,,,,,,,,,,"name=Test Field Title,type=field,required=1,sku=1-text,price=0.000000,price_type=fixed,max_characters=10|name=Test Date and Time Title,type=date_time,required=1,price=2.000000,sku=2-date|name=Test Select,type=drop_down,required=1,price=3.000000,option_title=Option 1,sku=3-1-select|name=Test Select,type=drop_down,required=1,price=3.000000,option_title=Option 2,sku=3-2-select|name=Test Radio,type=radio,required=1,price=3.000000,option_title=Option 1,sku=4-1-radio|name=Test Radio,type=radio,required=1,price=3.000000,option_title=Option 2,sku=4-2-radio",,1,1,999,0,0,0,1,10000,1,1,0,0,,,,,,,,,,,Block after Info Column,,,

dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/FullTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ public function testGetIndexData()
5151
$productsIds = array_keys($result);
5252
foreach ($productsIds as $productId) {
5353
$product = $productRepository->getById($productId);
54-
$this->assertContains($product->getVisibility(), $allowedVisibility);
55-
$this->assertContains($product->getStatus(), $allowedStatuses);
54+
$this->assertContainsEquals($product->getVisibility(), $allowedVisibility);
55+
$this->assertContainsEquals($product->getStatus(), $allowedStatuses);
5656
}
5757

5858
$expectedData = $this->getExpectedIndexData();

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
@@ -159,11 +159,7 @@ public function testCreateCustomerErrors(array $postData, array $expectedData, a
159159
$customerFormData = $this->session->getCustomerFormData();
160160
$this->assertNotEmpty($customerFormData);
161161
unset($customerFormData['form_key']);
162-
if (!empty($expectedData) && !empty($customerFormData)) {
163-
$expectedData = array_shift($expectedData);
164-
$customerFormData = array_shift($customerFormData);
165-
}
166-
$this->assertEmpty(array_diff_assoc($expectedData, $customerFormData));
162+
$this->assertEquals($expectedData, $customerFormData);
167163
$this->assertRedirect($this->stringContains($this->baseControllerUrl . 'new/key/'));
168164
}
169165

@@ -387,12 +383,9 @@ public function testCreateSameEmailFormatDateError(): void
387383
$customerFormData = $this->session->getCustomerFormData();
388384
$this->assertNotEmpty($customerFormData);
389385
unset($customerFormData['form_key']);
390-
if (!empty($customerFormData)) {
391-
$customerFormData = array_shift($customerFormData);
392-
$postFormatted = array_shift($postFormatted);
393-
}
394-
$this->assertEmpty(
395-
array_diff_assoc($postFormatted, $customerFormData),
386+
$this->assertEquals(
387+
$postFormatted,
388+
$customerFormData,
396389
'Customer form data should be formatted'
397390
);
398391
$this->assertRedirect($this->stringContains($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
@@ -108,20 +108,6 @@ protected function setUp(): void
108108
);
109109
}
110110

111-
/**
112-
* Test constructor
113-
*
114-
* @magentoDataFixture Magento/Customer/_files/import_export/customer_with_addresses.php
115-
*/
116-
public function testConstruct()
117-
{
118-
$this->assertObjectHasAttribute('_entityTable', $this->_entityAdapter, 'Entity table must not be empty');
119-
$this->assertObjectHasAttribute('errorMessageTemplates', $this->_entityAdapter, 'Templates must not be empty');
120-
$this->assertObjectHasAttribute('_attributes', $this->_entityAdapter, 'Attributes must not be empty');
121-
$this->assertObjectHasAttribute('_countryRegions', $this->_entityAdapter, 'Country regions must not be empty');
122-
$this->assertObjectHasAttribute('_regions', $this->_entityAdapter, 'Regions must not be empty');
123-
}
124-
125111
/**
126112
* Test _saveAddressEntity
127113
*

dev/tests/integration/testsuite/Magento/Downloadable/Block/Account/LinkTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function testMyDownloadableProductLink(): void
4747
$block = $this->page->getLayout()->getBlock('customer-account-navigation-downloadable-products-link');
4848
$this->assertNotFalse($block);
4949
$html = $block->toHtml();
50-
$this->assertContains('downloadable/customer/products', $html);
50+
$this->assertStringContainsString('downloadable/customer/products', $html);
5151
$this->assertEquals('My Downloadable Products', strip_tags($html));
5252
}
5353

dev/tests/integration/testsuite/Magento/Downloadable/Block/Customer/Products/ListProductsTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ protected function tearDown(): void
8282
public function testNoItems(): void
8383
{
8484
$html = $this->createBlock()->toHtml();
85-
$this->assertContains((string)__('You have not purchased any downloadable products yet.'), strip_tags($html));
85+
$this->assertStringContainsString(
86+
(string)__('You have not purchased any downloadable products yet.'),
87+
strip_tags($html)
88+
);
8689
}
8790

8891
/**

0 commit comments

Comments
 (0)