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
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
"phpstan/phpstan-symfony": "^2.0",
"phpunit/phpunit": "^9.6",
"symfony/phpunit-bridge": "^7.4",
"symfony/runtime": "^7.4"
"symfony/runtime": "^7.4",
"webmozart/assert": "^2.3"
},
"conflict": {
"doctrine/dbal": "2.7.0",
Expand Down
8 changes: 1 addition & 7 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2196,12 +2196,6 @@ parameters:
count: 1
path: src/bundle/Core/Features/Context/ContentPreviewContext.php

-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertTrue\(\) with false and non\-falsy\-string will always evaluate to false\.$#'
identifier: staticMethod.impossibleType
count: 1
path: src/bundle/Core/Features/Context/ContentPreviewContext.php

-
message: '#^Method Ibexa\\Bundle\\Core\\Features\\Context\\ContentPreviewContext\:\:checkForExceptions\(\) has no return type specified\.$#'
identifier: missingType.return
Expand Down Expand Up @@ -7441,7 +7435,7 @@ parameters:
path: src/lib/FieldType/ValueSerializer/SymfonySerializerAdapter.php

-
message: '#^Method Ibexa\\Core\\FieldType\\ValueSerializer\\SymfonySerializerAdapter\:\:normalize\(\) should return array\|null but returns array\|ArrayObject\|bool\|float\|int\|string\|null\.$#'
message: '#^Method Ibexa\\Core\\FieldType\\ValueSerializer\\SymfonySerializerAdapter\:\:normalize\(\) should return array\|null but returns array\<mixed\>\|ArrayObject\<\(int\|string\), mixed\>\|bool\|float\|int\|string\|null\.$#'
identifier: return.type
count: 1
path: src/lib/FieldType/ValueSerializer/SymfonySerializerAdapter.php
Expand Down
18 changes: 9 additions & 9 deletions src/bundle/Core/Features/Context/ConsoleContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

use Behat\Behat\Context\Context;
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
use PHPUnit\Framework\Assert as Assertion;
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Process;
use Webmozart\Assert\Assert as Assertion;

class ConsoleContext implements Context
{
Expand Down Expand Up @@ -70,9 +70,9 @@ public function iRunAConsoleScriptWithSiteaccess($siteaccessOption)
public function iExpectItToBeExecutedWithTheSiteaccess($siteaccess)
{
$actualSiteaccess = trim($this->scriptOutput);
Assertion::assertEquals(
$siteaccess,
Assertion::eq(
$actualSiteaccess,
$siteaccess,
"The command was expected to be executed with the siteaccess \"$siteaccess\", but was executed with \"$actualSiteaccess\""
);
}
Expand Down Expand Up @@ -101,7 +101,7 @@ public function thereIsASiteaccess($expectedSiteaccessName, $default = false)
}
}

Assertion::assertTrue($found, "No siteaccess named $expectedSiteaccessName was found");
Assertion::true($found, "No siteaccess named $expectedSiteaccessName was found");
$this->it['siteaccess'] = $expectedSiteaccessName;
}

