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
-------

39181f4fdf Use class const in test
This commit is contained in:
Jérémy Derussé 2021-01-22 11:21:47 +01:00
commit 10f3b10978
No known key found for this signature in database
GPG Key ID: 2083FA5758C473D2
3 changed files with 15 additions and 13 deletions

View File

@ -20,6 +20,7 @@ use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer;
use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\HttpKernel\KernelInterface;
class WebProfilerExtensionTest extends TestCase
{
@ -51,7 +52,7 @@ class WebProfilerExtensionTest extends TestCase
{
parent::setUp();
$this->kernel = $this->getMockBuilder(\Symfony\Component\HttpKernel\KernelInterface::class)->getMock();
$this->kernel = $this->getMockBuilder(KernelInterface::class)->getMock();
$this->container = new ContainerBuilder();
$this->container->register('error_handler.error_renderer.html', HtmlErrorRenderer::class)->setPublic(true);

View File

@ -20,8 +20,6 @@ use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Tests\Fixtures\DummyOutput;
/**
* Console logger test.
*
* @author Kévin Dunglas <dunglas@gmail.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
*/
@ -157,9 +155,9 @@ class ConsoleLoggerTest extends TestCase
public function testObjectCastToString()
{
if (method_exists($this, 'createPartialMock')) {
$dummy = $this->createPartialMock('Symfony\Component\Console\Tests\Logger\DummyTest', ['__toString']);
$dummy = $this->createPartialMock(DummyTest::class, ['__toString']);
} else {
$dummy = $this->createPartialMock('Symfony\Component\Console\Tests\Logger\DummyTest', ['__toString']);
$dummy = $this->createPartialMock(DummyTest::class, ['__toString']);
}
$dummy->method('__toString')->willReturn('DUMMY');

View File

@ -18,7 +18,10 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException;
use Symfony\Component\Security\Http\AccessMapInterface;
use Symfony\Component\Security\Http\Event\LazyResponseEvent;
use Symfony\Component\Security\Http\Firewall\AccessListener;
@ -27,7 +30,7 @@ class AccessListenerTest extends TestCase
{
public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess()
{
$this->expectException(\Symfony\Component\Security\Core\Exception\AccessDeniedException::class);
$this->expectException(AccessDeniedException::class);
$request = new Request();
$accessMap = $this->getMockBuilder(AccessMapInterface::class)->getMock();
@ -38,7 +41,7 @@ class AccessListenerTest extends TestCase
->willReturn([['foo' => 'bar'], null])
;
$token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
$token = $this->getMockBuilder(TokenInterface::class)->getMock();
$token
->expects($this->any())
->method('isAuthenticated')
@ -82,14 +85,14 @@ class AccessListenerTest extends TestCase
->willReturn([['foo' => 'bar'], null])
;
$notAuthenticatedToken = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
$notAuthenticatedToken = $this->getMockBuilder(TokenInterface::class)->getMock();
$notAuthenticatedToken
->expects($this->any())
->method('isAuthenticated')
->willReturn(false)
;
$authenticatedToken = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
$authenticatedToken = $this->getMockBuilder(TokenInterface::class)->getMock();
$authenticatedToken
->expects($this->any())
->method('isAuthenticated')
@ -146,7 +149,7 @@ class AccessListenerTest extends TestCase
->willReturn([null, null])
;
$token = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
$token = $this->getMockBuilder(TokenInterface::class)->getMock();
$token
->expects($this->never())
->method('isAuthenticated')
@ -201,7 +204,7 @@ class AccessListenerTest extends TestCase
public function testHandleWhenTheSecurityTokenStorageHasNoToken()
{
$this->expectException(\Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException::class);
$this->expectException(AuthenticationCredentialsNotFoundException::class);
$tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)->getMock();
$tokenStorage
->expects($this->any())
@ -241,7 +244,7 @@ class AccessListenerTest extends TestCase
->willReturn([['foo' => 'bar', 'bar' => 'baz'], null])
;
$authenticatedToken = $this->getMockBuilder(\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class)->getMock();
$authenticatedToken = $this->getMockBuilder(TokenInterface::class)->getMock();
$authenticatedToken
->expects($this->any())
->method('isAuthenticated')
@ -263,7 +266,7 @@ class AccessListenerTest extends TestCase
$tokenStorage,
$accessDecisionManager,
$accessMap,
$this->createMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')
$this->createMock(AuthenticationManagerInterface::class)
);
$listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MASTER_REQUEST));