Skip to content

Commit

Permalink
Fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Dec 3, 2023
1 parent e793c86 commit a5dc802
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 56 deletions.
8 changes: 1 addition & 7 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="3.18.2@19aa905f7c3c7350569999a93c40ae91ae4e1626">
<file src="src/Action/CheckAuthAction.php">
<InvalidArgument occurrences="1">
<code>$token</code>
</InvalidArgument>
</file>
</files>
<files psalm-version="5.16.0@2897ba636551a8cb61601cc26f6ccfbba6c36591"/>
16 changes: 8 additions & 8 deletions src/Session/SessionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,28 @@ public function __construct(RequestStack $requestStack)

public function isAuthenticated(): bool
{
return $this->getHttpSession()->has(static::SESSION_LASTFM_TOKEN);
return $this->getHttpSession()->has(self::SESSION_LASTFM_TOKEN);
}

public function getUsername(): ?string
{
return $this->getHttpSession()->get(static::SESSION_LASTFM_NAME);
return $this->getHttpSession()->get(self::SESSION_LASTFM_NAME);
}

public function store(SessionInterface $lastFmSession): void
{
$session = $this->getHttpSession();

$session->set(static::SESSION_LASTFM_NAME, $lastFmSession->getName());
$session->set(static::SESSION_LASTFM_TOKEN, $lastFmSession->getKey());
$session->set(self::SESSION_LASTFM_NAME, $lastFmSession->getName());
$session->set(self::SESSION_LASTFM_TOKEN, $lastFmSession->getKey());
}

public function clear(): void
{
$session = $this->getHttpSession();

$session->remove(static::SESSION_LASTFM_NAME);
$session->remove(static::SESSION_LASTFM_TOKEN);
$session->remove(self::SESSION_LASTFM_NAME);
$session->remove(self::SESSION_LASTFM_TOKEN);
}

public function getSession(): ?SessionInterface
Expand All @@ -65,8 +65,8 @@ public function getSession(): ?SessionInterface
$session = $this->getHttpSession();

return new LastFmSession(
$session->get(static::SESSION_LASTFM_NAME),
$session->get(static::SESSION_LASTFM_TOKEN)
$session->get(self::SESSION_LASTFM_NAME),
$session->get(self::SESSION_LASTFM_TOKEN)
);
}

Expand Down
14 changes: 7 additions & 7 deletions tests/Action/AuthErrorActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testExecute(): void
->willReturn(false)
;

$this->sessionManager->expects(static::once())->method('clear');
$this->sessionManager->expects(self::once())->method('clear');

$this->twig->method('render')->with('@NucleosLastFm/Auth/error.html.twig')
->willReturn('CONTENT')
Expand All @@ -59,8 +59,8 @@ public function testExecute(): void

$response = $action();

static::assertNotInstanceOf(RedirectResponse::class, $response);
static::assertSame(Response::HTTP_UNAUTHORIZED, $response->getStatusCode());
self::assertNotInstanceOf(RedirectResponse::class, $response);
self::assertSame(Response::HTTP_UNAUTHORIZED, $response->getStatusCode());
}

public function testExecuteWithCaughtEvent(): void
Expand All @@ -69,7 +69,7 @@ public function testExecuteWithCaughtEvent(): void
->willReturn(false)
;

$this->sessionManager->expects(static::once())->method('clear');
$this->sessionManager->expects(self::once())->method('clear');

$eventResponse = new Response();

Expand All @@ -84,7 +84,7 @@ public function testExecuteWithCaughtEvent(): void

$response = $action();

static::assertSame($eventResponse, $response);
self::assertSame($eventResponse, $response);
}

public function testExecuteWithNoAuth(): void
Expand All @@ -93,7 +93,7 @@ public function testExecuteWithNoAuth(): void
->willReturn(true)
;

$this->router->expects(static::once())->method('generate')->with('nucleos_lastfm_success')
$this->router->expects(self::once())->method('generate')->with('nucleos_lastfm_success')
->willReturn('/success')
;

Expand All @@ -104,6 +104,6 @@ public function testExecuteWithNoAuth(): void
$this->eventDispatcher
);

static::assertInstanceOf(RedirectResponse::class, $action());
self::assertInstanceOf(RedirectResponse::class, $action());
}
}
16 changes: 8 additions & 8 deletions tests/Action/AuthSuccessActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function testExecute(): void
->willReturn('FooUser')
;

