Skip to content
Merged
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
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"ibexa/doctrine-schema": "~6.0.x-dev",
"ibexa/fieldtype-richtext": "~6.0.x-dev",
"ibexa/http-cache": "~6.0.x-dev",
"ibexa/phpstan": "~6.0.x-dev",
"ibexa/rector": "~6.0.x-dev",
"ibexa/rest": "~6.0.x-dev",
"ibexa/search": "~6.0.x-dev",
Expand Down
8 changes: 1 addition & 7 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -528,14 +528,8 @@ parameters:
count: 1
path: tests/integration/Invitation/InvitationServiceTest.php

-
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\User\\\\PasswordValidationContext'' and Ibexa\\Contracts\\Core\\Repository\\Values\\User\\PasswordValidationContext will always evaluate to true\.$#'
identifier: method.alreadyNarrowedType
count: 1
path: tests/lib/Validator/Constraint/PasswordValidatorTest.php

-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\User\\\\PasswordValidationContext'' and Ibexa\\Contracts\\Core\\Repository\\Values\\User\\PasswordValidationContext will always evaluate to true\.$#'
identifier: staticMethod.alreadyNarrowedType
count: 1
count: 2
path: tests/lib/Validator/Constraint/PasswordValidatorTest.php
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ includes:
- phpstan-baseline.neon
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-symfony/extension.neon
- vendor/ibexa/phpstan/extension.neon

