Skip to content

Commit bb21c69

Browse files
FRW-8773 Added PHPUnit 11 support. (#11131)
FRW-8773 Added PHP Unit 11 support.
1 parent a1744ad commit bb21c69

File tree

12 files changed

+25
-29
lines changed

12 files changed

+25
-29
lines changed

src/Spryker/Zed/Development/DevelopmentConfig.php

-1
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,6 @@ public function getExternalToInternalMap()
428428
{
429429
return [
430430
'codeception/codeception' => 'spryker/testify',
431-
'dms/phpunit-arraysubset-asserts' => 'spryker/testify',
432431
'doctrine/inflector' => 'spryker/doctrine-inflector',
433432
'egulias/email-validator' => 'spryker/egulias',
434433
'fakerphp/faker' => 'spryker/testify',

tests/SprykerTest/Zed/Development/Business/CodeStyleSniffer/CodeStyleSnifferTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ protected function getCodeStyleSnifferMock(string $developmentModulePath, int $l
151151
$developmentConfig,
152152
$this->tester->createCodeStylePathResolver(),
153153
])
154-
->setMethods(['runSnifferCommand'])
154+
->onlyMethods(['runSnifferCommand'])
155155
->getMock();
156156

157157
$codeStyleSnifferMock

tests/SprykerTest/Zed/Development/Business/Composer/Updater/AutoloadUpdaterTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public function autoloadKeys(): array
199199
protected function getAutoloadUpdaterMock(): AutoloadUpdater
200200
{
201201
$autoloadUpdaterMock = $this->getMockBuilder(AutoloadUpdater::class)
202-
->setMethods(['pathExists', 'getPath'])
202+
->onlyMethods(['pathExists', 'getPath'])
203203
->getMock();
204204

205205
return $autoloadUpdaterMock;

tests/SprykerTest/Zed/Development/Business/IdeAutoCompletion/Bundle/MethodBuilder/ClientMethodBuilderTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ protected function getClientMethodBuilderMock(): ClientMethodBuilder
7777
$methodBuilderMock = $this
7878
->getMockBuilder(ClientMethodBuilder::class)
7979
->setConstructorArgs([$this->getNamespaceExtractorMock()])
80-
->setMethods(['findFileByName', 'isSearchDirectoryAccessible'])
80+
->onlyMethods(['findFileByName', 'isSearchDirectoryAccessible'])
8181
->getMock();
8282

8383
$methodBuilderMock

tests/SprykerTest/Zed/Development/Business/IdeAutoCompletion/Bundle/MethodBuilder/FacadeMethodBuilderTest.php

+7-14
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,10 @@ public function testFileLookupPrefersInterface(): void
7979
$methodBuilderMock
8080
->expects($this->exactly(1))
8181
->method('findFileByName')
82-
->withConsecutive(
83-
[$this->equalTo('FooBundleFacadeInterface.php'), $this->anything()],
84-
)
85-
->will($this->onConsecutiveCalls(
82+
->willReturnOnConsecutiveCalls(
8683
new SplFileInfo(static::BUNDLE_DIRECTORY . 'FooBundle/Business/FooBundleFacadeInterface.php', 'foo', 'bar'),
8784
new SplFileInfo(static::BUNDLE_DIRECTORY . 'FooBundle/Business/FooBundleFacade.php', 'foo', 'bar'),
88-
));
85+
);
8986

9087
$bundleMethodTransfer = $methodBuilderMock->getMethod($this->getBundleTransfer());
9188

@@ -101,14 +98,10 @@ public function testFileLookupFallsBackToConcreteClassIfInterfaceIsMissing(): vo
10198
$methodBuilderMock
10299
->expects($this->exactly(2))
103100
->method('findFileByName')
104-
->withConsecutive(
105-
[$this->equalTo('FooBundleFacadeInterface.php'), $this->anything()],
106-
[$this->equalTo('FooBundleFacade.php'), $this->anything()],
107-
)
108-
->will($this->onConsecutiveCalls(
109-
null,
110-
new SplFileInfo(static::BUNDLE_DIRECTORY . 'FooBundle/Business/FooBundleFacade.php', 'foo', 'bar'),
111-
));
101+
->willReturnOnConsecutiveCalls(
102+
null, // First call returns null (interface missing)
103+
new SplFileInfo(static::BUNDLE_DIRECTORY . 'FooBundle/Business/FooBundleFacade.php', 'foo', 'bar'), // Second call returns concrete class file
104+
);
112105

113106
$bundleMethodTransfer = $methodBuilderMock->getMethod($this->getBundleTransfer());
114107

@@ -123,7 +116,7 @@ protected function getFacadeMethodBuilderMock(): FacadeMethodBuilder
123116
$methodBuilderMock = $this
124117
->getMockBuilder(FacadeMethodBuilder::class)
125118
->setConstructorArgs([$this->getNamespaceExtractorMock()])
126-
->setMethods(['findFileByName', 'isSearchDirectoryAccessible'])
119+
->onlyMethods(['findFileByName', 'isSearchDirectoryAccessible'])
127120
->getMock();
128121

129122
$methodBuilderMock

tests/SprykerTest/Zed/Development/Business/IdeAutoCompletion/Bundle/MethodBuilder/QueryContainerMethodBuilderTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ protected function getQueryContainerMethodBuilderMock(): QueryContainerMethodBui
7777
$methodBuilderMock = $this
7878
->getMockBuilder(QueryContainerMethodBuilder::class)
7979
->setConstructorArgs([$this->getNamespaceExtractorMock()])
80-
->setMethods(['findFileByName', 'isSearchDirectoryAccessible'])
80+
->onlyMethods(['findFileByName', 'isSearchDirectoryAccessible'])
8181
->getMock();
8282

8383
$methodBuilderMock

tests/SprykerTest/Zed/Development/Business/IdeAutoCompletion/Bundle/MethodBuilder/ServiceMethodBuilderTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ protected function getServiceMethodBuilderMock(): ServiceMethodBuilder
7777
$methodBuilderMock = $this
7878
->getMockBuilder(ServiceMethodBuilder::class)
7979
->setConstructorArgs([$this->getNamespaceExtractorMock()])
80-
->setMethods(['findFileByName', 'isSearchDirectoryAccessible'])
80+
->onlyMethods(['findFileByName', 'isSearchDirectoryAccessible'])
8181
->getMock();
8282

8383
$methodBuilderMock

tests/SprykerTest/Zed/Development/Business/IdeAutoCompletion/IdeAutoCompletionWriterTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ protected function getDevelopmentConfigMock(): DevelopmentConfig
184184
{
185185
$configMock = $this
186186
->getMockBuilder(DevelopmentConfig::class)
187-
->setMethods(['getDefaultIdeAutoCompletionOptions'])
187+
->onlyMethods(['getDefaultIdeAutoCompletionOptions'])
188188
->getMock();
189189

190190
$configMock

tests/SprykerTest/Zed/Development/Business/PhpMd/Rules/Design/CouplingBetweenObjectsTest.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function testApplyAddsViolationWhenClassIsNotIgnorable(): void
8686
protected function getCouplingBetweenObjectsMock(): CouplingBetweenObjects
8787
{
8888
$mockBuilder = $this->getMockBuilder(CouplingBetweenObjects::class);
89-
$mockBuilder->setMethods(['addViolation', 'getIntProperty']);
89+
$mockBuilder->onlyMethods(['addViolation', 'getIntProperty']);
9090

9191
$couplingBetweenObjectsMock = $mockBuilder->getMock();
9292
$couplingBetweenObjectsMock->expects($this->once())->method('getIntProperty')->willReturn(static::THRESHOLD);
@@ -103,7 +103,8 @@ protected function getCouplingBetweenObjectsMock(): CouplingBetweenObjects
103103
protected function getNodeMock(string $fullyQualifiedClassName, string $nodeName): AbstractNode
104104
{
105105
$mockBuilder = $this->getMockBuilder(AbstractNode::class);
106-
$mockBuilder->setMethods(['getMetric', 'getName', 'getNamespace', 'getNamespaceName', 'hasSuppressWarningsAnnotationFor', 'getFullQualifiedName', 'getParentName'])
106+
$mockBuilder->addMethods(['getNamespace'])
107+
->onlyMethods(['getMetric', 'getName', 'getNamespaceName', 'hasSuppressWarningsAnnotationFor', 'getFullQualifiedName', 'getParentName'])
107108
->disableOriginalConstructor();
108109

109110
$nodeMock = $mockBuilder->getMock();

tests/SprykerTest/Zed/Development/Business/PhpMd/Rules/Design/NumberOfChildrenTest.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function testApplyAddsViolationWhenClassIsNotIgnorable(): void
8181
protected function getNumberOfChildrenMock(): NumberOfChildren
8282
{
8383
$mockBuilder = $this->getMockBuilder(NumberOfChildren::class);
84-
$mockBuilder->setMethods(['addViolation', 'getIntProperty']);
84+
$mockBuilder->onlyMethods(['addViolation', 'getIntProperty']);
8585

8686
$numberOfChildrenMock = $mockBuilder->getMock();
8787
$numberOfChildrenMock->expects($this->once())->method('getIntProperty')->willReturn(static::THRESHOLD);
@@ -97,7 +97,8 @@ protected function getNumberOfChildrenMock(): NumberOfChildren
9797
protected function getNodeMock(string $fullyQualifiedClassName): AbstractNode
9898
{
9999
$mockBuilder = $this->getMockBuilder(AbstractNode::class);
100-
$mockBuilder->setMethods(['getMetric', 'getName', 'getNamespace', 'getNamespaceName', 'hasSuppressWarningsAnnotationFor', 'getFullQualifiedName', 'getParentName'])
100+
$mockBuilder->addMethods(['getNamespace'])
101+
->onlyMethods(['getMetric', 'getName', 'getNamespaceName', 'hasSuppressWarningsAnnotationFor', 'getFullQualifiedName', 'getParentName'])
101102
->disableOriginalConstructor();
102103

103104
$nodeMock = $mockBuilder->getMock();

tests/SprykerTest/Zed/Development/Business/PhpMd/Rules/Design/TooManyMethodsTest.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function testApplyDoesNotAddViolationIfNumberOfMethodsLowerThenThreshold(
107107
protected function getTooManyMethodsMock(): TooManyMethods
108108
{
109109
$mockBuilder = $this->getMockBuilder(TooManyMethods::class);
110-
$mockBuilder->setMethods(['addViolation', 'getIntProperty', 'getStringProperty']);
110+
$mockBuilder->onlyMethods(['addViolation', 'getIntProperty', 'getStringProperty']);
111111

112112
$tooManyMethodsMock = $mockBuilder->getMock();
113113
$tooManyMethodsMock->expects($this->any())->method('getStringProperty')->willReturn('/ignore regex pattern/');
@@ -124,7 +124,8 @@ protected function getTooManyMethodsMock(): TooManyMethods
124124
protected function getNodeMock(string $fullyQualifiedClassName, string $nodeName): AbstractNode
125125
{
126126
$mockBuilder = $this->getMockBuilder(AbstractTypeNode::class);
127-
$mockBuilder->setMethods(['getMetric', 'getName', 'getNamespace', 'getNamespaceName', 'hasSuppressWarningsAnnotationFor', 'getFullQualifiedName', 'getParentName', 'getMethodNames'])
127+
$mockBuilder->addMethods(['getNamespace'])
128+
->onlyMethods(['getMetric', 'getName', 'getNamespaceName', 'hasSuppressWarningsAnnotationFor', 'getFullQualifiedName', 'getParentName', 'getMethodNames'])
128129
->disableOriginalConstructor();
129130

130131
$nodeMock = $mockBuilder->getMock();

tests/SprykerTest/Zed/Development/Business/PhpMd/Rules/Design/TooManyPublicMethodsTest.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function testApplyDoesNotAddViolationIfNumberOfMethodsLowerThenThreshold(
106106
protected function getTooManyPublicMethodsMock(): TooManyPublicMethods
107107
{
108108
$mockBuilder = $this->getMockBuilder(TooManyPublicMethods::class);
109-
$mockBuilder->setMethods(['addViolation', 'getIntProperty', 'getStringProperty']);
109+
$mockBuilder->onlyMethods(['addViolation', 'getIntProperty', 'getStringProperty']);
110110

111111
$tooManyMethodsMock = $mockBuilder->getMock();
112112
$tooManyMethodsMock->expects($this->any())->method('getStringProperty')->willReturn('/ignore regex pattern/');
@@ -123,7 +123,8 @@ protected function getTooManyPublicMethodsMock(): TooManyPublicMethods
123123
protected function getNodeMock(string $fullyQualifiedClassName, string $nodeName): AbstractNode
124124
{
125125
$mockBuilder = $this->getMockBuilder(AbstractTypeNode::class);
126-
$mockBuilder->setMethods(['getMetric', 'getName', 'getNamespace', 'getNamespaceName', 'hasSuppressWarningsAnnotationFor', 'getFullQualifiedName', 'getParentName', 'getMethods'])
126+
$mockBuilder->addMethods(['getNamespace'])
127+
->onlyMethods(['getMetric', 'getName', 'getNamespaceName', 'hasSuppressWarningsAnnotationFor', 'getFullQualifiedName', 'getParentName', 'getMethods'])
127128
->disableOriginalConstructor();
128129

129130
$nodeMock = $mockBuilder->getMock();

0 commit comments

Comments
 (0)