$this->twig->expects(static::once())->method('render')->with('@NucleosLastFm/Auth/success.html.twig', [
$this->twig->expects(self::once())->method('render')->with('@NucleosLastFm/Auth/success.html.twig', [
'name' => 'FooUser',
]);

Expand All @@ -66,8 +66,8 @@ public function testExecute(): void

$response = $action();

static::assertNotInstanceOf(RedirectResponse::class, $response);
static::assertSame(200, $response->getStatusCode());
self::assertNotInstanceOf(RedirectResponse::class, $response);
self::assertSame(200, $response->getStatusCode());
}

public function testExecuteWithCaughtEvent(): void
Expand Down Expand Up @@ -97,7 +97,7 @@ public function testExecuteWithCaughtEvent(): void

$response = $action();

static::assertSame($eventResponse, $response);
self::assertSame($eventResponse, $response);
}

public function testExecuteNoAuth(): void
Expand All @@ -106,7 +106,7 @@ public function testExecuteNoAuth(): void
->willReturn(false)
;

$this->router->expects(static::once())->method('generate')->with('nucleos_lastfm_error')
$this->router->expects(self::once())->method('generate')->with('nucleos_lastfm_error')
->willReturn('/success')
;

Expand All @@ -117,7 +117,7 @@ public function testExecuteNoAuth(): void
$this->eventDispatcher
);

static::assertInstanceOf(RedirectResponse::class, $action());
self::assertInstanceOf(RedirectResponse::class, $action());
}

public function testExecuteNoSession(): void
Expand All @@ -129,7 +129,7 @@ public function testExecuteNoSession(): void
->willReturn(null)
;

$this->router->expects(static::once())->method('generate')->with('nucleos_lastfm_error')
$this->router->expects(self::once())->method('generate')->with('nucleos_lastfm_error')
->willReturn('/success')
;

Expand All @@ -140,6 +140,6 @@ public function testExecuteNoSession(): void
$this->eventDispatcher
);

static::assertInstanceOf(RedirectResponse::class, $action());
self::assertInstanceOf(RedirectResponse::class, $action());
}
}
8 changes: 4 additions & 4 deletions tests/Action/CheckAuthActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected function setUp(): void

public function testExecute(): void
{
$this->sessionManager->expects(static::once())->method('store');
$this->sessionManager->expects(self::once())->method('store');

$this->router->method('generate')->with('nucleos_lastfm_success')
->willReturn('/success')
Expand All @@ -57,7 +57,7 @@ public function testExecute(): void

$response = $action($request);

static::assertSame('/success', $response->getTargetUrl());
self::assertSame('/success', $response->getTargetUrl());
}

public function testExecuteWithNoToken(): void
Expand All @@ -77,7 +77,7 @@ public function testExecuteWithNoToken(): void

$response = $action($request);

static::assertSame('/auth', $response->getTargetUrl());
self::assertSame('/auth', $response->getTargetUrl());
}

public function testExecuteWithNoSession(): void
Expand All @@ -100,6 +100,6 @@ public function testExecuteWithNoSession(): void

$response = $action($request);

static::assertSame('/error', $response->getTargetUrl());
self::assertSame('/error', $response->getTargetUrl());
}
}
2 changes: 1 addition & 1 deletion tests/Action/StartAuthActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ public function testExecute(): void
$this->router
);

static::assertSame('https://lastFm/login', $action()->getTargetUrl());
self::assertSame('https://lastFm/login', $action()->getTargetUrl());
}
}
2 changes: 1 addition & 1 deletion tests/BundleIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ public function testStartup(): void

$client->request('GET', '/test');

static::assertSame(200, $client->getResponse()->getStatusCode());
self::assertSame(200, $client->getResponse()->getStatusCode());
}
}
2 changes: 1 addition & 1 deletion tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ public function testOptions(): void
],
];

static::assertSame($expected, $config);
self::assertSame($expected, $config);
}
}
4 changes: 2 additions & 2 deletions tests/Event/AuthFailedEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function testGetResponse(): void
{
$event = new AuthFailedEvent();

static::assertNull($event->getResponse());
self::assertNull($event->getResponse());
}

