Skip to content

Commit bcacf65

Browse files
authored
Merge pull request #8314 from magento-gl/BUG#AC-8834
Bug#AC-8834:: 2.4.7-Beta1-Composer Integration Test Failures-PHP 8.2-phpunit deprecated function is removed
2 parents 712e80c + d947d79 commit bcacf65

File tree

11 files changed

+371
-42
lines changed

11 files changed

+371
-42
lines changed

dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/StockTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected function setUp(): void
5454
public function testValidate(): void
5555
{
5656
$this->expectException(LocalizedException::class);
57-
$this->expectErrorMessage((string)__('Please enter a valid number in this field.'));
57+
$this->expectExceptionMessage((string)__('Please enter a valid number in this field.'));
5858
$product = $this->productFactory->create();
5959
$product->setQuantityAndStockStatus(['qty' => 'string']);
6060
$this->model->validate($product);

dev/tests/integration/testsuite/Magento/Catalog/Model/Product/AuthorizationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public function postRequestData(): array
136136
public function testAuthorizedSavingOfWithException(array $data): void
137137
{
138138
$this->expectException(AuthorizationException::class);
139-
$this->expectErrorMessage('Not allowed to edit the product\'s design attributes');
139+
$this->expectExceptionMessage('Not allowed to edit the product\'s design attributes');
140140
$this->request->setPost(new Parameters($data));
141141

142142
/** @var Product $product */

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function testSaveWithoutWebsiteId(): void
6565
$productWebsiteLink = $this->productWebsiteLinkFactory->create();
6666
$productWebsiteLink->setSku('unique-simple-azaza');
6767
$this->expectException(InputException::class);
68-
$this->expectErrorMessage((string)__('There are not websites for assign to product'));
68+
$this->expectExceptionMessage((string)__('There are not websites for assign to product'));
6969
$this->productWebsiteLinkRepository->save($productWebsiteLink);
7070
}
7171

dev/tests/integration/testsuite/Magento/Catalog/Model/System/Config/Backend/Catalog/Url/Rewrite/SuffixTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
* @magentoAppArea adminhtml
3333
* @magentoDbIsolation enabled
3434
* @magentoAppIsolation enabled
35+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
3536
*/
3637
class SuffixTest extends TestCase
3738
{
@@ -83,7 +84,7 @@ protected function setUp(): void
8384
public function testSaveWithError(): void
8485
{
8586
$this->expectException(LocalizedException::class);
86-
$this->expectErrorMessage((string)__('Anchor symbol (#) is not supported in url rewrite suffix.'));
87+
$this->expectExceptionMessage((string)__('Anchor symbol (#) is not supported in url rewrite suffix.'));
8788
$this->model->setValue('.html#');
8889
$this->model->beforeSave();
8990
}

dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/Product/Type/ConfigurableTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ protected function getUsedProducts()
656656
*/
657657
public function testAddCustomOptionToConfigurableChildProduct(): void
658658
{
659-
$this->expectErrorMessage(
659+
$this->expectExceptionMessage(
660660
'Required custom options cannot be added to a simple product that is a part of a composite product.'
661661
);
662662

dev/tests/integration/testsuite/Magento/Framework/App/ResourceConnection/ConnectionFactoryTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ public function testCreate()
3636
];
3737
$connection = $this->model->create($dbConfig);
3838
$this->assertInstanceOf(\Magento\Framework\DB\Adapter\AdapterInterface::class, $connection);
39-
$this->assertClassHasAttribute('logger', get_class($connection));
39+
$this->assertIsObject($connection);
40+
$this->assertTrue(property_exists($connection, 'logger'));
4041
$object = new ReflectionClass(get_class($connection));
4142
$attribute = $object->getProperty('logger');
4243
$attribute->setAccessible(true);

dev/tests/integration/testsuite/Magento/Framework/ObjectManager/ObjectManagerTest.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,27 @@ class ObjectManagerTest extends \PHPUnit\Framework\TestCase
1212
/**#@+
1313
* Test class with type error
1414
*/
15-
const TEST_CLASS_WITH_TYPE_ERROR = \Magento\Framework\ObjectManager\TestAsset\ConstructorWithTypeError::class;
15+
public const TEST_CLASS_WITH_TYPE_ERROR =
16+
\Magento\Framework\ObjectManager\TestAsset\ConstructorWithTypeError::class;
1617

1718
/**#@+
1819
* Test classes for basic instantiation
1920
*/
20-
const TEST_CLASS = \Magento\Framework\ObjectManager\TestAsset\Basic::class;
21+
public const TEST_CLASS = \Magento\Framework\ObjectManager\TestAsset\Basic::class;
2122

22-
const TEST_CLASS_INJECTION = \Magento\Framework\ObjectManager\TestAsset\BasicInjection::class;
23+
public const TEST_CLASS_INJECTION = \Magento\Framework\ObjectManager\TestAsset\BasicInjection::class;
2324

2425
/**#@-*/
2526

2627
/**#@+
2728
* Test classes and interface to test preferences
2829
*/
29-
const TEST_INTERFACE = \Magento\Framework\ObjectManager\TestAsset\TestAssetInterface::class;
30+
public const TEST_INTERFACE = \Magento\Framework\ObjectManager\TestAsset\TestAssetInterface::class;
3031

31-
const TEST_INTERFACE_IMPLEMENTATION = \Magento\Framework\ObjectManager\TestAsset\InterfaceImplementation::class;
32+
public const TEST_INTERFACE_IMPLEMENTATION =
33+
\Magento\Framework\ObjectManager\TestAsset\InterfaceImplementation::class;
3234

33-
const TEST_CLASS_WITH_INTERFACE = \Magento\Framework\ObjectManager\TestAsset\InterfaceInjection::class;
35+
public const TEST_CLASS_WITH_INTERFACE = \Magento\Framework\ObjectManager\TestAsset\InterfaceInjection::class;
3436

3537
/**#@-*/
3638

@@ -141,7 +143,8 @@ public function testNewInstance($actualClassName, array $properties = [], $expec
141143
$object = new ReflectionClass($actualClassName);
142144
if ($properties) {
143145
foreach ($properties as $propertyName => $propertyClass) {
144-
$this->assertClassHasAttribute($propertyName, $actualClassName);
146+
$this->assertIsObject($testObject);
147+
$this->assertTrue(property_exists($testObject, $propertyName));
145148
$attribute = $object->getProperty($propertyName);
146149
$attribute->setAccessible(true);
147150
$propertyObject = $attribute->getValue($testObject);

dev/tests/integration/testsuite/Magento/Framework/ProfilerTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22
/**
3-
* Test case for \Magento\Framework\Profiler
4-
*
53
* Copyright © Magento, Inc. All rights reserved.
64
* See COPYING.txt for license details.
75
*/
@@ -25,7 +23,8 @@ public function testApplyConfigWithDrivers(array $config, array $expectedDrivers
2523
{
2624
$profiler = new \Magento\Framework\Profiler();
2725
$profiler::applyConfig($config, '');
28-
$this->assertClassHasAttribute('_drivers', \Magento\Framework\Profiler::class);
26+
$this->assertIsObject($profiler);
27+
$this->assertTrue(property_exists($profiler, '_drivers'));
2928
$object = new ReflectionClass(\Magento\Framework\Profiler::class);
3029
$attribute = $object->getProperty('_drivers');
3130
$attribute->setAccessible(true);

dev/tests/integration/testsuite/Magento/ImportExport/Model/ExportTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ public function testGetEntityAdapterWithValidEntity($entity, $expectedEntityType
3535
{
3636
$this->_model->setData(['entity' => $entity]);
3737
$this->_model->getEntityAttributeCollection();
38-
$this->assertClassHasAttribute('_entityAdapter', get_class($this->_model));
38+
$this->assertIsObject($this->_model);
39+
$this->assertTrue(property_exists($this->_model, '_entityAdapter'));
3940
$object = new ReflectionClass(get_class($this->_model));
4041
$attribute = $object->getProperty('_entityAdapter');
4142
$attribute->setAccessible(true);

dev/tests/integration/testsuite/Magento/Ups/Model/CarrierTest.php

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
use Magento\Framework\HTTP\AsyncClient\Response;
1515
use Magento\Framework\HTTP\AsyncClientInterface;
1616
use Magento\Quote\Model\Quote\Address\RateRequest;
17+
use Magento\Quote\Model\Quote\Address\RateRequestFactory;
1718
use Magento\Quote\Model\Quote\Address\RateResult\Error;
19+
use Magento\Shipping\Model\Shipment\Request;
1820
use Magento\TestFramework\Helper\Bootstrap;
19-
use Magento\Quote\Model\Quote\Address\RateRequestFactory;
2021
use Magento\TestFramework\HTTP\AsyncClientInterfaceMock;
21-
use PHPUnit\Framework\TestCase;
2222
use PHPUnit\Framework\MockObject\MockObject;
23-
use Magento\Shipping\Model\Shipment\Request;
23+
use PHPUnit\Framework\TestCase;
2424
use Psr\Log\LoggerInterface;
2525

2626
/**
@@ -113,29 +113,54 @@ public function testGetShipConfirmUrlLive()
113113
}
114114

115115
/**
116-
* Collect free rates.
116+
* Collect rates for UPS Ground method.
117117
*
118118
* @magentoConfigFixture current_store carriers/ups/active 1
119-
* @magentoConfigFixture current_store carriers/ups/type UPS
120-
* @magentoConfigFixture current_store carriers/ups/allowed_methods 1DA,GND
121-
* @magentoConfigFixture current_store carriers/ups/free_method GND
119+
* @magentoConfigFixture current_store carriers/ups/type UPS_XML
120+
* @magentoConfigFixture current_store carriers/ups/allowed_methods 03
121+
* @magentoConfigFixture current_store carriers/ups/free_method 03
122+
* @magentoConfigFixture default_store carriers/ups/shipper_number 12345
123+
* @magentoConfigFixture default_store carriers/ups/origin_shipment Shipments Originating in the United States
124+
* @magentoConfigFixture default_store carriers/ups/username user
125+
* @magentoConfigFixture default_store carriers/ups/password pass
126+
* @magentoConfigFixture default_store carriers/ups/access_license_number acn
127+
* @magentoConfigFixture default_store carriers/ups/debug 1
128+
* @magentoConfigFixture default_store currency/options/allow USD,EUR
129+
* @magentoConfigFixture default_store currency/options/base USD
122130
*/
123131
public function testCollectFreeRates()
124132
{
125-
$rateRequest = Bootstrap::getObjectManager()->get(RateRequestFactory::class)->create();
126-
$rateRequest->setDestCountryId('US');
127-
$rateRequest->setDestRegionId('CA');
128-
$rateRequest->setDestPostcode('90001');
129-
$rateRequest->setPackageQty(1);
130-
$rateRequest->setPackageWeight(1);
131-
$rateRequest->setFreeMethodWeight(0);
132-
$rateRequest->setLimitCarrier($this->carrier::CODE);
133-
$rateRequest->setFreeShipping(true);
134-
$rateResult = $this->carrier->collectRates($rateRequest);
135-
$result = $rateResult->asArray();
136-
$methods = $result[$this->carrier::CODE]['methods'];
137-
$this->assertEquals(0, $methods['GND']['price']);
138-
$this->assertNotEquals(0, $methods['1DA']['price']);
133+
$request = Bootstrap::getObjectManager()->create(
134+
RateRequest::class,
135+
[
136+
'data' => [
137+
'dest_country' => 'US',
138+
'dest_postal' => '90001',
139+
'package_weight' => '1',
140+
'package_qty' => '1',
141+
'free_method_weight' => '5',
142+
'product' => '11',
143+
'action' => 'Rate',
144+
'unit_measure' => 'KGS',
145+
'free_shipping' => '1',
146+
'base_currency' => new DataObject(['code' => 'USD'])
147+
]
148+
]
149+
);
150+
//phpcs:disable Magento2.Functions.DiscouragedFunction
151+
$this->httpClient->nextResponses(
152+
[
153+
new Response(
154+
200,
155+
[],
156+
file_get_contents(__DIR__ . "/../_files/ups_rates_response_option9.xml")
157+
)
158+
]
159+
);
160+
161+
$rates = $this->carrier->collectRates($request)->getAllRates();
162+
$this->assertEquals('19.19', $rates[0]->getPrice());
163+
$this->assertEquals('03', $rates[0]->getMethod());
139164
}
140165

141166
/**
@@ -181,7 +206,7 @@ public function testCollectRates(int $negotiable, int $tax, int $responseId, str
181206
new Response(
182207
200,
183208
[],
184-
file_get_contents(__DIR__ ."/../_files/ups_rates_response_option$responseId.xml")
209+
file_get_contents(__DIR__ . "/../_files/ups_rates_response_option$responseId.xml")
185210
)
186211
]
187212
);
@@ -283,9 +308,9 @@ public function collectRatesDataProvider()
283308
public function testRequestToShipment(): void
284309
{
285310
//phpcs:disable Magento2.Functions.DiscouragedFunction
286-
$expectedShipmentRequest = file_get_contents(__DIR__ .'/../_files/ShipmentConfirmRequest.xml');
287-
$shipmentResponse = file_get_contents(__DIR__ .'/../_files/ShipmentConfirmResponse.xml');
288-
$acceptResponse = file_get_contents(__DIR__ .'/../_files/ShipmentAcceptResponse.xml');
311+
$expectedShipmentRequest = file_get_contents(__DIR__ . '/../_files/ShipmentConfirmRequest.xml');
312+
$shipmentResponse = file_get_contents(__DIR__ . '/../_files/ShipmentConfirmResponse.xml');
313+
$acceptResponse = file_get_contents(__DIR__ . '/../_files/ShipmentAcceptResponse.xml');
289314
//phpcs:enable Magento2.Functions.DiscouragedFunction
290315
$this->httpClient->nextResponses(
291316
[

0 commit comments

Comments
 (0)