Skip to content

Commit b1b2e6e

Browse files
ShradddhaShradddha
authored andcommitted
AC-11943:: Remove Deprecations- PhpUnit10 WebAPI Tests
1 parent 27c2086 commit b1b2e6e

File tree

59 files changed

+174
-165
lines changed

Some content is hidden

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

59 files changed

+174
-165
lines changed

dev/tests/api-functional/framework/Magento/TestFramework/TestCase/GraphQlAbstract.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ abstract class GraphQlAbstract extends WebapiAbstract
1919
*
2020
* @var \Magento\TestFramework\TestCase\GraphQl\Client
2121
*/
22-
private $graphQlClient;
22+
private static $graphQlClient;
2323

2424
/**
2525
* @var \Magento\Framework\App\Cache
@@ -37,17 +37,17 @@ abstract class GraphQlAbstract extends WebapiAbstract
3737
* @return array|int|string|float|bool GraphQL call results
3838
* @throws \Exception
3939
*/
40-
public function graphQlQuery(
40+
public static function graphQlQuery(
4141
string $query,
4242
array $variables = [],
4343
string $operationName = '',
4444
array $headers = []
4545
) {
46-
return $this->getGraphQlClient()->get(
46+
return self::getGraphQlClient()->get(
4747
$query,
4848
$variables,
4949
$operationName,
50-
$this->composeHeaders($headers)
50+
self::composeHeaders($headers)
5151
);
5252
}
5353

@@ -62,17 +62,17 @@ public function graphQlQuery(
6262
* @return array|int|string|float|bool GraphQL call results
6363
* @throws \Exception
6464
*/
65-
public function graphQlMutation(
65+
public static function graphQlMutation(
6666
string $query,
6767
array $variables = [],
6868
string $operationName = '',
6969
array $headers = []
7070
) {
71-
return $this->getGraphQlClient()->post(
71+
return self::getGraphQlClient()->post(
7272
$query,
7373
$variables,
7474
$operationName,
75-
$this->composeHeaders($headers)
75+
self::composeHeaders($headers)
7676
);
7777
}
7878

@@ -128,7 +128,7 @@ public function graphQlMutationWithResponseHeaders(
128128
* @param array $headers
129129
* @return string[]
130130
*/
131-
private function composeHeaders(array $headers): array
131+
private static function composeHeaders(array $headers): array
132132
{
133133
$headersArray = [];
134134
foreach ($headers as $key => $value) {
@@ -165,14 +165,14 @@ private function getAppCache()
165165
*
166166
* @return \Magento\TestFramework\TestCase\GraphQl\Client
167167
*/
168-
private function getGraphQlClient()
168+
private static function getGraphQlClient()
169169
{
170-
if ($this->graphQlClient === null) {
171-
$this->graphQlClient = Bootstrap::getObjectManager()->get(
170+
if (self::$graphQlClient === null) {
171+
self::$graphQlClient = Bootstrap::getObjectManager()->get(
172172
\Magento\TestFramework\TestCase\GraphQl\Client::class
173173
);
174174
}
175-
return $this->graphQlClient;
175+
return self::$graphQlClient;
176176
}
177177

178178
/**

dev/tests/api-functional/framework/Magento/TestFramework/TestCase/WebapiAbstract.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ abstract class WebapiAbstract extends \PHPUnit\Framework\TestCase
8989
*
9090
* @var \Magento\TestFramework\TestCase\Webapi\AdapterInterface[]
9191
*/
92-
protected $_webApiAdapters;
92+
protected static $_webApiAdapters;
9393

9494
/**
9595
* The list of available Web API adapters.
9696
*
9797
* @var array
9898
*/
99-
protected $_webApiAdaptersMap = [
99+
protected static $_webApiAdaptersMap = [
100100
self::ADAPTER_SOAP => \Magento\TestFramework\TestCase\Webapi\Adapter\Soap::class,
101101
self::ADAPTER_REST => \Magento\TestFramework\TestCase\Webapi\Adapter\Rest::class,
102102
];
@@ -166,7 +166,7 @@ protected function tearDown(): void
166166
* @param \Magento\Integration\Model\Integration|null $integration
167167
* @return array|int|string|float|bool Web API call results
168168
*/
169-
protected function _webApiCall(
169+
protected static function _webApiCall(
170170
$serviceInfo,
171171
$arguments = [],
172172
$webApiAdapterCode = null,
@@ -177,7 +177,7 @@ protected function _webApiCall(
177177
/** Default adapter code is defined in PHPUnit configuration */
178178
$webApiAdapterCode = strtolower(TESTS_WEB_API_ADAPTER);
179179
}
180-
return $this->_getWebApiAdapter($webApiAdapterCode)->call($serviceInfo, $arguments, $storeCode, $integration);
180+
return self::_getWebApiAdapter($webApiAdapterCode)->call($serviceInfo, $arguments, $storeCode, $integration);
181181
}
182182

183183
/**
@@ -295,19 +295,19 @@ public function addModelToDelete($model, $secure = false)
295295
* @return \Magento\TestFramework\TestCase\Webapi\AdapterInterface
296296
* @throws \LogicException When requested Web API adapter is not declared
297297
*/
298-
protected function _getWebApiAdapter($webApiAdapterCode)
298+
protected static function _getWebApiAdapter($webApiAdapterCode)
299299
{
300-
if (!isset($this->_webApiAdapters[$webApiAdapterCode])) {
301-
if (!isset($this->_webApiAdaptersMap[$webApiAdapterCode])) {
300+
if (!isset(self::$_webApiAdapters[$webApiAdapterCode])) {
301+
if (!isset(self::$_webApiAdaptersMap[$webApiAdapterCode])) {
302302
throw new \LogicException(
303303
sprintf('Declaration of the requested Web API adapter "%s" was not found.', $webApiAdapterCode)
304304
);
305305
}
306-
$this->_webApiAdapters[$webApiAdapterCode] = Bootstrap::getObjectManager()->get(
307-
$this->_webApiAdaptersMap[$webApiAdapterCode]
306+
self::$_webApiAdapters[$webApiAdapterCode] = Bootstrap::getObjectManager()->get(
307+
self::$_webApiAdaptersMap[$webApiAdapterCode]
308308
);
309309
}
310-
return $this->_webApiAdapters[$webApiAdapterCode];
310+
return self::$_webApiAdapters[$webApiAdapterCode];
311311
}
312312

313313
/**

dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryLinkRepositoryTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class CategoryLinkRepositoryTest extends WebapiAbstract
1616
const RESOURCE_PATH_SUFFIX = '/V1/categories';
1717
const RESOURCE_PATH_PREFIX = 'products';
1818

19-
private $categoryId = 333;
19+
private static $categoryId = 333;
2020

2121
/**
2222
* @dataProvider saveDataProvider
@@ -30,7 +30,7 @@ public function testSave($productLink, $productId, $productPosition = 0)
3030
$serviceInfo = [
3131
'rest' => [
3232
'resourcePath' => self::RESOURCE_PATH_SUFFIX
33-
. '/' . $this->categoryId . '/' . self::RESOURCE_PATH_PREFIX,
33+
. '/' . self::$categoryId . '/' . self::RESOURCE_PATH_PREFIX,
3434
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST,
3535
],
3636
'soap' => [
@@ -44,16 +44,16 @@ public function testSave($productLink, $productId, $productPosition = 0)
4444
$this->assertTrue($this->isProductInCategory($this->categoryId, $productId, $productPosition));
4545
}
4646

47-
public function saveDataProvider()
47+
public static function saveDataProvider()
4848
{
4949
return [
5050
[
51-
['sku' => 'simple_with_cross', 'position' => 7, 'category_id' => $this->categoryId],
51+
['sku' => 'simple_with_cross', 'position' => 7, 'category_id' => self::$categoryId],
5252
334,
5353
7,
5454
],
5555
[
56-
['sku' => 'simple_with_cross', 'category_id' => $this->categoryId],
56+
['sku' => 'simple_with_cross', 'category_id' => self::$categoryId],
5757
334,
5858
0
5959
],
@@ -86,16 +86,16 @@ public function testUpdateProduct($productLink, $productId, $productPosition = 0
8686
$this->assertFalse($this->isProductInCategory($this->categoryId, $productId, $productPosition));
8787
}
8888

89-
public function updateProductProvider()
89+
public static function updateProductProvider()
9090
{
9191
return [
9292
[
93-
['sku' => 'simple_with_cross', 'position' => 7, 'categoryId' => $this->categoryId],
93+
['sku' => 'simple_with_cross', 'position' => 7, 'categoryId' => self::$categoryId],
9494
333,
9595
4,
9696
],
9797
[
98-
['sku' => 'simple_with_cross', 'categoryId' => $this->categoryId],
98+
['sku' => 'simple_with_cross', 'categoryId' => self::$categoryId],
9999
333,
100100
0
101101
],

dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryManagementTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function testTree($rootCategoryId, $depth, $expected)
6262
/**
6363
* @return array
6464
*/
65-
public function treeDataProvider(): array
65+
public static function treeDataProvider(): array
6666
{
6767
return [
6868
[
@@ -183,7 +183,7 @@ public function testUpdateMove($categoryId, $parentId, $afterId, $expectedPositi
183183
$this->assertEquals($parentId, $model->getParentId());
184184
}
185185

186-
public function updateMoveDataProvider()
186+
public static function updateMoveDataProvider()
187187
{
188188
return [
189189
[402, 400, null, 2],

dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryRepositoryTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,16 +213,16 @@ public function testDeleteSystemOrRoot(int $categoryId, string $exceptionMsg): v
213213
/**
214214
* @return array
215215
*/
216-
public function deleteSystemOrRootDataProvider(): array
216+
public static function deleteSystemOrRootDataProvider(): array
217217
{
218218
return [
219219
'system_category' => [
220220
'category_id' => Category::TREE_ROOT_ID,
221-
'exception_message' => $this->buildExceptionMessage(Category::TREE_ROOT_ID),
221+
'exception_message' => self::buildExceptionMessage(Category::TREE_ROOT_ID),
222222
],
223223
'root_category' => [
224224
'category_id' => 2,
225-
'exception_message' => $this->buildExceptionMessage(2),
225+
'exception_message' => self::buildExceptionMessage(2),
226226
],
227227
];
228228
}
@@ -233,7 +233,7 @@ public function deleteSystemOrRootDataProvider(): array
233233
* @param int $categoryId
234234
* @return string
235235
*/
236-
private function buildExceptionMessage(int $categoryId): string
236+
private static function buildExceptionMessage(int $categoryId): string
237237
{
238238
$translatedMsg = (string)__('Cannot delete category with id %1');
239239

dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeOptionManagementInterfaceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function testAdd(array $optionData)
8585
*
8686
* @return array
8787
*/
88-
public function addDataProvider(): array
88+
public static function addDataProvider(): array
8989
{
9090
$optionPayload = [
9191
AttributeOptionInterface::LABEL => 'new color',

dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeRepositoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function testCreate(string $attributeCode): void
127127
/**
128128
* @return array
129129
*/
130-
public function attributeCodeDataProvider(): array
130+
public static function attributeCodeDataProvider(): array
131131
{
132132
return [
133133
[str_repeat('az_7', 15)],

dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductCustomOptionRepositoryTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public function testSave($optionData)
182182
}
183183
}
184184

185-
public function optionDataProvider()
185+
public static function optionDataProvider()
186186
{
187187
$fixtureOptions = [];
188188
$fixture = include '_files/product_options.php';
@@ -232,7 +232,7 @@ public function testAddNegative($optionData)
232232
$this->_webApiCall($serviceInfo, ['option' => $optionDataPost]);
233233
}
234234

235-
public function optionNegativeDataProvider()
235+
public static function optionNegativeDataProvider()
236236
{
237237
$fixtureOptions = [];
238238
$fixture = include '_files/product_options_negative.php';
@@ -397,7 +397,7 @@ public function testUpdateOptionAddingNewValue($optionType, $includedExisting, $
397397
}
398398
}
399399

400-
public function validOptionDataProvider()
400+
public static function validOptionDataProvider()
401401
{
402402
return [
403403
'drop_down including previous values' => ['drop_down', true, 3],
@@ -443,7 +443,7 @@ public function testUpdateNegative($optionData, $message, $exceptionCode)
443443
/**
444444
* @return array
445445
*/
446-
public function optionNegativeUpdateDataProvider()
446+
public static function optionNegativeUpdateDataProvider()
447447
{
448448
return include '_files/product_options_update_negative.php';
449449
}

dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRenderListInterfaceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function testGetList(array $expectedRenderInfo)
8888
* Provider for parts of product information
8989
* @return array
9090
*/
91-
public function productRenderInfoProvider()
91+
public static function productRenderInfoProvider()
9292
{
9393
return [
9494
'simple_products_variation' => [

dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,11 @@ public function testGetNoSuchEntityException()
209209
*
210210
* @return array
211211
*/
212-
public function productCreationProvider()
212+
public static function productCreationProvider()
213213
{
214214
$productBuilder = function ($data) {
215215
return array_replace_recursive(
216-
$this->getSimpleProductData(),
216+
self::getSimpleProductData(),
217217
$data
218218
);
219219
};
@@ -1134,7 +1134,7 @@ public function testGetListWithFilteringByStore(array $searchCriteria, array $sk
11341134
*
11351135
* @return array
11361136
*/
1137-
public function testGetListWithFilteringByStoreDataProvider()
1137+
public static function testGetListWithFilteringByStoreDataProvider()
11381138
{
11391139
return [
11401140
[
@@ -1226,7 +1226,7 @@ public function testGetListPagination(int $pageSize, int $currentPage, int $expe
12261226
*
12271227
* @return array
12281228
*/
1229-
public function productPaginationDataProvider()
1229+
public static function productPaginationDataProvider()
12301230
{
12311231
return [
12321232
'expect-all-items' => [
@@ -1370,7 +1370,7 @@ public function testGetListSortingByPosition(string $sortOrder, array $expectedI
13701370
*
13711371
* @return array[]
13721372
*/
1373-
public function getListSortingByPositionDataProvider(): array
1373+
public static function getListSortingByPositionDataProvider(): array
13741374
{
13751375
return [
13761376
'sort_by_position_descending' => [
@@ -1463,7 +1463,7 @@ public function testEavAttributes()
14631463
* @param array $productData
14641464
* @return array
14651465
*/
1466-
protected function getSimpleProductData($productData = [])
1466+
protected static function getSimpleProductData($productData = [])
14671467
{
14681468
return [
14691469
ProductInterface::SKU => isset($productData[ProductInterface::SKU])

0 commit comments

Comments
 (0)