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 @@ -31,6 +31,7 @@
"ibexa/doctrine-schema": "~6.0.x-dev",
"ibexa/http-cache": "~6.0.x-dev",
"ibexa/notifications": "~6.0.x-dev",
"ibexa/phpstan": "~6.0.x-dev",
"ibexa/rector": "~6.0.x-dev",
"ibexa/rest": "~6.0.x-dev",
"ibexa/test-core": "~6.0.x-dev",
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
includes:
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-symfony/extension.neon
- vendor/ibexa/phpstan/extension.neon
- phpstan-baseline.neon

parameters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function getModelTransformerForTranslation(FieldDefinition $fieldDefiniti
static function (ApiUserValue $data): UserAccountFieldData {
return new UserAccountFieldData($data->login, null, $data->email, $data->enabled);
},
static function (UserAccountFieldData $submittedData) use ($fieldDefinition) {
static function (UserAccountFieldData $submittedData) use ($fieldDefinition): ApiUserValue {
/** @var \Ibexa\Core\FieldType\User\Value $userValue */
$userValue = clone $fieldDefinition->defaultValue;

Expand Down
8 changes: 4 additions & 4 deletions tests/lib/Event/FormActionEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class FormActionEventTest extends TestCase
{
public function testConstruct(): void
{
$form = $this->createStub(FormInterface::class);
$form = self::createStub(FormInterface::class);
$data = new stdClass();
$clickedButton = 'fooButton';
$options = ['languageCode' => 'eng-GB', 'foo' => 'bar'];
Expand All @@ -33,7 +33,7 @@ public function testConstruct(): void
public function testEventDoesntHaveResponse(): void
{
$event = new FormActionEvent(
$this->createStub(FormInterface::class),
self::createStub(FormInterface::class),
new stdClass(),
'fooButton'
);
Expand All @@ -44,7 +44,7 @@ public function testEventDoesntHaveResponse(): void
public function testEventSetResponse(): void
{
$event = new FormActionEvent(
$this->createStub(FormInterface::class),
self::createStub(FormInterface::class),
new stdClass(),
'fooButton'
);
Expand All @@ -63,7 +63,7 @@ public function testGetOption(): void
$options = ['languageCode' => 'eng-GB', 'foo' => 'bar', 'obj' => $objectOption];

$event = new FormActionEvent(
$this->createStub(FormInterface::class),
self::createStub(FormInterface::class),
new stdClass(),
'fooButton',
$options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function testTransformNull(): void

public function testTransform(): void
{
$value = $this->createStub(Value::class);
$value = self::createStub(Value::class);
$valueHash = ['lorem' => 'Lorem ipsum dolor...'];

$fieldType = $this->createMock(FieldType::class);
Expand All @@ -49,7 +49,7 @@ public function testTransform(): void

public function testReverseTransformNull(): void
{
$emptyValue = $this->createStub(Value::class);
$emptyValue = self::createStub(Value::class);

$fieldType = $this->createMock(FieldType::class);
$fieldType
Expand All @@ -68,7 +68,7 @@ public function testReverseTransformNull(): void
public function testReverseTransform(): void
{
$value = 'Lorem ipsum dolor...';
$expected = $this->createStub(Value::class);
$expected = self::createStub(Value::class);

$fieldType = $this->createMock(FieldType::class);
$fieldType
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/FieldType/FieldTypeFormMapperDispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function testMapFieldValue(): void
'fieldDefinition' => new FieldDefinition(['fieldTypeIdentifier' => 'first_type']),
]);

$formMock = $this->createStub(FormInterface::class);
$formMock = self::createStub(FormInterface::class);

$this->fieldTypeAliasResolverMock
->method('resolveIdentifier')
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/FieldType/Mapper/BaseMapperTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ protected function setUp(): void
$this->fieldTypeService = $this->createMock(FieldTypeService::class);
$this->fieldTypeService
->method('getFieldType')
->willReturn($this->createStub(FieldType::class));
->willReturn(self::createStub(FieldType::class));

$this->config = $this->createMock(FormConfigInterface::class);
$this->fieldForm = $this->createMock(FormInterface::class);
$formFactory = $this->createMock(FormFactoryInterface::class);
$formFactory
->expects(self::once())
->method('createBuilder')
->willReturn($this->createStub(FormBuilder::class));
->willReturn(self::createStub(FormBuilder::class));

$this->config
->expects(self::once())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class FixUrlProtocolListenerTest extends TestCase
#[DataProvider('provideUrlCases')]
public function testUrlProtocolHandling(?string $inputData, ?string $expectedData, string $defaultProtocol = 'https'): void
{
$form = $this->createStub(FormInterface::class);
$form = self::createStub(FormInterface::class);
$listener = new FixUrlProtocolListener($defaultProtocol);

$event = new FormEvent($form, $inputData);
Expand Down
18 changes: 9 additions & 9 deletions tests/lib/Form/Processor/ContentFormProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ public function testProcessPublish(

// The deferred (async) redirect resolves its location from the content tree root config
// and the location lookup.
$configResolver = $this->createStub(ConfigResolverInterface::class);
$configResolver = self::createStub(ConfigResolverInterface::class);
$configResolver->method('getParameter')->willReturn(self::TREE_ROOT_LOCATION_ID);

$locationService = $this->createStub(LocationService::class);
$locationService = self::createStub(LocationService::class);
$locationService->method('loadLocation')->willReturn(
new Location([
'id' => self::TREE_ROOT_LOCATION_ID,
Expand Down Expand Up @@ -242,16 +242,16 @@ private function createDraft(?int $mainLocationId, int $status): Content
'status' => $status,
]);

$versionInfo = $this->createStub(VersionInfo::class);
$versionInfo = self::createStub(VersionInfo::class);
$versionInfo->method('getInitialLanguage')->willReturn(
new Language(['languageCode' => self::LANGUAGE_CODE])
);
$versionInfo->method('getContentInfo')->willReturn($contentInfo);

$draft = $this->createStub(Content::class);
$draft = self::createStub(Content::class);
$draft->method('getVersionInfo')->willReturn($versionInfo);
$draft->method('getContentInfo')->willReturn($contentInfo);
$draft->method('getContentType')->willReturn($this->createStub(ContentType::class));
$draft->method('getContentType')->willReturn(self::createStub(ContentType::class));

return $draft;
}
Expand All @@ -265,7 +265,7 @@ private function createPublishedContent(): Content
'status' => ContentInfo::STATUS_PUBLISHED,
]);

$publishedContent = $this->createStub(Content::class);
$publishedContent = self::createStub(Content::class);
$publishedContent->method('getContentInfo')->willReturn($contentInfo);
$publishedContent->method('getId')->willReturn(self::CONTENT_ID);

Expand Down Expand Up @@ -293,13 +293,13 @@ private function createCreateData(): ContentCreateData
*/
private function createForm(?string $redirectUrlAfterPublish = null): FormInterface
{
$formConfig = $this->createStub(FormConfigInterface::class);
$formConfig = self::createStub(FormConfigInterface::class);
$formConfig->method('getOption')->willReturn(self::LANGUAGE_CODE);

$redirectUrlField = $this->createStub(FormInterface::class);
$redirectUrlField = self::createStub(FormInterface::class);
$redirectUrlField->method('getData')->willReturn($redirectUrlAfterPublish);

$form = $this->createStub(FormInterface::class);
$form = self::createStub(FormInterface::class);
$form->method('getConfig')->willReturn($formConfig);
$form->method('offsetGet')->willReturn($redirectUrlField);

Expand Down
2 changes: 1 addition & 1 deletion tests/lib/Validator/Constraints/PasswordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function testGetTargets(): void

public function testNamedArguments(): void
{
$contentType = $this->createStub(ContentType::class);
$contentType = self::createStub(ContentType::class);
$payload = new \stdClass();

$constraint = new Password(
Expand Down
20 changes: 10 additions & 10 deletions tests/lib/Validator/Constraints/PasswordValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ public function testValidateShouldBeSkipped(mixed $value): void
public function testValid(): void
{
$password = 'pass';
$contentType = $this->createStub(ContentType::class);
$contentType = self::createStub(ContentType::class);

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

return [];
});
Expand All @@ -76,18 +76,18 @@ public function testValid(): void

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 ($actualPassword, $actualContext) use ($password, $contentType, $errorMessage, $errorParameter): array {
$this->assertEquals($password, $actualPassword);
$this->assertInstanceOf(PasswordValidationContext::class, $actualContext);
$this->assertSame($contentType, $actualContext->contentType);
->willReturnCallback(static function ($actualPassword, $actualContext) use ($password, $contentType, $errorMessage, $errorParameter): array {
self::assertEquals($password, $actualPassword);
self::assertInstanceOf(PasswordValidationContext::class, $actualContext);
self::assertSame($contentType, $actualContext->contentType);

return [
new ValidationError($errorMessage, null, ['%foo%' => $errorParameter]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testGetTargets(): void

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

$constraint = new UserAccountPassword(contentType: $contentType);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ public static function dataProviderForValidateNotSupportedValueType(): array
public function testValid(): void
{
$userAccount = new UserAccountFieldData('user', 'pass', 'user@ibexa.co');
$contentType = $this->createStub(ContentType::class);
$contentType = self::createStub(ContentType::class);

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

return [];
});
Expand All @@ -85,18 +85,18 @@ public function testValid(): void

public function testInvalid(): void
{
$contentType = $this->createStub(ContentType::class);
$contentType = self::createStub(ContentType::class);
$userAccount = new UserAccountFieldData('user', 'pass', 'user@ibexa.co');
$errorParameter = 'foo';
$errorMessage = 'error';

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

return [
new ValidationError($errorMessage, null, ['%foo%' => $errorParameter]),
Expand Down
Loading