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
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@
"ibexa/rest": "~5.0.x-dev",
"ibexa/test-core": "~5.0.x-dev",
"matthiasnoback/symfony-dependency-injection-test": "^5.0",
"phpunit/phpunit": "^9.6",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-phpunit": "^2.0",
"phpstan/phpstan-symfony": "^2.0"
"phpstan/phpstan-symfony": "^2.0",
"phpunit/phpunit": "^9.6",
"webmozart/assert": "^2.3"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ parameters:
path: src/lib/Form/Type/FieldType/AuthorFieldType.php

-
message: '#^Method Ibexa\\ContentForms\\Form\\Type\\FieldType\\AuthorFieldType\:\:getViewTransformer\(\) return type with generic interface Symfony\\Component\\Form\\DataTransformerInterface does not specify its types\: T, R$#'
message: '#^Method Ibexa\\ContentForms\\Form\\Type\\FieldType\\AuthorFieldType\:\:getViewTransformer\(\) return type with generic interface Symfony\\Component\\Form\\DataTransformerInterface does not specify its types\: TValue, TTransformedValue$#'
identifier: missingType.generics
count: 1
path: src/lib/Form/Type/FieldType/AuthorFieldType.php
Expand Down
7 changes: 4 additions & 3 deletions src/lib/Behat/Context/ContentTypeContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeCreateStruct;
use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinitionUpdateStruct;
use Ibexa\Core\Repository\Values\User\UserReference;
use PHPUnit\Framework\Assert as Assertion;
use RuntimeException;
use Webmozart\Assert\Assert as Assertion;