Expand All @@ -111,9 +111,9 @@ public function thereIsASiteaccess($expectedSiteaccessName, $default = false)
public function thereIsADefaultSiteaccess($expectedSiteaccessName)
{
$this->thereIsASiteaccess($expectedSiteaccessName, true);
Assertion::assertEquals(
$expectedSiteaccessName,
$siteaccessList = $this->getConfigResolver()->getParameter('siteaccess.default_siteaccess')
Assertion::eq(
$this->getConfigResolver()->getParameter('siteaccess.default_siteaccess'),
$expectedSiteaccessName
);
}

Expand Down Expand Up @@ -167,7 +167,7 @@ private function iRunTheCommand($command, $siteaccess = null)
public function thereIsASiteaccessThatIsNotTheDefaultOne()
{
$siteaccessName = $this->getNonDefaultSiteaccessName();
Assertion::assertNotNull($siteaccessName, 'There is no siteaccess other than the default one');
Assertion::notNull($siteaccessName, 'There is no siteaccess other than the default one');
$this->it['siteaccess'] = $siteaccessName;
}

Expand All @@ -176,7 +176,7 @@ public function thereIsASiteaccessThatIsNotTheDefaultOne()
*/
public function iExpectItToBeExecutedWithIt()
{
Assertion::assertEquals($this->it['siteaccess'], $this->scriptOutput);
Assertion::eq($this->scriptOutput, $this->it['siteaccess']);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/bundle/Core/Features/Context/ContentPreviewContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\MinkExtension\Context\RawMinkContext;
use Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo;
use PHPUnit\Framework\Assert as Assertion;
use Webmozart\Assert\Assert as Assertion;

class ContentPreviewContext extends RawMinkContext
{
Expand Down Expand Up @@ -86,7 +86,7 @@ protected function checkForExceptions()
$exceptionLines[] = trim($html);
}
$message = 'An exception occured during rendering:' . implode("\n", $exceptionLines);
Assertion::assertTrue(false, $message);
Assertion::true(false, $message);
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/bundle/Core/Features/Context/ContentTypeContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Behat\Gherkin\Node\TableNode;
use Ibexa\Contracts\Core\Repository\ContentTypeService;
use Ibexa\Contracts\Core\Repository\Exceptions as ApiExceptions;
use PHPUnit\Framework\Assert as Assertion;
use Webmozart\Assert\Assert as Assertion;

/**
* Sentences for content types.
Expand Down Expand Up @@ -81,7 +81,7 @@ public function ensureContentTypeDoesntExist($identifier)
*/
public function assertContentTypeExistsByIdentifier($identifier)
{
Assertion::assertTrue(
Assertion::true(
$this->checkContentTypeExistenceByIdentifier($identifier),
"Couldn't find a content type with identifier '$identifier'."
);
Expand All @@ -94,7 +94,7 @@ public function assertContentTypeExistsByIdentifier($identifier)
*/
public function assertContentTypeDoesntExistsByIdentifier($identifier)
{
Assertion::assertFalse(
Assertion::false(
$this->checkContentTypeExistenceByIdentifier($identifier),
"Found a content type with identifier '$identifier'."
);
Expand All @@ -107,7 +107,7 @@ public function assertContentTypeDoesntExistsByIdentifier($identifier)
*/
public function assertContentTypeExistsByIdentifierOnGroup($identifier, $groupIdentifier)
{
Assertion::assertTrue(
Assertion::true(
$this->checkContentTypeExistenceByIdentifier($identifier, $groupIdentifier),
"Couldn't find content type with identifier '$identifier' on '$groupIdentifier."
);
Expand Down
12 changes: 6 additions & 6 deletions src/bundle/Core/Features/Context/QueryControllerContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace Ibexa\Bundle\Core\Features\Context;

use Behat\MinkExtension\Context\RawMinkContext;
use PHPUnit\Framework\Assert;
use Webmozart\Assert\Assert;

class QueryControllerContext extends RawMinkContext
{
Expand All @@ -19,7 +19,7 @@ public function theQueryResultsAreAssignedToTheTwigVariable($twigVariableName)
{
$variableTypes = $this->getVariableTypesFromTemplate();

Assert::assertArrayHasKey($twigVariableName, $variableTypes, "The $twigVariableName twig variable was not set");
Assert::keyExists($variableTypes, $twigVariableName, "The $twigVariableName twig variable was not set");
}

/**
Expand All @@ -29,8 +29,8 @@ public function theQueryResultsAssignedToTheTwigVariableIsAObject($twigVariableN
{
$variableTypes = $this->getVariableTypesFromTemplate();

Assert::assertArrayHasKey($twigVariableName, $variableTypes, "The $twigVariableName twig variable was not set");
Assert::assertEquals($className, $variableTypes[$twigVariableName], "The $twigVariableName twig variable does not have $className type");
Assert::keyExists($variableTypes, $twigVariableName, "The $twigVariableName twig variable was not set");
Assert::eq($variableTypes[$twigVariableName], $className, "The $twigVariableName twig variable does not have $className type");
}

/**
Expand Down Expand Up @@ -59,12 +59,12 @@ public function theQueryResultsAssignedToTheTwigVariableIsAObjectAndHasLimitAndC
}
}

Assert::assertTrue(
Assert::true(
$pageLimitFound,
"The maxPerPage $pageLimit twig variable was not set"
);

Assert::assertTrue(
Assert::true(
$currentPageFound,
"The currentPage $pageValue twig variable was not set"
);
Expand Down
14 changes: 7 additions & 7 deletions src/bundle/Core/Features/Context/RoleContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Behat\Behat\Context\Context;
use Ibexa\Contracts\Core\Repository\Exceptions as ApiExceptions;
use Ibexa\Contracts\Core\Repository\RoleService;
use PHPUnit\Framework\Assert as Assertion;
use Webmozart\Assert\Assert as Assertion;

/**
* Sentences for Roles.
Expand Down Expand Up @@ -85,7 +85,7 @@ public function iHaveRole($name)
public function iSeeRole($name)
{
$role = $this->getRole($name);
Assertion::assertNotNull(
Assertion::notNull(
$role,
"Couldn't find Role with name $name"
);
Expand All @@ -97,12 +97,12 @@ public function iSeeRole($name)
public function noAssginedPolicies($name)
{
$role = $this->getRole($name);
Assertion::assertNotNull(
Assertion::notNull(
$role,
"Couldn't find Role with name $name"
);
$policies = $role->getPolicies();
Assertion::assertEmpty($policies, "Role $name has policies associated");
Assertion::isEmpty($policies, "Role $name has policies associated");
}

/**
Expand All @@ -111,12 +111,12 @@ public function noAssginedPolicies($name)
public function noAssigneGroups($name)
{
$role = $this->getRole($name);
Assertion::assertNotNull(
Assertion::notNull(
$role,
"Couldn't find Role with name $name"
);
$roleAssigments = $this->roleService->getRoleAssignments($role);
Assertion::assertEmpty($roleAssigments, "Role $name has Users or groups associated");
Assertion::isEmpty($roleAssigments, "Role $name has Users or groups associated");
}

/**
Expand All @@ -127,7 +127,7 @@ public function noAssigneGroups($name)
public function iDontSeeRole($name)
{
$role = $this->getRole($name);
Assertion::assertNull(
Assertion::null(
$role,
"Found Role with name $name"
);
Expand Down
18 changes: 9 additions & 9 deletions src/bundle/Core/Features/Context/UserContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Ibexa\Contracts\Core\Repository\UserService;
use Ibexa\Contracts\Core\Repository\Values\Content\Query;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion;
use PHPUnit\Framework\Assert as Assertion;
use Webmozart\Assert\Assert as Assertion;

/**
* Sentences for Users.
Expand Down Expand Up @@ -427,7 +427,7 @@ public function iHaveTheFollowingUsers(TableNode $table)
*/
public function assertUserWithNameExists($username)
{
Assertion::assertTrue(
Assertion::true(
$this->checkUserExistenceByUsername($username),
"Couldn't find User with name '$username'."
);
Expand All @@ -440,7 +440,7 @@ public function assertUserWithNameExists($username)
*/
public function assertUserWithNameDoesntExist($username)
{
Assertion::assertFalse(
Assertion::false(
$this->checkUserExistenceByUsername($username),
"User with name '$username' was found."
);
Expand All @@ -454,7 +454,7 @@ public function assertUserWithNameDoesntExist($username)
*/
public function assertUserWithNameExistsInGroup($username, $parentGroup)
{
Assertion::assertTrue(
Assertion::true(
$this->checkUserExistenceByUsername($username, $parentGroup),
"Couldn't find User with name '$username' in parent group '$parentGroup'."
);
Expand All @@ -468,7 +468,7 @@ public function assertUserWithNameExistsInGroup($username, $parentGroup)
*/
public function assertUserWithNameDoesntExistInGroup($username, $parentGroup)
{
Assertion::assertFalse(
Assertion::false(
$this->checkUserExistenceByUsername($username, $parentGroup),
"User with name '$username' was found in parent group '$parentGroup'."
);
Expand All @@ -490,7 +490,7 @@ public function assertUserWithNameDoesntExistInGroups($username, TableNode $tabl
array_shift($groups);
foreach ($groups as $group) {
$parentGroupName = $group[0];
Assertion::assertFalse(
Assertion::false(
$this->checkUserExistenceByUsername($username, $parentGroupName),
"User with name '$username' was found in parent group '$parentGroupName'."
);
Expand All @@ -510,7 +510,7 @@ public function assertUserWithNameDoesntExistInGroups($username, TableNode $tabl
*/
public function assertUserWithNameExistsWithFields($username, TableNode $table)
{
Assertion::assertTrue(
Assertion::true(
$this->checkUserExistenceByUsername($username),
"Couldn't find User with name '$username'."
);
Expand All @@ -532,9 +532,9 @@ public function assertUserWithNameExistsWithFields($username, TableNode $table)
default:
$fieldValue = $user->getFieldValue($fieldName);
}
Assertion::assertEquals(
$expectedValue,
Assertion::eq(
$fieldValue,
$expectedValue,
"Field '$fieldName' did not contain expected value '$expectedValue'."
);
}
Expand Down
Loading