Skip to content

Commit

Permalink
IBX-8121: Fixed code style for 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Steveb-p authored May 7, 2024
1 parent 4c91177 commit afd1e13
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 69 deletions.
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,17 @@
},
"require-dev": {
"behat/behat": "^3.5",
"friendsofphp/php-cs-fixer": "^3.0",
"ibexa/behat": "~5.0.x-dev",
"ibexa/ci-scripts": "^0.2@dev",
"ibexa/code-style": "^1.0",
"ibexa/code-style": "~2.0.0",
"ibexa/doctrine-schema": "~5.0.x-dev",
"ibexa/http-cache": "~5.0.x-dev",
"ibexa/notifications": "~5.0.x-dev",
"ibexa/rest": "~5.0.x-dev",
"ibexa/test-core": "~5.0.x-dev",
"ibexa/user": "^5.0.x-dev",
"matthiasnoback/symfony-dependency-injection-test": "^4.0",
"phpunit/phpunit": "^8.2"
"phpunit/phpunit": "^9.6"
},
"autoload": {
"psr-4": {
Expand Down
19 changes: 5 additions & 14 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="./bootstrap.php"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="./bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
beStrictAboutTestsThatDoNotTestAnything="false">
<php>
<ini name="error_reporting" value="-1" />
</php>
<testsuites>
<testsuite name="ContentForms tests">
<directory suffix="Test.php">./tests/lib</directory>
<directory>./tests/lib</directory>
</testsuite>
<testsuite name="ContentFormsBundle tests">
<directory suffix="Test.php">./tests/bundle</directory>
<directory>./tests/bundle</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>./src/bundle</directory>
<directory>./src/lib</directory>
</whitelist>
</filter>

</phpunit>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface GroupedContentFormFieldsProviderInterface
{
/**
* @param \Symfony\Component\Form\FormInterface[] $fieldsDataForm
*
* @phpstan-return array<string, array<int, string>> Array of fieldGroupIdentifier grouped by fieldGroupName.
*/
public function getGroupedFields(array $fieldsDataForm): array;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ public function testGetGroupedFields(): void
{
$fieldsGroupsListMock = $this->createMock(FieldsGroupsList::class);
$fieldsGroupsListMock
->expects($this->exactly(3))
->expects(self::exactly(3))
->method('getFieldGroup')
->withConsecutive()
->willReturnOnConsecutiveCalls('group_1', 'group_2', 'group_2');

$fieldsGroupsListMock
->expects($this->once())
->expects(self::once())
->method('getGroups')
->willReturn([
'group_1' => 'Group 1',
Expand Down Expand Up @@ -65,7 +65,7 @@ public function testGetGroupedFields(): void
],
];

$this->assertEquals($expected, $result);
self::assertEquals($expected, $result);
}

/**
Expand All @@ -80,15 +80,15 @@ private function getFormMockWithFieldData(
->disableOriginalConstructor()
->getMock();
$formMock
->expects($this->once())
->expects(self::once())
->method('getViewData')
->willReturn(new FieldData([
'field' => new Field(['fieldDefIdentifier' => $fieldDefIdentifier]),
'fieldDefinition' => new FieldDefinition(['fieldTypeIdentifier' => $fieldTypeIdentifier]),
'value' => new Value('value'),
]));
$formMock
->expects($this->once())
->expects(self::once())
->method('getName')
->willReturn($fieldDefIdentifier);

Expand Down
20 changes: 10 additions & 10 deletions tests/lib/FieldType/DataTransformer/FieldValueTransformerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ public function testTransformNull()

$fieldType = $this->createMock(FieldType::class);
$fieldType
->expects($this->never())
->expects(self::never())
->method('toHash');

$result = (new FieldValueTransformer($fieldType))->transform($value);

$this->assertNull($result);
self::assertNull($result);
}

public function testTransform()
Expand All @@ -37,14 +37,14 @@ public function testTransform()

$fieldType = $this->createMock(FieldType::class);
$fieldType
->expects($this->once())
->expects(self::once())
->method('toHash')
->with($value)
->willReturn($valueHash);

$result = (new FieldValueTransformer($fieldType))->transform($value);

$this->assertEquals($result, $valueHash);
self::assertEquals($result, $valueHash);
}

public function testReverseTransformNull()
Expand All @@ -53,16 +53,16 @@ public function testReverseTransformNull()

$fieldType = $this->createMock(FieldType::class);
$fieldType
->expects($this->once())
->expects(self::once())
->method('getEmptyValue')
->willReturn($emptyValue);
$fieldType
->expects($this->never())
->expects(self::never())
->method('fromHash');

$result = (new FieldValueTransformer($fieldType))->reverseTransform(null);

$this->assertSame($emptyValue, $result);
self::assertSame($emptyValue, $result);
}

public function testReverseTransform()
Expand All @@ -72,16 +72,16 @@ public function testReverseTransform()

$fieldType = $this->createMock(FieldType::class);
$fieldType
->expects($this->never())
->expects(self::never())
->method('getEmptyValue');
$fieldType
->expects($this->once())
->expects(self::once())
->method('fromHash')
->willReturn($expected);

$result = (new FieldValueTransformer($fieldType))->reverseTransform($value);

$this->assertSame($expected, $result);
self::assertSame($expected, $result);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function testReverseTransform($value, ?Value $expectedValue): void
{
$transformer = new RelationListValueTransformer();

$this->assertEquals(
self::assertEquals(
$expectedValue,
$transformer->reverseTransform($value)
);
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()
$formMock = $this->createMock(FormInterface::class);

$this->fieldValueMapperMock
->expects($this->once())
->expects(self::once())
->method('mapFieldValueForm')
->with($formMock, $data);

Expand Down
14 changes: 7 additions & 7 deletions tests/lib/FieldType/Mapper/BaseMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected function setUp(): void
$this->fieldTypeService = $this->getMockBuilder(FieldTypeService::class)
->getMock();
$this->fieldTypeService
->expects($this->any())
->expects(self::any())
->method('getFieldType')
->willReturn($this->getMockBuilder(FieldType::class)->getMock());

Expand All @@ -40,25 +40,25 @@ protected function setUp(): void
$formFactory = $this->getMockBuilder(FormFactoryInterface::class)
->setMethods(['addModelTransformer', 'setAutoInitialize', 'getForm'])
->getMockForAbstractClass();
$formFactory->expects($this->once())
$formFactory->expects(self::once())
->method('createBuilder')
->willReturn($formFactory);
$formFactory->expects($this->once())
$formFactory->expects(self::once())
->method('create')
->willReturn($formFactory);
$formFactory->expects($this->once())
$formFactory->expects(self::once())
->method('addModelTransformer')
->willReturn($formFactory);
$formFactory->expects($this->once())
$formFactory->expects(self::once())
->method('setAutoInitialize')
->willReturn($formFactory);

$this->config->expects($this->once())
$this->config->expects(self::once())
->method('getFormFactory')
->willReturn($formFactory);

$this->fieldForm = $this->getMockBuilder(FormInterface::class)->getMock();
$this->fieldForm->expects($this->once())
$this->fieldForm->expects(self::once())
->method('getConfig')
->willReturn($this->config);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function testMapFieldValueFormNoLanguageCode()
'fieldSettings' => ['isMultiple' => false, 'options' => []],
]);

$this->data->expects($this->once())
$this->data->expects(self::once())
->method('__get')
->with('fieldDefinition')
->willReturn($fieldDefinition);
Expand All @@ -49,7 +49,7 @@ public function testMapFieldValueFormWithLanguageCode()
'fieldTypeIdentifier' => 'ezselection',
'fieldSettings' => ['isMultiple' => false, 'options' => []],
]);
$this->data->expects($this->once())
$this->data->expects(self::once())
->method('__get')
->with('fieldDefinition')
->willReturn($fieldDefinition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function testMapFieldValueFormNoLanguageCode()

$fieldDefinition = new FieldDefinition(['names' => []]);

$this->data->expects($this->once())
$this->data->expects(self::once())
->method('__get')
->with('fieldDefinition')
->willReturn($fieldDefinition);
Expand All @@ -71,7 +71,7 @@ public function testMapFieldValueFormWithLanguageCode()

$fieldDefinition = new FieldDefinition(['names' => ['eng-GB' => 'foo']]);

$this->data->expects($this->once())
$this->data->expects(self::once())
->method('__get')
->with('fieldDefinition')
->willReturn($fieldDefinition);
Expand Down
6 changes: 3 additions & 3 deletions tests/lib/Validator/Constraints/PasswordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ protected function setUp(): void

public function testConstruct()
{
$this->assertSame('ez.user.password.invalid', $this->constraint->message);
self::assertSame('ez.user.password.invalid', $this->constraint->message);
}

public function testValidatedBy()
{
$this->assertSame(PasswordValidator::class, $this->constraint->validatedBy());
self::assertSame(PasswordValidator::class, $this->constraint->validatedBy());
}

public function testGetTargets()
{
$this->assertSame([Password::CLASS_CONSTRAINT, Password::PROPERTY_CONSTRAINT], $this->constraint->getTargets());
self::assertSame([Password::CLASS_CONSTRAINT, Password::PROPERTY_CONSTRAINT], $this->constraint->getTargets());
}
}

Expand Down
18 changes: 9 additions & 9 deletions tests/lib/Validator/Constraints/PasswordValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ protected function setUp(): void
public function testValidateShouldBeSkipped($value)
{
$this->userService
->expects($this->never())
->expects(self::never())
->method('validatePassword');

$this->executionContext
->expects($this->never())
->expects(self::never())
->method('buildViolation');

$this->validator->validate($value, new Password());
Expand All @@ -59,7 +59,7 @@ public function testValid()
$contentType = $this->createMock(ContentType::class);

$this->userService
->expects($this->once())
->expects(self::once())
->method('validatePassword')
->willReturnCallback(function ($actualPassword, $actualContext) use ($password, $contentType) {
$this->assertEquals($password, $actualPassword);
Expand All @@ -70,7 +70,7 @@ public function testValid()
});

$this->executionContext
->expects($this->never())
->expects(self::never())
->method('buildViolation');

$this->validator->validate($password, new Password([
Expand All @@ -86,7 +86,7 @@ public function testInvalid()
$errorMessage = 'error';

$this->userService
->expects($this->once())
->expects(self::once())
->method('validatePassword')
->willReturnCallback(function ($actualPassword, $actualContext) use ($password, $contentType, $errorMessage, $errorParameter) {
$this->assertEquals($password, $actualPassword);
Expand All @@ -101,21 +101,21 @@ public function testInvalid()
$constraintViolationBuilder = $this->createMock(ConstraintViolationBuilderInterface::class);

$this->executionContext
->expects($this->once())
->expects(self::once())
->method('buildViolation')
->willReturn($constraintViolationBuilder);
$this->executionContext
->expects($this->once())
->expects(self::once())
->method('buildViolation')
->with($errorMessage)
->willReturn($constraintViolationBuilder);
$constraintViolationBuilder
->expects($this->once())
->expects(self::once())
->method('setParameters')
->with(['%foo%' => $errorParameter])
->willReturn($constraintViolationBuilder);
$constraintViolationBuilder
->expects($this->once())
->expects(self::once())
->method('addViolation');

$this->validator->validate('pass', new Password([
Expand Down
6 changes: 3 additions & 3 deletions tests/lib/Validator/Constraints/UserAccountPasswordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ protected function setUp(): void

public function testConstruct()
{
$this->assertSame('ez.user.password.invalid', $this->constraint->message);
self::assertSame('ez.user.password.invalid', $this->constraint->message);
}

public function testValidatedBy()
{
$this->assertSame(UserAccountPasswordValidator::class, $this->constraint->validatedBy());
self::assertSame(UserAccountPasswordValidator::class, $this->constraint->validatedBy());
}

public function testGetTargets()
{
$this->assertSame([UserAccountPassword::CLASS_CONSTRAINT, UserAccountPassword::PROPERTY_CONSTRAINT], $this->constraint->getTargets());
self::assertSame([UserAccountPassword::CLASS_CONSTRAINT, UserAccountPassword::PROPERTY_CONSTRAINT], $this->constraint->getTargets());
}
}

Expand Down
Loading

0 comments on commit afd1e13

Please sign in to comment.