8000 minor #39930 Use class const in test (OskarStark) · symfony/symfony@10f3b10 · GitHub
[go: up one dir, main page]

Skip to content

Commit 10f3b10

Browse files
committed
minor #39930 Use class const in test (OskarStark)
This PR was merged into the 4.4 branch. Discussion ---------- Use class const in test | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | --- | License | MIT | Doc PR | --- super minor Commits ------- 39181f4 Use class const in test
2 parents 039fe6a + 39181f4 commit 10f3b10

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer;
2121
use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass;
2222
use Symfony\Component\EventDispatcher\EventDispatcher;
23+
use Symfony\Component\HttpKernel\KernelInterface;
2324

2425
class WebProfilerExtensionTest extends TestCase
2526
{
@@ -51,7 +52,7 @@ protected function setUp(): void
5152
{
5253
parent::setUp();
5354

54-
$this->kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock();
55+
$this->kernel = $this->getMockBuilder(KernelInterface::class)->getMock();
5556

5657
$this->container = new ContainerBuilder();
5758
$this->container->register('error_handler.error_renderer.html', HtmlErrorRenderer::class)->setPublic(true);

src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
use Symfony\Component\Console\Tests\Fixtures\DummyOutput;
2121

2222
/**
23-
* Console logger test.
24-
*
2523
* @author Kévin Dunglas <dunglas@gmail.com>
2624
* @author Jordi Boggiano <j.boggiano@seld.be>
2725
*/
@@ -157,9 +155,9 @@ public function testContextReplacement()
157155
public function testObjectCastToString()
158156
{
159157
if (method_exists($this, 'createPartialMock')) {
160-
$dummy = $this->createPartialMock('Symfony\Component\Console\Tests\Logger\DummyTest', ['__toString']);
158+
$dummy = $this->createPartialMock(DummyTest::class, ['__toString']);
161159
} else {
162-
$dummy = $this->createPartialMock('Symfony\Component\Console\Tests\Logger\DummyTest', ['__toString']);
160+
$dummy = $this->createPartialMock(DummyTest::class, ['__toString']);
163161
}
164162
$dummy->method('__toString')->willReturn('DUMMY');
165163

src/Symfony/Component/Security/Http/Tests/Firewall/AccessListenerTest.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
1919
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
2020
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
21+
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
2122
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
23+
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
24+
use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException;
2225
use Symfony\Component\Security\Http\AccessMapInterface;
2326
use Symfony\Component\Security\Http\Event\LazyResponseEvent;
2427
use Symfony\Component\Security\Http\Firewall\AccessListener;
@@ -27,7 +30,7 @@ class AccessListenerTest extends TestCase
2730
{
2831
public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess()
2932
{
30-
$this->expectException(\Symfony\Component\Security\Core\Exception\AccessDeniedException::class);
33+
$this->expectException(AccessDeniedException::class);
3134
$request = new Request();
3235

3336
$accessMap = $this->getMockBuilder(AccessMapInterface::class)->getMock();
@@ -38,7 +41,7 @@ public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess()
3841
->willReturn([['foo' => 'bar'], null])
3942
;
4043

41-
$token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
44+
$token = $this->getMockBuilder(TokenInterface::class)->getMock();
4245
$token
4346
->expects($this->any())
4447
->method('isAuthenticated')
@@ -82,14 +85,14 @@ public function testHandleWhenTheTokenIsNotAuthenticated()
8285
->willReturn([['foo' => 'bar'], null])
8386
;
8487

85-
$notAuthenticatedToken = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
88+
$notAuthenticatedToken = $this->getMockBuilder(TokenInterface::class)->getMock();
8689
$notAuthenticatedToken
8790
->expects($this->any())
8891
->method('isAuthenticated')
8992
->willReturn(false)
9093
;
9194

92-
$authenticatedToken = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
95+
$authenticatedToken = $this->getMockBuilder(TokenInterface::class)->getMock();
9396
$authenticatedToken
9497
->expects($this->any())
9598
->method('isAuthenticated')
@@ -146,7 +149,7 @@ public function testHandleWhenThereIsNoAccessMapEntryMatchingTheRequest()
146149
->willReturn([null, null])
147150
;
148151

149-
$token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
152+
$token = $this->getMockBuilder(TokenInterface::class)->getMock();
150153
$token
151154
->expects($this->never())
152155
->method('isAuthenticated')
@@ -201,7 +204,7 @@ public function testHandleWhenAccessMapReturnsEmptyAttributes()
201204

202205
public function testHandleWhenTheSecurityTokenStorageHasNoToken()
203206
{
204-
$this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException::class);
207+
$this->expectException(AuthenticationCredentialsNotFoundException::class);
205208
$tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)->getMock();
206209
$tokenStorage
207210
->expects($this->any())
@@ -241,7 +244,7 @@ public function testHandleMWithultipleAttributesShouldBeHandledAsAnd()
241244
->willReturn([['foo' => 'bar', 'bar' => 'baz'], null])
242245
;
243246

244-
$authenticatedToken = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
247+
$authenticatedToken = $this->getMockBuilder(TokenInterface::class)->getMock();
245248
$authenticatedToken
246249
->expects($this->any())
247250
->method('isAuthenticated')
@@ -263,7 +266,7 @@ public function testHandleMWithultipleAttributesShouldBeHandledAsAnd()
263266
$tokenStorage,
264267
$accessDecisionManager,
265268
$accessMap,
266-
$this->createMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')
269+
$this->createMock(AuthenticationManagerInterface::class)
267270
);
268271

269272
$listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST));

0 commit comments

Comments
 (0)
0