parameters:
level: 8
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Form/ChoiceList/Loader/UserGroupsChoiceLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(
*/
protected function loadChoices(): iterable
{
return $this->repository->sudo(function () {
return $this->repository->sudo(function (): array {
$query = new Query();
$query->filter = new ContentTypeIdentifier('user_group');
$query->offset = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Form/Type/Invitation/SectionsChoiceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function configureOptions(OptionsResolver $resolver): void
->setDefaults([
'choice_loader' => ChoiceList::lazy(
$this,
fn () => $this->repository->sudo(fn (): iterable => $this->sectionService->loadSections())
fn (): iterable => $this->repository->sudo(fn (): iterable => $this->sectionService->loadSections())
),
'choice_label' => 'name',
'choice_value' => 'id',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class PerformAccessCheckSubscriberTest extends TestCase

protected function setUp(): void
{
$this->kernel = $this->createStub(HttpKernelInterface::class);
$this->kernel = self::createStub(HttpKernelInterface::class);
$this->request = new Request();
$this->subscriber = new PerformAccessCheckSubscriber([]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected function setUp(): void
parent::setUp();

$this->validator = $this->createMock(ValidatorInterface::class);
$this->constraintViolation = $this->createStub(ConstraintViolationInterface::class);
$this->constraintViolation = self::createStub(ConstraintViolationInterface::class);
$this->configResolver = $this->createMock(ConfigResolverInterface::class);
}

Expand Down
12 changes: 6 additions & 6 deletions tests/lib/Invitation/InvitationServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ protected function setUp(): void
$this->configResolver = $this->createMock(ConfigResolverInterface::class);

$this->invitationService = new InvitationService(
$this->createStub(PermissionResolver::class),
$this->createStub(Handler::class),
$this->createStub(HashGenerator::class),
$this->createStub(UserService::class),
self::createStub(PermissionResolver::class),
self::createStub(Handler::class),
self::createStub(HashGenerator::class),
self::createStub(UserService::class),
$this->siteAccessService,
$this->createStub(TransactionHandler::class),
self::createStub(TransactionHandler::class),
$this->configResolver,
$this->createStub(DomainMapper::class)
self::createStub(DomainMapper::class)
);
}

Expand Down
8 changes: 4 additions & 4 deletions tests/lib/Password/PasswordRequirementsResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ public static function dataProviderForGetRequirements(): array
public function testCoversEveryCoreValidatorSchemaRule(): void
{
$schema = (new UserType(
$this->createStub(UserHandler::class),
$this->createStub(PasswordHashService::class),
$this->createStub(PasswordValidatorInterface::class)
self::createStub(UserHandler::class),
self::createStub(PasswordHashService::class),
self::createStub(PasswordValidatorInterface::class)
))->getValidatorConfigurationSchema()['PasswordValueValidator'];

$allRulesEnabled = array_map(
static fn (array $rule) => $rule['type'] === 'int' ? 1 : true,
static fn (array $rule): int|true => $rule['type'] === 'int' ? 1 : true,
$schema
);
$allRulesEnabled['minLength'] = 10;
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/Permission/UserPermissionsLimitationTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public function testEvaluate(
): void {
$value = (new UserPermissionsLimitationType($this->getPersistenceMock()))->evaluate(
$limitation,
$this->createStub(APIUser::class),
self::createStub(APIUser::class),
$object,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function setUp(): void
{
$this->httpUtils = $this->createMock(HttpUtils::class);
$this->handler = new DefaultAuthenticationFailureHandler(
$this->createStub(HttpKernelInterface::class),
self::createStub(HttpKernelInterface::class),
$this->httpUtils
);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/UserSetting/Setting/LanguageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function testGetDefaultValue(
$this->availableLocaleChoiceLoader->method('getChoiceList')->willReturn($availableLocales);

$language = new Language(
$this->createStub(TranslatorInterface::class),
self::createStub(TranslatorInterface::class),
$this->userLanguagePreferenceProvider,
$this->availableLocaleChoiceLoader,
);
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/UserSetting/UserSettingServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class UserSettingServiceTest extends TestCase
{
public function testCountUserSettings(): void
{
$userPreferenceService = $this->createStub(UserPreferenceService::class);
$userPreferenceService = self::createStub(UserPreferenceService::class);
$valueRegistry = $this->createMock(ValueDefinitionRegistry::class);
$valueRegistry->method('countValueDefinitions')->willReturn(2);
$userSettingService = new UserSettingService($userPreferenceService, $valueRegistry);
Expand Down
16 changes: 8 additions & 8 deletions tests/lib/UserSetting/ValueDefinitionRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class ValueDefinitionRegistryTest extends TestCase
public function testGetValueDefinitions(): void
{
$definitions = [
'foo' => $this->createStub(ValueDefinitionInterface::class),
'bar' => $this->createStub(ValueDefinitionInterface::class),
'baz' => $this->createStub(ValueDefinitionInterface::class),
'foo' => self::createStub(ValueDefinitionInterface::class),
'bar' => self::createStub(ValueDefinitionInterface::class),
'baz' => self::createStub(ValueDefinitionInterface::class),
];

$registry = new ValueDefinitionRegistry($definitions);
Expand All @@ -29,7 +29,7 @@ public function testGetValueDefinitions(): void

public function testAddValueDefinition(): void
{
$foo = $this->createStub(ValueDefinitionInterface::class);
$foo = self::createStub(ValueDefinitionInterface::class);

$registry = new ValueDefinitionRegistry([]);
$registry->addValueDefinition('foo', $foo);
Expand All @@ -40,7 +40,7 @@ public function testAddValueDefinition(): void
public function testHasValueDefinition(): void
{
$registry = new ValueDefinitionRegistry([
'foo' => $this->createStub(ValueDefinitionInterface::class),
'foo' => self::createStub(ValueDefinitionInterface::class),
]);

self::assertTrue($registry->hasValueDefinition('foo'));
Expand All @@ -49,7 +49,7 @@ public function testHasValueDefinition(): void

public function testGetValueDefinition(): void
{
$foo = $this->createStub(ValueDefinitionInterface::class);
$foo = self::createStub(ValueDefinitionInterface::class);

$registry = new ValueDefinitionRegistry([
'foo' => $foo,
Expand All @@ -61,8 +61,8 @@ public function testGetValueDefinition(): void
public function testCountValueDefinitions(): void
{
$definitions = [
'foo' => $this->createStub(ValueDefinitionInterface::class),
'bar' => $this->createStub(ValueDefinitionInterface::class),
'foo' => self::createStub(ValueDefinitionInterface::class),
'bar' => self::createStub(ValueDefinitionInterface::class),
];

$registry = new ValueDefinitionRegistry($definitions);
Expand Down
20 changes: 10 additions & 10 deletions tests/lib/Validator/Constraint/PasswordValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public function testValidateShouldBeSkipped(\stdClass|string|null $value): void
public function testValid(): void
{
$password = 'pass';
$contentType = $this->createStub(ContentType::class);
$user = $this->createStub(User::class);
$contentType = self::createStub(ContentType::class);
$user = self::createStub(User::class);

$this->userService
->expects(self::once())
Expand Down Expand Up @@ -93,23 +93,23 @@ static function (string $actualPassword, PasswordValidationContext $actualContex

public function testInvalid(): void
{
$contentType = $this->createStub(ContentType::class);
$contentType = self::createStub(ContentType::class);
$password = 'pass';
$errorParameter = 'foo';
$errorMessage = 'error';

$this->userService
->expects(self::once())
->method('validatePassword')
->willReturnCallback(function (string $actualPassword, PasswordValidationContext $actualContext) use (
->willReturnCallback(static function (string $actualPassword, PasswordValidationContext $actualContext) use (
$password,
$contentType,
$errorMessage,
$errorParameter
): array {
$this->assertEquals($password, $actualPassword);
$this->assertInstanceOf(PasswordValidationContext::class, $actualContext);
$this->assertSame($contentType, $actualContext->contentType);
self::assertEquals($password, $actualPassword);
self::assertInstanceOf(PasswordValidationContext::class, $actualContext);
self::assertSame($contentType, $actualContext->contentType);

return [
new ValidationError($errorMessage, null, ['%foo%' => $errorParameter]),
Expand Down Expand Up @@ -146,7 +146,7 @@ public function testInvalid(): void

public function testPluralValidationErrorUsesPluralMessageTemplate(): void
{
$contentType = $this->createStub(ContentType::class);
$contentType = self::createStub(ContentType::class);

$this->userService
->method('validatePassword')
Expand Down Expand Up @@ -183,7 +183,7 @@ public function testKnownValidationErrorsGetRequirementCode(
string $errorMessage,
string $expectedCode
): void {
$contentType = $this->createStub(ContentType::class);
$contentType = self::createStub(ContentType::class);

$this->userService
->method('validatePassword')
Expand Down Expand Up @@ -291,7 +291,7 @@ public function testEveryCoreCharacterRuleErrorProducesRequirementCode(): void
->willReturn($constraintViolationBuilder);

$this->validator->validate('pass', new Password(
contentType: $this->createStub(ContentType::class),
contentType: self::createStub(ContentType::class),
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function testInvalid(): void
->with($apiUser, 'password')
->willReturn(false);
$constraint = new UserPassword();
$constraintViolationBuilder = $this->createStub(ConstraintViolationBuilderInterface::class);
$constraintViolationBuilder = self::createStub(ConstraintViolationBuilderInterface::class);
$this->executionContext
->expects(self::once())
->method('buildViolation')
Expand Down
Loading