Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e2d5c4a

Browse files
Merge branch '6.2' into 6.3
* 6.2: [Security] remove deprecated conditions in supports and authenticate methods from AccessListener class [Tests] Replace `setMethods()` by `onlyMethods()` and `addMethods()`
2 parents 2f1ccef + 9fd2a04 commit e2d5c4a

File tree

41 files changed

+125
-103
lines changed

Some content is hidden

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

41 files changed

+125
-103
lines changed

src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected function setUp(): void
3434

3535
$this->extension = $this
3636
->getMockBuilder(AbstractDoctrineExtension::class)
37-
->setMethods([
37+
->onlyMethods([
3838
'getMappingResourceConfigDirectory',
3939
'getObjectManagerElementName',
4040
'getMappingObjectDefaultName',

src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
namespace Symfony\Bridge\Doctrine\Tests\Form\ChoiceList;
1313

1414
use Doctrine\DBAL\Connection;
15+
use Doctrine\DBAL\Result;
1516
use Doctrine\DBAL\Types\GuidType;
1617
use Doctrine\DBAL\Types\Type;
18+
use Doctrine\ORM\AbstractQuery;
1719
use PHPUnit\Framework\TestCase;
1820
use Symfony\Bridge\Doctrine\Form\ChoiceList\ORMQueryBuilderLoader;
1921
use Symfony\Bridge\Doctrine\Tests\DoctrineTestHelper;
@@ -45,8 +47,8 @@ protected function checkIdentifierType($classname, $expectedType)
4547
{
4648
$em = DoctrineTestHelper::createTestEntityManager();
4749

48-
$query = $this->getMockBuilder(\QueryMock::class)
49-
->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute'])
50+
$query = $this->getMockBuilder(QueryMock::class)
51+
->onlyMethods(['setParameter', 'getResult', 'getSql', '_doExecute'])
5052
->getMock();
5153

5254
$query
@@ -60,7 +62,7 @@ protected function checkIdentifierType($classname, $expectedType)
6062

6163
$qb = $this->getMockBuilder(\Doctrine\ORM\QueryBuilder::class)
6264
->setConstructorArgs([$em])
63-
->setMethods(['getQuery'])
65+
->onlyMethods(['getQuery'])
6466
->getMock();
6567

6668
$qb->expects($this->once())
@@ -78,8 +80,8 @@ public function testFilterNonIntegerValues()
7880
{
7981
$em = DoctrineTestHelper::createTestEntityManager();
8082

81-
$query = $this->getMockBuilder(\QueryMock::class)
82-
->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute'])
83+
$query = $this->getMockBuilder(QueryMock::class)
84+
->onlyMethods(['setParameter', 'getResult', 'getSql', '_doExecute'])
8385
->getMock();
8486

8587
$query
@@ -93,7 +95,7 @@ public function testFilterNonIntegerValues()
9395

9496
$qb = $this->getMockBuilder(\Doctrine\ORM\QueryBuilder::class)
9597
->setConstructorArgs([$em])
96-
->setMethods(['getQuery'])
98+
->onlyMethods(['getQuery'])
9799
->getMock();
98100

99101
$qb->expects($this->once())
@@ -114,8 +116,8 @@ public function testFilterEmptyUuids($entityClass)
114116
{
115117
$em = DoctrineTestHelper::createTestEntityManager();
116118

117-
$query = $this->getMockBuilder(\QueryMock::class)
118-
->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute'])
119+
$query = $this->getMockBuilder(QueryMock::class)
120+
->onlyMethods(['setParameter', 'getResult', 'getSql', '_doExecute'])
119121
->getMock();
120122

121123
$query
@@ -129,7 +131,7 @@ public function testFilterEmptyUuids($entityClass)
129131

130132
$qb = $this->getMockBuilder(\Doctrine\ORM\QueryBuilder::class)
131133
->setConstructorArgs([$em])
132-
->setMethods(['getQuery'])
134+
->onlyMethods(['getQuery'])
133135
->getMock();
134136

135137
$qb->expects($this->once())
@@ -159,8 +161,8 @@ public function testFilterUid($entityClass)
159161

160162
$em = DoctrineTestHelper::createTestEntityManager();
161163

162-
$query = $this->getMockBuilder(\QueryMock::class)
163-
->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute'])
164+
$query = $this->getMockBuilder(QueryMock::class)
165+
->onlyMethods(['setParameter', 'getResult', 'getSql', '_doExecute'])
164166
->getMock();
165167

166168
$query
@@ -174,7 +176,7 @@ public function testFilterUid($entityClass)
174176

175177
$qb = $this->getMockBuilder(\Doctrine\ORM\QueryBuilder::class)
176178
->setConstructorArgs([$em])
177-
->setMethods(['getQuery'])
179+
->onlyMethods(['getQuery'])
178180
->getMock();
179181

180182
$qb->expects($this->once())
@@ -206,7 +208,7 @@ public function testUidThrowProperException($entityClass)
206208

207209
$qb = $this->getMockBuilder(\Doctrine\ORM\QueryBuilder::class)
208210
->setConstructorArgs([$em])
209-
->setMethods(['getQuery'])
211+
->onlyMethods(['getQuery'])
210212
->getMock();
211213

212214
$qb->expects($this->never())
@@ -227,8 +229,8 @@ public function testEmbeddedIdentifierName()
227229
{
228230
$em = DoctrineTestHelper::createTestEntityManager();
229231

230-
$query = $this->getMockBuilder(\QueryMock::class)
231-
->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute'])
232+
$query = $this->getMockBuilder(QueryMock::class)
233+
->onlyMethods(['setParameter', 'getResult', 'getSql', '_doExecute'])
232234
->getMock();
233235

234236
$query
@@ -242,7 +244,7 @@ public function testEmbeddedIdentifierName()
242244

243245
$qb = $this->getMockBuilder(\Doctrine\ORM\QueryBuilder::class)
244246
->setConstructorArgs([$em])
245-
->setMethods(['getQuery'])
247+
->onlyMethods(['getQuery'])
246248
->getMock();
247249
$qb->expects($this->once())
248250
->method('getQuery')
@@ -271,3 +273,24 @@ public static function provideUidEntityClasses()
271273
];
272274
}
273275
}
276+
277+
class QueryMock extends AbstractQuery
278+
{
279+
public function __construct()
280+
{
281+
}
282+
283+
/**
284+
* @return array|string
285+
*/
286+
public function getSQL()
287+
{
288+
}
289+
290+
/**
291+
* @return Result|int
292+
*/
293+
protected function _doExecute()
294+
{
295+
}
296+
}

src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function testLog($sql, $params, $logParams)
3030
$dbalLogger = $this
3131
->getMockBuilder(DbalLogger::class)
3232
->setConstructorArgs([$logger, null])
33-
->setMethods(['log'])
33+
->onlyMethods(['log'])
3434
->getMock()
3535
;
3636

@@ -62,7 +62,7 @@ public function testLogNonUtf8()
6262
$dbalLogger = $this
6363
->getMockBuilder(DbalLogger::class)
6464
->setConstructorArgs([$logger, null])
65-
->setMethods(['log'])
65+
->onlyMethods(['log'])
6666
->getMock()
6767
;
6868

@@ -85,7 +85,7 @@ public function testLogNonUtf8Array()
8585
$dbalLogger = $this
8686
->getMockBuilder(DbalLogger::class)
8787
->setConstructorArgs([$logger, null])
88-
->setMethods(['log'])
88+
->onlyMethods(['log'])
8989
->getMock()
9090
;
9191

@@ -116,7 +116,7 @@ public function testLogLongString()
116116
$dbalLogger = $this
117117
->getMockBuilder(DbalLogger::class)
118118
->setConstructorArgs([$logger, null])
119-
->setMethods(['log'])
119+
->onlyMethods(['log'])
120120
->getMock()
121121
;
122122

@@ -144,7 +144,7 @@ public function testLogUTF8LongString()
144144
$dbalLogger = $this
145145
->getMockBuilder(DbalLogger::class)
146146
->setConstructorArgs([$logger, null])
147-
->setMethods(['log'])
147+
->onlyMethods(['log'])
148148
->getMock()
149149
;
150150

src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ private function getManager($em, $name = null)
211211
private function getObjectManager($repository)
212212
{
213213
$em = $this->getMockBuilder(ObjectManager::class)
214-
->setMethods(['getClassMetadata', 'getRepository'])
214+
->onlyMethods(['getClassMetadata', 'getRepository'])
215215
->getMockForAbstractClass();
216216
$em->expects($this->any())
217217
->method('getRepository')

src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ protected function createRegistryMock($em = null)
9696
protected function createRepositoryMock()
9797
{
9898
$repository = $this->getMockBuilder(ObjectRepository::class)
99-
->setMethods(['findByCustom', 'find', 'findAll', 'findOneBy', 'findBy', 'getClassName'])
99+
->onlyMethods(['find', 'findAll', 'findOneBy', 'findBy', 'getClassName'])
100+
->addMethods(['findByCustom'])
100101
->getMock()
101102
;
102103

src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function testVerbosityMapping($verbosity, $level, $isHandling, array $map
6565
$levelName = Logger::getLevelName($level);
6666
$levelName = sprintf('%-9s', $levelName);
6767

68-
$realOutput = $this->getMockBuilder(Output::class)->setMethods(['doWrite'])->getMock();
68+
$realOutput = $this->getMockBuilder(Output::class)->onlyMethods(['doWrite'])->getMock();
6969
$realOutput->setVerbosity($verbosity);
7070
if ($realOutput->isDebug()) {
7171
$log = "16:21:54 $levelName [app] My info message\n";

src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public function testWarmupRemoveCacheMisses()
136136
$cacheFile = tempnam($this->cacheDir, __FUNCTION__);
137137
$warmer = $this->getMockBuilder(AnnotationsCacheWarmer::class)
138138
->setConstructorArgs([new AnnotationReader(), $cacheFile])
139-
->setMethods(['doWarmUp'])
139+
->onlyMethods(['doWarmUp'])
140140
->getMock();
141141

142142
$warmer->method('doWarmUp')->willReturnCallback(function ($cacheDir, ArrayAdapter $arrayAdapter) {

src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/RouterCacheWarmerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ class RouterCacheWarmerTest extends TestCase
2121
{
2222
public function testWarmUpWithWarmebleInterface()
2323
{
24-
$containerMock = $this->getMockBuilder(ContainerInterface::class)->setMethods(['get', 'has'])->getMock();
24+
$containerMock = $this->getMockBuilder(ContainerInterface::class)->onlyMethods(['get', 'has'])->getMock();
2525

26-
$routerMock = $this->getMockBuilder(testRouterInterfaceWithWarmebleInterface::class)->setMethods(['match', 'generate', 'getContext', 'setContext', 'getRouteCollection', 'warmUp'])->getMock();
26+
$routerMock = $this->getMockBuilder(testRouterInterfaceWithWarmebleInterface::class)->onlyMethods(['match', 'generate', 'getContext', 'setContext', 'getRouteCollection', 'warmUp'])->getMock();
2727
$containerMock->expects($this->any())->method('get')->with('router')->willReturn($routerMock);
2828
$routerCacheWarmer = new RouterCacheWarmer($containerMock);
2929

@@ -34,9 +34,9 @@ public function testWarmUpWithWarmebleInterface()
3434

3535
public function testWarmUpWithoutWarmebleInterface()
3636
{
37-
$containerMock = $this->getMockBuilder(ContainerInterface::class)->setMethods(['get', 'has'])->getMock();
37+
$containerMock = $this->getMockBuilder(ContainerInterface::class)->onlyMethods(['get', 'has'])->getMock();
3838

39-
$routerMock = $this->getMockBuilder(testRouterInterfaceWithoutWarmebleInterface::class)->setMethods(['match', 'generate', 'getContext', 'setContext', 'getRouteCollection'])->getMock();
39+
$routerMock = $this->getMockBuilder(testRouterInterfaceWithoutWarmebleInterface::class)->onlyMethods(['match', 'generate', 'getContext', 'setContext', 'getRouteCollection'])->getMock();
4040
$containerMock->expects($this->any())->method('get')->with('router')->willReturn($routerMock);
4141
$routerCacheWarmer = new RouterCacheWarmer($containerMock);
4242
$this->expectException(\LogicException::class);

src/Symfony/Bundle/FrameworkBundle/Tests/KernelBrowserTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function testRequestAfterKernelShutdownAndPerformedRequest()
6464
private function getKernelMock()
6565
{
6666
$mock = $this->getMockBuilder($this->getKernelClass())
67-
->setMethods(['shutdown', 'boot', 'handle', 'getContainer'])
67+
->onlyMethods(['shutdown', 'boot', 'handle', 'getContainer'])
6868
->disableOriginalConstructor()
6969
->getMock();
7070

src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ private function getServiceContainer(RouteCollection $routes): Container
609609
->willReturn($routes)
610610
;
611611

612-
$sc = $this->getMockBuilder(Container::class)->setMethods(['get'])->getMock();
612+
$sc = $this->getMockBuilder(Container::class)->onlyMethods(['get'])->getMock();
613613

614614
$sc
615615
->expects($this->once())

src/Symfony/Bundle/SecurityBundle/Tests/EventListener/VoteListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function testOnVoterVote()
2626
$traceableAccessDecisionManager = $this
2727
->getMockBuilder(TraceableAccessDecisionManager::class)
2828
->disableOriginalConstructor()
29-
->setMethods(['addVoterVote'])
29+
->onlyMethods(['addVoterVote'])
3030
->getMock();
3131

3232
$traceableAccessDecisionManager

src/Symfony/Component/Cache/Tests/Adapter/ChainAdapterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public function testExpirationOnAllAdapters()
214214

215215
$adapter1 = $this->getMockBuilder(FilesystemAdapter::class)
216216
->setConstructorArgs(['', 2])
217-
->setMethods(['save'])
217+
->onlyMethods(['save'])
218218
->getMock();
219219
$adapter1->expects($this->once())
220220
->method('save')
@@ -223,7 +223,7 @@ public function testExpirationOnAllAdapters()
223223

224224
$adapter2 = $this->getMockBuilder(FilesystemAdapter::class)
225225
->setConstructorArgs(['', 4])
226-
->setMethods(['save'])
226+
->onlyMethods(['save'])
227227
->getMock();
228228
$adapter2->expects($this->once())
229229
->method('save')

src/Symfony/Component/Cache/Tests/Adapter/MaxIdLengthAdapterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function testLongKey()
2121
{
2222
$cache = $this->getMockBuilder(MaxIdLengthAdapter::class)
2323
->setConstructorArgs([str_repeat('-', 10)])
24-
->setMethods(['doHave', 'doFetch', 'doDelete', 'doSave', 'doClear'])
24+
->onlyMethods(['doHave', 'doFetch', 'doDelete', 'doSave', 'doClear'])
2525
->getMock();
2626

2727
$cache->expects($this->exactly(2))

src/Symfony/Component/Console/Tests/ApplicationTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ public function testFindAlternativesOutput()
734734

735735
public function testFindNamespaceDoesNotFailOnDeepSimilarNamespaces()
736736
{
737-
$application = $this->getMockBuilder(Application::class)->setMethods(['getNamespaces'])->getMock();
737+
$application = $this->getMockBuilder(Application::class)->onlyMethods(['getNamespaces'])->getMock();
738738
$application->expects($this->once())
739739
->method('getNamespaces')
740740
->willReturn(['foo:sublong', 'bar:sub']);
@@ -894,7 +894,7 @@ public function testRenderExceptionEscapesLines()
894894

895895
public function testRenderExceptionLineBreaks()
896896
{
897-
$application = $this->getMockBuilder(Application::class)->setMethods(['getTerminalWidth'])->getMock();
897+
$application = $this->getMockBuilder(Application::class)->addMethods(['getTerminalWidth'])->getMock();
898898
$application->setAutoExit(false);
899899
$application->expects($this->any())
900900
->method('getTerminalWidth')
@@ -1121,7 +1121,7 @@ public function testRunReturnsIntegerExitCode()
11211121
{
11221122
$exception = new \Exception('', 4);
11231123

1124-
$application = $this->getMockBuilder(Application::class)->setMethods(['doRun'])->getMock();
1124+
$application = $this->getMockBuilder(Application::class)->onlyMethods(['doRun'])->getMock();
11251125
$application->setAutoExit(false);
11261126
$application->expects($this->once())
11271127
->method('doRun')
@@ -1160,7 +1160,7 @@ public function testRunReturnsExitCodeOneForExceptionCodeZero()
11601160
{
11611161
$exception = new \Exception('', 0);
11621162

1163-
$application = $this->getMockBuilder(Application::class)->setMethods(['doRun'])->getMock();
1163+
$application = $this->getMockBuilder(Application::class)->onlyMethods(['doRun'])->getMock();
11641164
$application->setAutoExit(false);
11651165
$application->expects($this->once())
11661166
->method('doRun')
@@ -1203,7 +1203,7 @@ public function testRunReturnsExitCodeOneForNegativeExceptionCode($exceptionCode
12031203
{
12041204
$exception = new \Exception('', $exceptionCode);
12051205

1206-
$application = $this->getMockBuilder(Application::class)->setMethods(['doRun'])->getMock();
1206+
$application = $this->getMockBuilder(Application::class)->onlyMethods(['doRun'])->getMock();
12071207
$application->setAutoExit(false);
12081208
$application->expects($this->once())
12091209
->method('doRun')

src/Symfony/Component/DependencyInjection/Tests/Compiler/MergeExtensionConfigurationPassTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function testExpressionLanguageProviderForwarding()
6060

6161
public function testExtensionLoadGetAMergeExtensionConfigurationContainerBuilderInstance()
6262
{
63-
$extension = $this->getMockBuilder(FooExtension::class)->setMethods(['load'])->getMock();
63+
$extension = $this->getMockBuilder(FooExtension::class)->onlyMethods(['load'])->getMock();
6464
$extension->expects($this->once())
6565
->method('load')
6666
->with($this->isType('array'), $this->isInstanceOf(MergeExtensionConfigurationContainerBuilder::class))
@@ -76,7 +76,7 @@ public function testExtensionLoadGetAMergeExtensionConfigurationContainerBuilder
7676

7777
public function testExtensionConfigurationIsTrackedByDefault()
7878
{
79-
$extension = $this->getMockBuilder(FooExtension::class)->setMethods(['getConfiguration'])->getMock();
79+
$extension = $this->getMockBuilder(FooExtension::class)->onlyMethods(['getConfiguration'])->getMock();
8080
$extension->expects($this->exactly(2))
8181
->method('getConfiguration')
8282
->willReturn(new FooConfiguration());

src/Symfony/Component/DomCrawler/Tests/FormTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ protected function getFormFieldMock($name, $value = null)
874874
{
875875
$field = $this
876876
->getMockBuilder(FormField::class)
877-
->setMethods(['getName', 'getValue', 'setValue', 'initialize'])
877+
->onlyMethods(['getName', 'getValue', 'setValue', 'initialize'])
878878
->disableOriginalConstructor()
879879
->getMock()
880880
;

src/Symfony/Component/Form/Test/Traits/ValidatorExtensionTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected function getValidatorExtension(): ValidatorExtension
3535
}
3636

3737
$this->validator = $this->createMock(ValidatorInterface::class);
38-
$metadata = $this->getMockBuilder(ClassMetadata::class)->setConstructorArgs([''])->setMethods(['addPropertyConstraint'])->getMock();
38+
$metadata = $this->getMockBuilder(ClassMetadata::class)->setConstructorArgs([''])->onlyMethods(['addPropertyConstraint'])->getMock();
3939
$this->validator->expects($this->any())->method('getMetadataFor')->will($this->returnValue($metadata));
4040
$this->validator->expects($this->any())->method('validate')->will($this->returnValue(new ConstraintViolationList()));
4141

0 commit comments

Comments
 (0)