Skip to content

Commit e39b04f

Browse files
ShradddhaShradddha
authored andcommitted
AC-12092:: Remove Deprecations- PhpUnit10 Unit Tests
1 parent f7523ca commit e39b04f

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
lines changed

app/code/Magento/Sitemap/Test/Unit/Model/ItemProvider/CompositeTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function testGetItems($itemResolverData, $expectedItems)
4747
/**
4848
* @return array
4949
*/
50-
public function sitemapItemsProvider()
50+
public static function sitemapItemsProvider()
5151
{
5252
$testCases = [];
5353

@@ -59,7 +59,7 @@ public function sitemapItemsProvider()
5959
$items = [];
6060
$maxItems = random_int(2, 5);
6161
for ($k = 1; $k < $maxItems; $k++) {
62-
$sitemapItem = $this->getMockForAbstractClass(SitemapItemInterface::class);
62+
$sitemapItem = static fn (self $testCase) => $testCase->getMockForAbstractClass(SitemapItemInterface::class);
6363
$items[] = $sitemapItem;
6464
$expectedItems[] = $sitemapItem;
6565
}

lib/internal/Magento/Framework/Cache/Test/Unit/Backend/Decorator/DecoratorAbstractTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,22 @@ public function testConstructor()
6363
*/
6464
public function testConstructorException($options)
6565
{
66+
if (!empty($options)) {
67+
$options['concrete_backend'] = $options['concrete_backend']($this);
68+
}
69+
6670
$this->expectException('Zend_Cache_Exception');
6771
$this->getMockForAbstractClass(AbstractDecorator::class, [$options]);
6872
}
6973

7074
/**
7175
* @return array
7276
*/
73-
public function constructorExceptionDataProvider()
77+
public static function constructorExceptionDataProvider()
7478
{
7579
return [
7680
'empty' => [[]],
77-
'wrong_class' => [['concrete_backend' => $this->getMockBuilder('Test_Class')
81+
'wrong_class' => [['concrete_backend' => static fn (self $testCase) => $testCase->getMockBuilder('Test_Class')
7882
->getMock()]]
7983
];
8084
}

lib/internal/Magento/Framework/Cache/Test/Unit/Backend/MongoDbTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,10 @@ public function testClean($mode, $tags, $expectedQuery)
347347
/**
348348
* @return array
349349
*/
350-
public function cleanDataProvider()
350+
public static function cleanDataProvider()
351351
{
352352
return [
353-
'clean expired' => [\Zend_Cache::CLEANING_MODE_OLD, [], $this->arrayHasKey('expire')],
353+
'clean expired' => [\Zend_Cache::CLEANING_MODE_OLD, [], self::arrayHasKey('expire')],
354354
'clean cache matching all tags (string)' => [
355355
\Zend_Cache::CLEANING_MODE_MATCHING_TAG,
356356
'tag1',

lib/internal/Magento/Framework/Cache/Test/Unit/Backend/RemoteSynchronizedCacheTest.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,25 @@ public static function initializeWithExceptionDataProvider(): array
9595
*/
9696
public function testInitializeWithOutException($options): void
9797
{
98+
$options['remote_backend_options']['adapter'] = $options['remote_backend_options']['adapter']($this);
9899
$result = new RemoteSynchronizedCache($options);
99100
$this->assertInstanceOf(RemoteSynchronizedCache::class, $result);
100101
}
101102

102-
/**
103-
* @return array
104-
*/
105-
public function initializeWithOutExceptionDataProvider(): array
103+
protected function getMockForMysqlClass()
106104
{
107105
$connectionMock = $this->getMockBuilder(Mysql::class)
108106
->disableOriginalConstructor()
109107
->getMock();
108+
return $connectionMock;
109+
}
110110

111+
/**
112+
* @return array
113+
*/
114+
public function initializeWithOutExceptionDataProvider(): array
115+
{
116+
$connectionMock = static fn (self $testCase) => $testCase->getMockForMysqlClass();
111117
return [
112118
'not_empty_backend_option' => [
113119
'options' => [

lib/internal/Magento/Framework/Test/Unit/ProfilerTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,9 @@ public function testApplyConfig(): void
459459
*/
460460
public function testParseConfig($data, $isAjax, $expected): void
461461
{
462+
if (!empty($data['driverFactory']) && is_callable($data['driverFactory'])) {
463+
$data['driverFactory'] = $data['driverFactory']($this);
464+
}
462465
if (!empty($expected) && is_callable($expected['driverFactory'])) {
463466
$expected['driverFactory'] = $expected['driverFactory']($this);
464467
}

0 commit comments

Comments
 (0)