Skip to content

Commit f195965

Browse files
AC-15634: PHPUnit 12 Upgrade | Added missing files
1 parent d0e6ed3 commit f195965

File tree

32 files changed

+306
-339
lines changed

32 files changed

+306
-339
lines changed

app/code/Magento/GraphQl/Test/Unit/Model/Backpressure/BackpressureContextFactoryTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Magento\GraphQl\Model\Backpressure\BackpressureContextFactory;
1616
use Magento\GraphQl\Model\Backpressure\GraphQlContext;
1717
use Magento\GraphQl\Model\Backpressure\RequestTypeExtractorInterface;
18+
use PHPUnit\Framework\Attributes\DataProvider;
1819
use PHPUnit\Framework\MockObject\MockObject;
1920
use PHPUnit\Framework\TestCase;
2021

@@ -99,8 +100,8 @@ public static function getIdentityCases(): array
99100
* @param int $identityType
100101
* @param string $identity
101102
* @return void
102-
* @dataProvider getIdentityCases
103103
*/
104+
#[DataProvider('getIdentityCases')]
104105
public function testCreateForIdentity(int $identityType, string $identity): void
105106
{
106107
$this->requestTypeExtractor->method('extract')->willReturn($typeId = 'test');

app/code/Magento/GraphQl/Test/Unit/Model/Config/DisableSessionTest.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\App\Config\ScopeConfigInterface;
1111
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1212
use Magento\GraphQl\Model\Config\DisableSession;
13+
use PHPUnit\Framework\Attributes\DataProvider;
1314
use PHPUnit\Framework\MockObject\MockObject;
1415
use PHPUnit\Framework\TestCase;
1516

@@ -33,16 +34,14 @@ class DisableSessionTest extends TestCase
3334
*/
3435
public function setUp(): void
3536
{
36-
$this->scopeConfigMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
37+
$this->scopeConfigMock = $this->createMock(ScopeConfigInterface::class);
3738
$this->model = (new ObjectManager($this))->getObject(
3839
DisableSession::class,
3940
['scopeConfig' => $this->scopeConfigMock]
4041
);
4142
}
4243

43-
/**
44-
* @dataProvider disableSessionDataProvider
45-
*/
44+
#[DataProvider('disableSessionDataProvider')]
4645
public function testisSessionDisabled($configValue, $expectedResult)
4746
{
4847
$this->scopeConfigMock->expects($this->any())->method('getValue')->willReturn($configValue);
@@ -56,12 +55,12 @@ public function testisSessionDisabled($configValue, $expectedResult)
5655
public static function disableSessionDataProvider()
5756
{
5857
return [
59-
['configValue' => '1', true],
60-
['configValue' => '0', false],
61-
['configValue' => '11', false],
62-
['configValue' => null, false],
63-
['configValue' => '', false],
64-
['configValue' => 'adfjsadf', false],
58+
['1', true],
59+
['0', false],
60+
['11', false],
61+
[null, false],
62+
['', false],
63+
['adfjsadf', false],
6564
];
6665
}
6766
}

app/code/Magento/GraphQl/Test/Unit/Plugin/DisableSessionTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1414
use Magento\GraphQl\Model\Config\DisableSession;
1515
use Magento\GraphQl\Plugin\DisableSession as DisableSessionPlugin;
16+
use PHPUnit\Framework\Attributes\DataProvider;
1617
use PHPUnit\Framework\MockObject\MockObject;
1718
use PHPUnit\Framework\TestCase;
1819

@@ -63,8 +64,8 @@ public function setUp(): void
6364
* @param bool $methodResult
6465
* @param bool $expectedResult
6566
* @return void
66-
* @dataProvider testAfterCheckDataProvider
6767
*/
68+
#[DataProvider('afterCheckDataProvider')]
6869
public function testAfterCheck(string $area, bool $config, bool $methodResult, bool $expectedResult)
6970
{
7071
$this->disableSessionConfigMock->expects($this->any())->method('isDisabled')->willReturn($config);
@@ -77,7 +78,7 @@ public function testAfterCheck(string $area, bool $config, bool $methodResult, b
7778
*
7879
* @return array[]
7980
*/
80-
public static function testAfterCheckDataProvider()
81+
public static function afterCheckDataProvider()
8182
{
8283
return [
8384
['area' => 'graphql', 'config' => true, 'methodResult' => false, 'expectedResult' => false],
@@ -98,8 +99,8 @@ public static function testAfterCheckDataProvider()
9899
* @param bool $methodResult
99100
* @param bool $expectedResult
100101
* @return void
101-
* @dataProvider testAfterCheckDataProviderNoAreaCode
102102
*/
103+
#[DataProvider('afterCheckDataProviderNoAreaCode')]
103104
public function testAfterCheckNoArea(bool $config, bool $methodResult, bool $expectedResult)
104105
{
105106
$this->disableSessionConfigMock->expects($this->any())->method('isDisabled')->willReturn($config);
@@ -114,7 +115,7 @@ public function testAfterCheckNoArea(bool $config, bool $methodResult, bool $exp
114115
*
115116
* @return array[]
116117
*/
117-
public static function testAfterCheckDataProviderNoAreaCode()
118+
public static function afterCheckDataProviderNoAreaCode()
118119
{
119120
return [
120121
['config' => true, 'methodResult' => true, 'expectedResult' => true],
@@ -123,4 +124,4 @@ public static function testAfterCheckDataProviderNoAreaCode()
123124
['config' => false, 'methodResult' => false, 'expectedResult' => false],
124125
];
125126
}
126-
}
127+
}

app/code/Magento/GraphQlCache/Test/Unit/Model/CacheId/CacheIdCalculatorTest.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,17 @@ class CacheIdCalculatorTest extends TestCase
6060

6161
protected function setup(): void
6262
{
63-
$this->logger = $this->getMockForAbstractClass(LoggerInterface::class);
64-
$this->contextFactory = $this->getMockForAbstractClass(ContextFactoryInterface::class);
65-
$context = $this->getMockForAbstractClass(ContextInterface::class);
63+
$this->logger = $this->createMock(LoggerInterface::class);
64+
$this->contextFactory = $this->createMock(ContextFactoryInterface::class);
65+
$context = $this->createMock(ContextInterface::class);
6666
$this->contextFactory->expects($this->any())->method('get')->willReturn($context);
67-
$this->deploymentConfig = $this->getMockBuilder(DeploymentConfig::class)
68-
->disableOriginalConstructor()
69-
->getMock();
70-
$this->envWriter = $this->getMockBuilder(DeploymentConfig\Writer::class)
71-
->disableOriginalConstructor()
72-
->getMock();
67+
$this->deploymentConfig = $this->createMock(DeploymentConfig::class);
68+
$this->envWriter = $this->createMock(DeploymentConfig\Writer::class);
7369
$this->random = new Random();
74-
$this->factorProvider1 = $this->getMockForAbstractClass(CacheIdFactorProviderInterface::class);
70+
$this->factorProvider1 = $this->createMock(CacheIdFactorProviderInterface::class);
7571
$this->factorProvider1->expects($this->any())->method('getFactorName')->willReturn('FACTOR_ONE_NAME');
7672
$this->factorProvider1->expects($this->any())->method('getFactorValue')->willReturn('FACTOR_ONE_VALUE');
77-
$this->factorProvider2 = $this->getMockForAbstractClass(CacheIdFactorProviderInterface::class);
73+
$this->factorProvider2 = $this->createMock(CacheIdFactorProviderInterface::class);
7874
$this->factorProvider2->expects($this->any())->method('getFactorName')->willReturn('FACTOR_TWO_NAME');
7975
$this->factorProvider2->expects($this->any())->method('getFactorValue')->willReturn('FACTOR_TWO_VALUE');
8076
}

app/code/Magento/GraphQlCache/Test/Unit/Model/CacheableQueryHandlerTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Magento\GraphQlCache\Model\CacheableQuery;
1414
use Magento\GraphQlCache\Model\CacheableQueryHandler;
1515
use Magento\GraphQlCache\Model\Resolver\IdentityPool;
16+
use PHPUnit\Framework\Attributes\DataProvider;
1617
use PHPUnit\Framework\TestCase;
1718

1819
/**
@@ -59,8 +60,8 @@ protected function setup(): void
5960
/**
6061
* @param array $resolvedData
6162
* @param array $identities
62-
* @dataProvider resolvedDataProvider
6363
*/
64+
#[DataProvider('resolvedDataProvider')]
6465
public function testhandleCacheFromResolverResponse(
6566
array $resolvedData,
6667
array $identities,
@@ -70,9 +71,10 @@ public function testhandleCacheFromResolverResponse(
7071
'cacheIdentity' => IdentityInterface::class,
7172
'cacheTag' => 'cat_p'
7273
];
73-
$mockIdentity = $this->getMockBuilder($cacheData['cacheIdentity'])
74-
->onlyMethods(['getIdentities'])
75-
->getMockForAbstractClass();
74+
$mockIdentity = $this->createPartialMock(
75+
IdentityInterface::class,
76+
['getIdentities']
77+
);
7678

7779
$this->requestMock->expects($this->once())->method('isGet')->willReturn(true);
7880
$this->identityPoolMock->expects($this->once())->method('get')->willReturn($mockIdentity);

app/code/Magento/Swagger/Test/Unit/Block/IndexTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,9 @@ class IndexTest extends TestCase
4444
*/
4545
protected function setUp(): void
4646
{
47-
$this->requestMock = $this->getMockBuilder(RequestInterface::class)
48-
->getMock();
49-
$this->schemaTypeMock = $this->getMockBuilder(SchemaTypeInterface::class)
50-
->getMock();
51-
$this->urlBuilder = $this->getMockBuilder(UrlInterface::class)
52-
->getMock();
47+
$this->requestMock = $this->createMock(RequestInterface::class);
48+
$this->schemaTypeMock = $this->createMock(SchemaTypeInterface::class);
49+
$this->urlBuilder = $this->createMock(UrlInterface::class);
5350

5451
$this->index = (new ObjectManager($this))->getObject(
5552
Index::class,

app/code/Magento/Swagger/Test/Unit/Controller/Index/IndexTest.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,11 @@ protected function setUp(): void
4646
$contextMock = $this->createMock(Context::class);
4747

4848
/** @var MockObject|PageConfig $pageConfigMock */
49-
$this->pageConfigMock = $this->getMockBuilder(PageConfig::class)
50-
->disableOriginalConstructor()
51-
->getMock();
49+
$this->pageConfigMock = $this->createMock(PageConfig::class);
5250
/** @var MockObject|PageFactory $resultPageFactory */
53-
$this->resultPageFactory = $this->getMockBuilder(PageFactory::class)
54-
->disableOriginalConstructor()
55-
->getMock();
51+
$this->resultPageFactory = $this->createMock(PageFactory::class);
5652

57-
$this->config = self::getMockBuilder(Config::class)
58-
->disableOriginalConstructor()
59-
->getMock();
53+
$this->config = $this->createMock(Config::class);
6054

6155
$this->indexAction = new Index(
6256
$contextMock,
@@ -86,9 +80,7 @@ public function testDispatchRejectsWhenDisabled()
8680
$this->expectException(NotFoundException::class);
8781
$this->expectExceptionMessage('Page not found.');
8882

89-
$request = self::getMockBuilder(Http::class)
90-
->disableOriginalConstructor()
91-
->getMock();
83+
$request = $this->createMock(Http::class);
9284

9385
$this->config->method('isEnabled')
9486
->willReturn(false);
@@ -101,9 +93,7 @@ public function testDispatchRejectsWhenDisabled()
10193
*/
10294
public function testDispatchIsSuccessfulWhenEnabled(): void
10395
{
104-
$request = self::getMockBuilder(Http::class)
105-
->disableOriginalConstructor()
106-
->getMock();
96+
$request = $this->createMock(Http::class);
10797
// Assert that execute is called
10898
$request->expects($this->once())
10999
->method('getFullActionName');

app/code/Magento/Swagger/Test/Unit/Model/ConfigTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use Magento\Framework\App\State;
1212
use Magento\Swagger\Model\Config;
13+
use PHPUnit\Framework\Attributes\DataProvider;
1314
use PHPUnit\Framework\MockObject\MockObject;
1415
use PHPUnit\Framework\TestCase;
1516

@@ -22,9 +23,7 @@ class ConfigTest extends TestCase
2223

2324
protected function setUp(): void
2425
{
25-
$this->state = self::getMockBuilder(State::class)
26-
->disableOriginalConstructor()
27-
->getMock();
26+
$this->state = $this->createMock(State::class);
2827
}
2928

3029
public function testDisabledInProductionByDefault()
@@ -40,8 +39,8 @@ public function testDisabledInProductionByDefault()
4039
* @param string $mode
4140
* @param bool $configuredValue
4241
* @param bool $expectedResult
43-
* @dataProvider useCaseProvider
4442
*/
43+
#[DataProvider('useCaseProvider')]
4544
public function testUseCases(string $mode, bool $configuredValue, bool $expectedResult)
4645
{
4746
$this->state->method('getMode')

app/code/Magento/SwaggerWebapi/Test/Unit/Model/SchemaType/RestTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use Magento\Swagger\Api\Data\SchemaTypeInterface;
1212
use Magento\SwaggerWebapi\Model\SchemaType\Rest;
13+
use PHPUnit\Framework\Attributes\DataProvider;
1314
use PHPUnit\Framework\MockObject\MockObject;
1415
use PHPUnit\Framework\TestCase;
1516

@@ -33,9 +34,8 @@ protected function setUp(): void
3334
*
3435
* @param $expected
3536
* @param null|string $store
36-
*
37-
* @dataProvider getSchemaUrlPathProvider
3837
*/
38+
#[DataProvider('getSchemaUrlPathProvider')]
3939
public function testGetSchemaUrlPath($expected, $store = null)
4040
{
4141
$this->assertEquals($expected, $this->rest->getSchemaUrlPath($store));

app/code/Magento/SwaggerWebapiAsync/Test/Unit/Model/SchemaType/AsyncTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use Magento\Swagger\Api\Data\SchemaTypeInterface;
1212
use Magento\SwaggerWebapiAsync\Model\SchemaType\Async;
13+
use PHPUnit\Framework\Attributes\DataProvider;
1314
use PHPUnit\Framework\MockObject\MockObject;
1415
use PHPUnit\Framework\TestCase;
1516

@@ -41,9 +42,8 @@ public function testGetCode()
4142
*
4243
* @param null|string $store
4344
* @param $expected
44-
*
45-
* @dataProvider getSchemaUrlPathProvider
4645
*/
46+
#[DataProvider('getSchemaUrlPathProvider')]
4747
public function testGetSchemaUrlPath($expected, $store = null)
4848
{
4949
$this->assertEquals($expected, $this->async->getSchemaUrlPath($store));

0 commit comments

Comments
 (0)