final class ContentTypeContext extends RawMinkContext implements Context, SnippetAcceptingContext
{
Expand All @@ -38,9 +39,9 @@
{
try {
$contentType = $this->contentTypeService->loadContentTypeByIdentifier($contentTypeIdentifier);
Assertion::assertEquals($id, $contentType->id);
Assertion::eq($contentType->id, $id);
} catch (NotFoundException) {
Assertion::fail("No ContentType with the identifier '$contentTypeIdentifier' could be found.");
throw new RuntimeException("No ContentType with the identifier '$contentTypeIdentifier' could be found.");

Check warning on line 44 in src/lib/Behat/Context/ContentTypeContext.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define and throw a dedicated exception instead of using a generic one.

See more on https://sonarcloud.io/project/issues?id=ibexa_content-forms&issues=AZ5Kck2gHrwM9G6BNVD0&open=AZ5Kck2gHrwM9G6BNVD0&pullRequest=110
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/lib/Behat/Context/FieldTypeFormContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Behat\MinkExtension\Context\RawMinkContext;
use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinitionCreateStruct;
use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinitionUpdateStruct;
use PHPUnit\Framework\Assert as Assertion;
use Webmozart\Assert\Assert as Assertion;

final class FieldTypeFormContext extends RawMinkContext implements SnippetAcceptingContext
{
Expand Down Expand Up @@ -154,7 +154,7 @@ public function itShouldContainTheFollowingSetOfLabelsAndInputFieldsTypes(TableN
}

foreach ($table->getColumnsHash() as $expectedField) {
Assertion::assertContains($expectedField, $actualInputFields);
Assertion::inArray($expectedField, $actualInputFields);
}
}

Expand Down Expand Up @@ -184,7 +184,7 @@ public function theInputFieldsShouldBeFlaggedAsRequired(string $fieldTypeIdentif
)
);

Assertion::assertNotEmpty($inputNodeElements, 'The input field is not marked as required');
Assertion::notEmpty($inputNodeElements, 'The input field is not marked as required');

$exceptions = $this->getRequiredFieldTypeExceptions($fieldTypeIdentifier);

Expand All @@ -194,9 +194,9 @@ public function theInputFieldsShouldBeFlaggedAsRequired(string $fieldTypeIdentif

$expectedState = array_key_exists($label, $exceptions) ? $exceptions[$label] : true;

Assertion::assertEquals(
$expectedState,
Assertion::eq(
$inputNodeElement->hasAttribute('required'),
$expectedState,
sprintf(
'%s input with id %s is not flagged as required',
$inputNodeElement->getAttribute('type'),
Expand Down
6 changes: 3 additions & 3 deletions src/lib/Behat/Context/PagelayoutContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\MinkExtension\Context\RawMinkContext;
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
use PHPUnit\Framework\Assert as Assertion;
use Webmozart\Assert\Assert as Assertion;

final class PagelayoutContext extends RawMinkContext implements Context, SnippetAcceptingContext
{
Expand All @@ -29,7 +29,7 @@ public function __construct(
*/
public function aPagelayoutIsConfigured(): void
{
Assertion::assertTrue($this->configResolver->hasParameter('page_layout'));
Assertion::true($this->configResolver->hasParameter('page_layout'));
}

/**
Expand All @@ -40,7 +40,7 @@ public function itIsRenderedUsingTheConfiguredPagelayout(): void
$pageLayout = $this->getPageLayout();

$searchedPattern = sprintf(self::TWIG_DEBUG_STOP_REGEX, preg_quote($pageLayout, null));
Assertion::assertMatchesRegularExpression($searchedPattern, $this->getSession()->getPage()->getOuterHtml());
Assertion::regex($this->getSession()->getPage()->getOuterHtml(), $searchedPattern);
}

public function getPageLayout(): string
Expand Down
8 changes: 4 additions & 4 deletions src/lib/Behat/Context/SelectionFieldTypeFormContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\MinkExtension\Context\RawMinkContext;
use PHPUnit\Framework\Assert as Assertion;
use Webmozart\Assert\Assert as Assertion;

final class SelectionFieldTypeFormContext extends RawMinkContext implements SnippetAcceptingContext
{
Expand Down Expand Up @@ -68,11 +68,11 @@ public function theSelectFieldShouldBeFlaggedAsRequired(): void
self::$fieldIdentifier
)
);
Assertion::assertNotEmpty($nodeElements, 'The select field is not marked as required');
Assertion::notEmpty($nodeElements, 'The select field is not marked as required');
foreach ($nodeElements as $nodeElement) {
Assertion::assertEquals(
'required',
Assertion::eq(
$nodeElement->getAttribute('required'),
'required',
sprintf(
'The select with ID %s is not flagged as required',
$nodeElement->getAttribute('id')
Expand Down
10 changes: 5 additions & 5 deletions src/lib/Behat/Context/UserRegistrationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
use Ibexa\Contracts\Core\Repository\Values\User\UserGroup;
use Ibexa\Core\Repository\Values\User\RoleCreateStruct;
use Ibexa\Core\Repository\Values\User\UserReference;
use PHPUnit\Framework\Assert as Assertion;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Yaml\Yaml;
use Webmozart\Assert\Assert as Assertion;

final class UserRegistrationContext extends RawMinkContext implements Context, SnippetAcceptingContext
{
Expand Down Expand Up @@ -295,9 +295,9 @@ public function theUserIsCreatedInThisUserGroup(string $userGroupName): void
$user = $this->userService->loadUserByLogin($this->registrationUsername);
$userGroups = $this->userService->loadUserGroupsOfUser($user);

Assertion::assertEquals(
$userGroupName,
$userGroups[0]->getName()
Assertion::eq(
$userGroups[0]->getName(),
$userGroupName
);
}

Expand Down Expand Up @@ -343,7 +343,7 @@ public function thePageIsRenderedUsingTheTemplateConfiguredIn(string $template):
$found = preg_match($searchedPattern, $html) === 1;
}

Assertion::assertTrue(
Assertion::true(
$found,
"Couldn't find $template " .
(isset($alternativeTemplate) ? "nor $alternativeTemplate " : ' ') .
Expand Down
Loading