public function testSetResponse(): void
Expand All @@ -31,6 +31,6 @@ public function testSetResponse(): void
$event = new AuthFailedEvent();
$event->setResponse($reponse);

static::assertSame($reponse, $event->getResponse());
self::assertSame($reponse, $event->getResponse());
}
}
8 changes: 4 additions & 4 deletions tests/Event/AuthSuccessEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function testGetUsername(): void

$event = new AuthSuccessEvent($session);

static::assertSame('MyUser', $event->getUsername());
self::assertSame('MyUser', $event->getUsername());
}

public function testGetSession(): void
Expand All @@ -34,7 +34,7 @@ public function testGetSession(): void

$event = new AuthSuccessEvent($session);

static::assertSame($session, $event->getSession());
self::assertSame($session, $event->getSession());
}

public function testGetResponse(): void
Expand All @@ -43,7 +43,7 @@ public function testGetResponse(): void

$event = new AuthSuccessEvent($session);

static::assertNull($event->getResponse());
self::assertNull($event->getResponse());
}

public function testSetResponse(): void
Expand All @@ -55,6 +55,6 @@ public function testSetResponse(): void
$event = new AuthSuccessEvent($session);
$event->setResponse($reponse);

static::assertSame($reponse, $event->getResponse());
self::assertSame($reponse, $event->getResponse());
}
}
2 changes: 1 addition & 1 deletion tests/NucleosLastFmBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ public function testGetContainerExtension(): void
{
$bundle = new NucleosLastFmBundle();

static::assertInstanceOf(NucleosLastFmExtension::class, $bundle->getContainerExtension());
self::assertInstanceOf(NucleosLastFmExtension::class, $bundle->getContainerExtension());
}
}
24 changes: 12 additions & 12 deletions tests/Session/SessionManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,27 @@ public function testIsAuthenticated(): void
$this->session->set('LASTFM_TOKEN', 'TheToken');

$manager = new SessionManager($this->requestStack);
static::assertTrue($manager->isAuthenticated());
self::assertTrue($manager->isAuthenticated());
}

public function testIsNotAuthenticated(): void
{
$manager = new SessionManager($this->requestStack);
static::assertFalse($manager->isAuthenticated());
self::assertFalse($manager->isAuthenticated());
}

public function testGetUsername(): void
{
$this->session->set('LASTFM_NAME', 'MyUser');

$manager = new SessionManager($this->requestStack);
static::assertSame('MyUser', $manager->getUsername());
self::assertSame('MyUser', $manager->getUsername());
}

public function testGetUsernameNotExist(): void
{
$manager = new SessionManager($this->requestStack);
static::assertNull($manager->getUsername());
self::assertNull($manager->getUsername());
}

public function testStore(): void
Expand All @@ -71,8 +71,8 @@ public function testStore(): void
$manager = new SessionManager($this->requestStack);
$manager->store($lastfmSession);

static::assertTrue($this->session->has('LASTFM_TOKEN'));
static::assertTrue($this->session->has('LASTFM_NAME'));
self::assertTrue($this->session->has('LASTFM_TOKEN'));
self::assertTrue($this->session->has('LASTFM_NAME'));
}

public function testClear(): void
Expand All @@ -83,8 +83,8 @@ public function testClear(): void
$manager = new SessionManager($this->requestStack);
$manager->clear();

static::assertFalse($this->session->has('LASTFM_TOKEN'));
static::assertFalse($this->session->has('LASTFM_NAME'));
self::assertFalse($this->session->has('LASTFM_TOKEN'));
self::assertFalse($this->session->has('LASTFM_NAME'));
}

public function testGetSession(): void
Expand All @@ -96,15 +96,15 @@ public function testGetSession(): void

$lastfmSession = $manager->getSession();

static::assertNotNull($lastfmSession);
static::assertSame('MyUser', $lastfmSession->getName());
static::assertSame('TheToken', $lastfmSession->getKey());
self::assertNotNull($lastfmSession);
self::assertSame('MyUser', $lastfmSession->getName());
self::assertSame('TheToken', $lastfmSession->getKey());
}

public function testGetSessionWithNoAuth(): void
{
$manager = new SessionManager($this->requestStack);

static::assertNull($manager->getSession());
self::assertNull($manager->getSession());
}
}

0 comments on commit a5dc802

Please sign in to comment.