Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api/rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector;
use Rector\PHPUnit\CodeQuality\Rector\ClassMethod\AddInstanceofAssertForNullableInstanceRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertEmptyNullableObjectToAssertInstanceofRector;
use Rector\PHPUnit\CodeQuality\Rector\StmtsAwareInterface\DeclareStrictTypesTestsRector;
use Rector\Privatization\Rector\Class_\FinalizeTestCaseClassRector;
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
Expand Down Expand Up @@ -50,6 +51,7 @@
CombineIfRector::class,
ConstraintOptionsToNamedArgumentsRector::class,
DeclareStrictTypesRector::class,
DeclareStrictTypesTestsRector::class,
DisallowedEmptyRuleFixerRector::class,
ExplicitBoolCompareRector::class,
FinalizeTestCaseClassRector::class,
Expand Down
8 changes: 5 additions & 3 deletions api/src/Controller/CevidbController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
use Symfony\Component\Routing\Annotation\Route;

class CevidbController extends AbstractController {
public function __construct(private readonly ClientRegistry $clientRegistry) {}

/**
* Link to this controller to start the "connect" process.
*/
#[Route('/auth/cevidb', name: 'connect_cevidb_start')]
public function connect(Request $request, ClientRegistry $clientRegistry) {
return $clientRegistry
public function connect(Request $request) {
return $this->clientRegistry
->getClient('cevidb') // key used in config/packages/knpu_oauth2_client.yaml
->redirect([], ['additionalData' => ['callback' => $request->get('callback')]])
;
Expand All @@ -25,7 +27,7 @@ public function connect(Request $request, ClientRegistry $clientRegistry) {
* in config/packages/knpu_oauth2_client.yaml.
*/
#[Route('/auth/cevidb/callback', name: 'connect_cevidb_check')]
public function connectCheck(ClientRegistry $clientRegistry) {
public function connectCheck() {
// ** if you want to *authenticate* the user, then
// leave this method blank and create a custom authenticator
}
Expand Down
8 changes: 5 additions & 3 deletions api/src/Controller/GoogleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
use Symfony\Component\Routing\Annotation\Route;

class GoogleController extends AbstractController {
public function __construct(private readonly ClientRegistry $clientRegistry) {}

/**
* Link to this controller to start the "connect" process.
*/
#[Route('/auth/google', name: 'connect_google_start')]
public function connect(Request $request, ClientRegistry $clientRegistry) {
return $clientRegistry
public function connect(Request $request) {
return $this->clientRegistry
->getClient('google') // key used in config/packages/knpu_oauth2_client.yaml
->redirect([], ['additionalData' => ['callback' => $request->get('callback')]])
;
Expand All @@ -25,7 +27,7 @@ public function connect(Request $request, ClientRegistry $clientRegistry) {
* in config/packages/knpu_oauth2_client.yaml.
*/
#[Route('/auth/google/callback', name: 'connect_google_check')]
public function connectCheck(ClientRegistry $clientRegistry) {
public function connectCheck() {
// ** if you want to *authenticate* the user, then
// leave this method blank and create a custom authenticator
}
Expand Down
8 changes: 5 additions & 3 deletions api/src/Controller/JubladbController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
use Symfony\Component\Routing\Annotation\Route;

class JubladbController extends AbstractController {
public function __construct(private readonly ClientRegistry $clientRegistry) {}

/**
* Link to this controller to start the "connect" process.
*/
#[Route('/auth/jubladb', name: 'connect_jubladb_start')]
public function connect(Request $request, ClientRegistry $clientRegistry) {
return $clientRegistry
public function connect(Request $request) {
return $this->clientRegistry
->getClient('jubladb') // key used in config/packages/knpu_oauth2_client.yaml
->redirect([], ['additionalData' => ['callback' => $request->get('callback')]])
;
Expand All @@ -25,7 +27,7 @@ public function connect(Request $request, ClientRegistry $clientRegistry) {
* in config/packages/knpu_oauth2_client.yaml.
*/
#[Route('/auth/jubladb/callback', name: 'connect_jubladb_check')]
public function connectCheck(ClientRegistry $clientRegistry) {
public function connectCheck() {
// ** if you want to *authenticate* the user, then
// leave this method blank and create a custom authenticator
}
Expand Down
8 changes: 5 additions & 3 deletions api/src/Controller/PbsmidataController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
use Symfony\Component\Routing\Annotation\Route;

class PbsmidataController extends AbstractController {
public function __construct(private readonly ClientRegistry $clientRegistry) {}

/**
* Link to this controller to start the "connect" process.
*/
#[Route('/auth/pbsmidata', name: 'connect_pbsmidata_start')]
public function connect(Request $request, ClientRegistry $clientRegistry) {
return $clientRegistry
public function connect(Request $request) {
return $this->clientRegistry
->getClient('pbsmidata') // key used in config/packages/knpu_oauth2_client.yaml
->redirect([], ['additionalData' => ['callback' => $request->get('callback')]])
;
Expand All @@ -25,7 +27,7 @@ public function connect(Request $request, ClientRegistry $clientRegistry) {
* in config/packages/knpu_oauth2_client.yaml.
*/
#[Route('/auth/pbsmidata/callback', name: 'connect_pbsmidata_check')]
public function connectCheck(ClientRegistry $clientRegistry) {
public function connectCheck() {
// ** if you want to *authenticate* the user, then
// leave this method blank and create a custom authenticator
}
Expand Down
2 changes: 1 addition & 1 deletion api/tests/Doctrine/Filter/ExpressionDateTimeFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function setUp(): void {

public function testGetDescriptionDoesNothingWhenNoPropertiesDefined() {
// given
$filter = new ExpressionDateTimeFilter($this->managerRegistryMock, null, null);
$filter = new ExpressionDateTimeFilter($this->managerRegistryMock);

// when
$description = $filter->getDescription('Dummy');
Expand Down
4 changes: 1 addition & 3 deletions api/tests/OAuth/JWTStateOAuth2ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@ public function testRedirectPersistsStateToTheDatabase() {
// then
$entityManagerMock->expects($this->once())
->method('persist')
->with($this->callback(function ($value) {
return $value instanceof OAuthState;
}))
->with($this->isInstanceOf(OAuthState::class))
;
// Should also clean up the database table
$repositoryMock->expects($this->once())->method('deleteAllExpiredBefore');
Expand Down
7 changes: 3 additions & 4 deletions api/tests/Service/MailServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class MailServiceTest extends KernelTestCase {

private Camp $camp;
private User $user;
private Security $security;

private MailService $mailer;

Expand All @@ -35,15 +34,15 @@ protected function setUp(): void {
$translator = self::getContainer()->get(TranslatorInterface::class);
$twigEnvironment = self::getContainer()->get(Environment::class);

$this->security = $this->createMock(Security::class);
$security = $this->createMock(Security::class);
$profile = new Profile();
$profile->nickname = 'Linux';
$profile->email = '[email protected]';
$user = new User();
$user->profile = $profile;
$this->security->method('getUser')->willReturn($user);
$security->method('getUser')->willReturn($user);

$this->mailer = new MailService($mailer, $translator, $twigEnvironment, 'frontend.example.com', '[email protected]', 'SenderName', $this->security);
$this->mailer = new MailService($mailer, $translator, $twigEnvironment, 'frontend.example.com', '[email protected]', 'SenderName', $security);

$this->user = new User();
$profile = new Profile();
Expand Down