Skip to content

Commit e39f896

Browse files
committed
Merged branch '5.0' into 6.0
2 parents 6b8ae8b + a1b3089 commit e39f896

8 files changed

Lines changed: 39 additions & 44 deletions

File tree

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@
7373
"phpstan/phpstan-symfony": "^2.0",
7474
"phpunit/phpunit": "^9.6",
7575
"symfony/phpunit-bridge": "^7.4",
76-
"symfony/runtime": "^7.4"
76+
"symfony/runtime": "^7.4",
77+
"webmozart/assert": "^2.3"
7778
},
7879
"conflict": {
7980
"doctrine/dbal": "2.7.0",

phpstan-baseline.neon

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2196,12 +2196,6 @@ parameters:
21962196
count: 1
21972197
path: src/bundle/Core/Features/Context/ContentPreviewContext.php
21982198

2199-
-
2200-
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertTrue\(\) with false and non\-falsy\-string will always evaluate to false\.$#'
2201-
identifier: staticMethod.impossibleType
2202-
count: 1
2203-
path: src/bundle/Core/Features/Context/ContentPreviewContext.php
2204-
22052199
-
22062200
message: '#^Method Ibexa\\Bundle\\Core\\Features\\Context\\ContentPreviewContext\:\:checkForExceptions\(\) has no return type specified\.$#'
22072201
identifier: missingType.return

src/bundle/Core/Features/Context/ConsoleContext.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
use Behat\Behat\Context\Context;
1111
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
12-
use PHPUnit\Framework\Assert as Assertion;
1312
use Symfony\Component\Process\PhpExecutableFinder;
1413
use Symfony\Component\Process\Process;
14+
use Webmozart\Assert\Assert as Assertion;
1515

1616
class ConsoleContext implements Context
1717
{
@@ -70,9 +70,9 @@ public function iRunAConsoleScriptWithSiteaccess($siteaccessOption)
7070
public function iExpectItToBeExecutedWithTheSiteaccess($siteaccess)
7171
{
7272
$actualSiteaccess = trim($this->scriptOutput);
73-
Assertion::assertEquals(
74-
$siteaccess,
73+
Assertion::eq(
7574
$actualSiteaccess,
75+
$siteaccess,
7676
"The command was expected to be executed with the siteaccess \"$siteaccess\", but was executed with \"$actualSiteaccess\""
7777
);
7878
}
@@ -101,7 +101,7 @@ public function thereIsASiteaccess($expectedSiteaccessName, $default = false)
101101
}
102102
}
103103

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

@@ -111,9 +111,9 @@ public function thereIsASiteaccess($expectedSiteaccessName, $default = false)
111111
public function thereIsADefaultSiteaccess($expectedSiteaccessName)
112112
{
113113
$this->thereIsASiteaccess($expectedSiteaccessName, true);
114-
Assertion::assertEquals(
115-
$expectedSiteaccessName,
116-
$siteaccessList = $this->getConfigResolver()->getParameter('siteaccess.default_siteaccess')
114+
Assertion::eq(
115+
$this->getConfigResolver()->getParameter('siteaccess.default_siteaccess'),
116+
$expectedSiteaccessName
117117
);
118118
}
119119

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

@@ -176,7 +176,7 @@ public function thereIsASiteaccessThatIsNotTheDefaultOne()
176176
*/
177177
public function iExpectItToBeExecutedWithIt()
178178
{
179-
Assertion::assertEquals($this->it['siteaccess'], $this->scriptOutput);
179+
Assertion::eq($this->scriptOutput, $this->it['siteaccess']);
180180
}
181181

182182
/**

src/bundle/Core/Features/Context/ContentPreviewContext.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
1111
use Behat\MinkExtension\Context\RawMinkContext;
1212
use Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo;
13-
use PHPUnit\Framework\Assert as Assertion;
13+
use Webmozart\Assert\Assert as Assertion;
1414

1515
class ContentPreviewContext extends RawMinkContext
1616
{
@@ -86,7 +86,7 @@ protected function checkForExceptions()
8686
$exceptionLines[] = trim($html);
8787
}
8888
$message = 'An exception occured during rendering:' . implode("\n", $exceptionLines);
89-
Assertion::assertTrue(false, $message);
89+
Assertion::true(false, $message);
9090
}
9191
}
9292

src/bundle/Core/Features/Context/ContentTypeContext.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Behat\Gherkin\Node\TableNode;
1212
use Ibexa\Contracts\Core\Repository\ContentTypeService;
1313
use Ibexa\Contracts\Core\Repository\Exceptions as ApiExceptions;
14-
use PHPUnit\Framework\Assert as Assertion;
14+
use Webmozart\Assert\Assert as Assertion;
1515

1616
/**
1717
* Sentences for content types.
@@ -81,7 +81,7 @@ public function ensureContentTypeDoesntExist($identifier)
8181
*/
8282
public function assertContentTypeExistsByIdentifier($identifier)
8383
{
84-
Assertion::assertTrue(
84+
Assertion::true(
8585
$this->checkContentTypeExistenceByIdentifier($identifier),
8686
"Couldn't find a content type with identifier '$identifier'."
8787
);
@@ -94,7 +94,7 @@ public function assertContentTypeExistsByIdentifier($identifier)
9494
*/
9595
public function assertContentTypeDoesntExistsByIdentifier($identifier)
9696
{
97-
Assertion::assertFalse(
97+
Assertion::false(
9898
$this->checkContentTypeExistenceByIdentifier($identifier),
9999
"Found a content type with identifier '$identifier'."
100100
);
@@ -107,7 +107,7 @@ public function assertContentTypeDoesntExistsByIdentifier($identifier)
107107
*/
108108
public function assertContentTypeExistsByIdentifierOnGroup($identifier, $groupIdentifier)
109109
{
110-
Assertion::assertTrue(
110+
Assertion::true(
111111
$this->checkContentTypeExistenceByIdentifier($identifier, $groupIdentifier),
112112
"Couldn't find content type with identifier '$identifier' on '$groupIdentifier."
113113
);

src/bundle/Core/Features/Context/QueryControllerContext.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace Ibexa\Bundle\Core\Features\Context;
99

1010
use Behat\MinkExtension\Context\RawMinkContext;
11-
use PHPUnit\Framework\Assert;
11+
use Webmozart\Assert\Assert;
1212

1313
class QueryControllerContext extends RawMinkContext
1414
{
@@ -19,7 +19,7 @@ public function theQueryResultsAreAssignedToTheTwigVariable($twigVariableName)
1919
{
2020
$variableTypes = $this->getVariableTypesFromTemplate();
2121

22-
Assert::assertArrayHasKey($twigVariableName, $variableTypes, "The $twigVariableName twig variable was not set");
22+
Assert::keyExists($variableTypes, $twigVariableName, "The $twigVariableName twig variable was not set");
2323
}
2424

2525
/**
@@ -29,8 +29,8 @@ public function theQueryResultsAssignedToTheTwigVariableIsAObject($twigVariableN
2929
{
3030
$variableTypes = $this->getVariableTypesFromTemplate();
3131

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

3636
/**
@@ -59,12 +59,12 @@ public function theQueryResultsAssignedToTheTwigVariableIsAObjectAndHasLimitAndC
5959
}
6060
}
6161

62-
Assert::assertTrue(
62+
Assert::true(
6363
$pageLimitFound,
6464
"The maxPerPage $pageLimit twig variable was not set"
6565
);
6666

67-
Assert::assertTrue(
67+
Assert::true(
6868
$currentPageFound,
6969
"The currentPage $pageValue twig variable was not set"
7070
);

src/bundle/Core/Features/Context/RoleContext.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Behat\Behat\Context\Context;
1111
use Ibexa\Contracts\Core\Repository\Exceptions as ApiExceptions;
1212
use Ibexa\Contracts\Core\Repository\RoleService;
13-
use PHPUnit\Framework\Assert as Assertion;
13+
use Webmozart\Assert\Assert as Assertion;
1414

1515
/**
1616
* Sentences for Roles.
@@ -85,7 +85,7 @@ public function iHaveRole($name)
8585
public function iSeeRole($name)
8686
{
8787
$role = $this->getRole($name);
88-
Assertion::assertNotNull(
88+
Assertion::notNull(
8989
$role,
9090
"Couldn't find Role with name $name"
9191
);
@@ -97,12 +97,12 @@ public function iSeeRole($name)
9797
public function noAssginedPolicies($name)
9898
{
9999
$role = $this->getRole($name);
100-
Assertion::assertNotNull(
100+
Assertion::notNull(
101101
$role,
102102
"Couldn't find Role with name $name"
103103
);
104104
$policies = $role->getPolicies();
105-
Assertion::assertEmpty($policies, "Role $name has policies associated");
105+
Assertion::isEmpty($policies, "Role $name has policies associated");
106106
}
107107

108108
/**
@@ -111,12 +111,12 @@ public function noAssginedPolicies($name)
111111
public function noAssigneGroups($name)
112112
{
113113
$role = $this->getRole($name);
114-
Assertion::assertNotNull(
114+
Assertion::notNull(
115115
$role,
116116
"Couldn't find Role with name $name"
117117
);
118118
$roleAssigments = $this->roleService->getRoleAssignments($role);
119-
Assertion::assertEmpty($roleAssigments, "Role $name has Users or groups associated");
119+
Assertion::isEmpty($roleAssigments, "Role $name has Users or groups associated");
120120
}
121121

122122
/**
@@ -127,7 +127,7 @@ public function noAssigneGroups($name)
127127
public function iDontSeeRole($name)
128128
{
129129
$role = $this->getRole($name);
130-
Assertion::assertNull(
130+
Assertion::null(
131131
$role,
132132
"Found Role with name $name"
133133
);

src/bundle/Core/Features/Context/UserContext.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Ibexa\Contracts\Core\Repository\UserService;
1616
use Ibexa\Contracts\Core\Repository\Values\Content\Query;
1717
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion;
18-
use PHPUnit\Framework\Assert as Assertion;
18+
use Webmozart\Assert\Assert as Assertion;
1919

2020
/**
2121
* Sentences for Users.
@@ -427,7 +427,7 @@ public function iHaveTheFollowingUsers(TableNode $table)
427427
*/
428428
public function assertUserWithNameExists($username)
429429
{
430-
Assertion::assertTrue(
430+
Assertion::true(
431431
$this->checkUserExistenceByUsername($username),
432432
"Couldn't find User with name '$username'."
433433
);
@@ -440,7 +440,7 @@ public function assertUserWithNameExists($username)
440440
*/
441441
public function assertUserWithNameDoesntExist($username)
442442
{
443-
Assertion::assertFalse(
443+
Assertion::false(
444444
$this->checkUserExistenceByUsername($username),
445445
"User with name '$username' was found."
446446
);
@@ -454,7 +454,7 @@ public function assertUserWithNameDoesntExist($username)
454454
*/
455455
public function assertUserWithNameExistsInGroup($username, $parentGroup)
456456
{
457-
Assertion::assertTrue(
457+
Assertion::true(
458458
$this->checkUserExistenceByUsername($username, $parentGroup),
459459
"Couldn't find User with name '$username' in parent group '$parentGroup'."
460460
);
@@ -468,7 +468,7 @@ public function assertUserWithNameExistsInGroup($username, $parentGroup)
468468
*/
469469
public function assertUserWithNameDoesntExistInGroup($username, $parentGroup)
470470
{
471-
Assertion::assertFalse(
471+
Assertion::false(
472472
$this->checkUserExistenceByUsername($username, $parentGroup),
473473
"User with name '$username' was found in parent group '$parentGroup'."
474474
);
@@ -490,7 +490,7 @@ public function assertUserWithNameDoesntExistInGroups($username, TableNode $tabl
490490
array_shift($groups);
491491
foreach ($groups as $group) {
492492
$parentGroupName = $group[0];
493-
Assertion::assertFalse(
493+
Assertion::false(
494494
$this->checkUserExistenceByUsername($username, $parentGroupName),
495495
"User with name '$username' was found in parent group '$parentGroupName'."
496496
);
@@ -510,7 +510,7 @@ public function assertUserWithNameDoesntExistInGroups($username, TableNode $tabl
510510
*/
511511
public function assertUserWithNameExistsWithFields($username, TableNode $table)
512512
{
513-
Assertion::assertTrue(
513+
Assertion::true(
514514
$this->checkUserExistenceByUsername($username),
515515
"Couldn't find User with name '$username'."
516516
);
@@ -532,9 +532,9 @@ public function assertUserWithNameExistsWithFields($username, TableNode $table)
532532
default:
533533
$fieldValue = $user->getFieldValue($fieldName);
534534
}
535-
Assertion::assertEquals(
536-
$expectedValue,
535+
Assertion::eq(
537536
$fieldValue,
537+
$expectedValue,
538538
"Field '$fieldName' did not contain expected value '$expectedValue'."
539539
);
540540
}

0 commit comments

Comments
 (0)