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
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"guzzlehttp/psr7": "^2.7",
"liuggio/fastest": "^1.11",
"php-http/client-common": "^2.1",
"phpunit/phpunit": "^8.5 || ^9.0 || ^10.0",
"symfony/config": "^7.3",
"symfony/console": "^7.3",
"symfony/dependency-injection": "^7.3",
Expand All @@ -36,7 +35,8 @@
"psy/psysh": "^0.12.4",
"oleg-andreyev/mink-phpwebdriver": "<1.3.3",
"oleg-andreyev/mink-phpwebdriver-extension": "^1.0",
"symfony/form": "^7.3"
"symfony/form": "^7.3",
"webmozart/assert": "^2.3"
},
"require-dev": {
"ibexa/code-style": "~2.3.0",
Expand All @@ -46,7 +46,8 @@
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpstan/phpstan-symfony": "^2.0",
"symfony/phpunit-bridge": "^7.3"
"symfony/phpunit-bridge": "^7.3",
"phpunit/phpunit": "^12.5"
},
"autoload": {
"psr-4": {
Expand Down
18 changes: 0 additions & 18 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -576,12 +576,6 @@ parameters:
count: 1
path: src/lib/API/ContentData/FieldTypeData/SelectionDataProvider.php

-
message: '#^Parameter \#1 \$min \(1\) of function random_int expects lower number than parameter \#2 \$max \(int\<0, max\>\)\.$#'
identifier: argument.type
count: 1
path: src/lib/API/ContentData/FieldTypeData/SelectionDataProvider.php

-
message: '#^Parameter \#1 \$selection of class Ibexa\\Core\\FieldType\\Selection\\Value constructor expects array\<int\>, list\<string\> given\.$#'
identifier: argument.type
Expand Down Expand Up @@ -1086,12 +1080,6 @@ parameters:
count: 1
path: src/lib/API/Facade/SearchFacade.php

-
message: '#^Parameter \#1 \$min \(0\) of function random_int expects lower number than parameter \#2 \$max \(int\<\-1, max\>\)\.$#'
identifier: argument.type
count: 1
path: src/lib/API/Facade/SearchFacade.php

-
message: '#^Possibly invalid array key type array\<int, int\>\|int\.$#'
identifier: offsetAccess.invalidOffset
Expand Down Expand Up @@ -2946,12 +2934,6 @@ parameters:
count: 1
path: tests/lib/Browser/Element/Criterion/ChildElementTextCriterionTest.php

-
message: '#^Call to an undefined method PHPUnit\\Framework\\MockObject\\Builder\\InvocationStubber\:\:with\(\)\.$#'
identifier: method.notFound
count: 1
path: tests/lib/Browser/Element/Criterion/ElementAttributeCriterionTest.php

-
message: '#^Method Ibexa\\Tests\\Behat\\Browser\\Element\\Criterion\\ElementAttributeCriterionTest\:\:createElementWithAttribute\(\) has parameter \$attribute with no type specified\.$#'
identifier: missingType.parameter
Expand Down
10 changes: 9 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
bootstrap="vendor/autoload.php"
colors="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.5/phpunit.xsd"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
>
<coverage/>
<testsuites>
<testsuite name="Ibexa\Bundle\Behat">
Expand Down
8 changes: 4 additions & 4 deletions src/lib/API/Facade/ContentFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Ibexa\Contracts\Core\Repository\Values\Content\Content;
use Ibexa\Contracts\Core\Repository\Values\Content\Location;
use Ibexa\Contracts\Core\Repository\Values\Content\URLAlias;
use PHPUnit\Framework\Assert;
use Webmozart\Assert\Assert;

class ContentFacade
{
Expand Down Expand Up @@ -63,7 +63,7 @@ public function createContentDraft(
$contentItemData = null
): Content {
$parentUrlAlias = $this->urlAliasService->lookup($parentUrl);
Assert::assertEquals(URLAlias::LOCATION, $parentUrlAlias->type);
Assert::eq($parentUrlAlias->type, URLAlias::LOCATION);

$parentLocationId = $parentUrlAlias->destination;
$locationCreateStruct = $this->locationService->newLocationCreateStruct((int) $parentLocationId);
Expand Down Expand Up @@ -111,7 +111,7 @@ public function createDraftForExistingContent(
$contentItemData
): Content {
$urlAlias = $this->urlAliasService->lookup($locationURL);
Assert::assertEquals(URLAlias::LOCATION, $urlAlias->type);
Assert::eq($urlAlias->type, URLAlias::LOCATION);

$location = $this->locationService->loadLocation((int) $urlAlias->destination);
$contentDraft = $this->contentService->createContentDraft($location->getContentInfo());
Expand All @@ -132,7 +132,7 @@ public function getContentByLocationURL($locationURL): Content
public function getLocationByLocationURL($locationURL): Location
{
$urlAlias = $this->urlAliasService->lookup($locationURL);
Assert::assertEquals(URLAlias::LOCATION, $urlAlias->type);
Assert::eq($urlAlias->type, URLAlias::LOCATION);

return $this->repository->sudo(function () use ($urlAlias) {
return $this->locationService->loadLocation((int) $urlAlias->destination);
Expand Down
4 changes: 2 additions & 2 deletions src/lib/API/Facade/SearchFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LogicalNot;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Subtree;
use Ibexa\Contracts\Core\Repository\Values\Content\URLAlias;
use PHPUnit\Framework\Assert;
use Webmozart\Assert\Assert;

class SearchFacade
{
Expand Down Expand Up @@ -54,7 +54,7 @@ public function __construct(
public function getRandomChildFromPath(string $path): string
{
$urlAlias = $this->urlAliasService->lookup($path);
Assert::assertEquals(URLAlias::LOCATION, $urlAlias->type);
Assert::eq($urlAlias->type, URLAlias::LOCATION);

$location = $this->locationService->loadLocation((int) $urlAlias->destination);

Expand Down
4 changes: 2 additions & 2 deletions src/lib/API/Facade/TrashFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Ibexa\Contracts\Core\Repository\TrashService;
use Ibexa\Contracts\Core\Repository\URLAliasService;
use Ibexa\Contracts\Core\Repository\Values\Content\URLAlias;
use PHPUnit\Framework\Assert;
use Webmozart\Assert\Assert;

class TrashFacade
{
Expand All @@ -38,7 +38,7 @@ public function __construct(
public function trash(string $locationURL)
{
$urlAlias = $this->urlAliasService->lookup($locationURL);
Assert::assertEquals(URLAlias::LOCATION, $urlAlias->type);
Assert::eq($urlAlias->type, URLAlias::LOCATION);

$location = $this->locationService->loadLocation((int) $urlAlias->destination);

Expand Down
12 changes: 6 additions & 6 deletions src/lib/Browser/Assert/CollectionAssert.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Ibexa\Behat\Browser\Element\ElementCollectionInterface;
use Ibexa\Behat\Browser\Element\Mapper\ElementTextMapper;
use Ibexa\Behat\Browser\Locator\LocatorInterface;
use PHPUnit\Framework\Assert;
use Webmozart\Assert\Assert;

class CollectionAssert implements CollectionAssertInterface
{
Expand All @@ -35,7 +35,7 @@ public function __construct(

public function isEmpty(): ElementCollectionInterface
{
Assert::assertTrue(
Assert::true(
$this->elementCollection->empty(),
sprintf(
"Failed asserting that Collection created with %s locator '%s': '%s' is empty",
Expand All @@ -53,7 +53,7 @@ public function hasElements(): ElementCollectionInterface
$elements = $this->elementCollection->toArray();
$this->elementCollection->setElements($elements);

Assert::assertNotEmpty(
Assert::notEmpty(
$elements,
sprintf(
"Failed asserting that Collection created with %s locator '%s': '%s' is not empty",
Expand All @@ -71,9 +71,9 @@ public function countEquals(int $expectedCount): ElementCollectionInterface
$elements = $this->elementCollection->toArray();
$this->elementCollection->setElements($elements);

Assert::assertCount(
$expectedCount,
Assert::count(
$elements,
$expectedCount,
sprintf(
"Failed asserting that Collection created with %s locator '%s': '%s' has %d elements. Found %s instead.",
$this->locator->getType(),
Expand All @@ -95,7 +95,7 @@ public function containsElementsWithText(array $expectedElementTexts): ElementCo
$elementTexts = $this->elementCollection->mapBy(new ElementTextMapper());

foreach ($expectedElementTexts as $expectedElementText) {
Assert::assertContains(
Assert::inArray(
$expectedElementText,
$elementTexts,
sprintf(
Expand Down
10 changes: 5 additions & 5 deletions src/lib/Browser/Assert/Debug/Interactive/CollectionAssert.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Ibexa\Behat\Browser\Assert\CollectionAssertInterface;
use Ibexa\Behat\Browser\Element\ElementCollectionInterface;
use Ibexa\Behat\Core\Debug\InteractiveDebuggerTrait;
use PHPUnit\Framework\ExpectationFailedException;
use Webmozart\Assert\InvalidArgumentException;

class CollectionAssert implements CollectionAssertInterface
{
Expand All @@ -29,7 +29,7 @@ public function isEmpty(): ElementCollectionInterface
{
try {
return $this->baseCollectionAssert->isEmpty();
} catch (ExpectationFailedException $exception) {
} catch (InvalidArgumentException $exception) {
return $this->startInteractiveSessionOnException($exception, true);
}
}
Expand All @@ -38,7 +38,7 @@ public function hasElements(): ElementCollectionInterface
{
try {
return $this->baseCollectionAssert->hasElements();
} catch (ExpectationFailedException $exception) {
} catch (InvalidArgumentException $exception) {
return $this->startInteractiveSessionOnException($exception, true);
}
}
Expand All @@ -47,7 +47,7 @@ public function countEquals(int $expectedCount): ElementCollectionInterface
{
try {
return $this->baseCollectionAssert->countEquals($expectedCount);
} catch (ExpectationFailedException $exception) {
} catch (InvalidArgumentException $exception) {
return $this->startInteractiveSessionOnException($exception, true);
}
}
Expand All @@ -56,7 +56,7 @@ public function containsElementsWithText(array $expectedElementTexts): ElementCo
{
try {
return $this->baseCollectionAssert->containsElementsWithText($expectedElementTexts);
} catch (ExpectationFailedException $exception) {
} catch (InvalidArgumentException $exception) {
return $this->startInteractiveSessionOnException($exception, true);
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/lib/Browser/Assert/Debug/Interactive/ElementAssert.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Ibexa\Behat\Browser\Assert\ElementAssertInterface;
use Ibexa\Behat\Browser\Element\ElementInterface;
use Ibexa\Behat\Core\Debug\InteractiveDebuggerTrait;
use PHPUnit\Framework\ExpectationFailedException;
use Webmozart\Assert\InvalidArgumentException;

class ElementAssert implements ElementAssertInterface
{
Expand All @@ -29,7 +29,7 @@ public function textEquals(string $expectedText): ElementInterface
{
try {
return $this->baseElementAssert->textEquals($expectedText);
} catch (ExpectationFailedException $exception) {
} catch (InvalidArgumentException $exception) {
return $this->startInteractiveSessionOnException($exception, true);
}
}
Expand All @@ -38,7 +38,7 @@ public function textContains(string $expectedTextFragment): ElementInterface
{
try {
return $this->baseElementAssert->textContains($expectedTextFragment);
} catch (ExpectationFailedException $exception) {
} catch (InvalidArgumentException $exception) {
return $this->startInteractiveSessionOnException($exception, true);
}
}
Expand All @@ -47,7 +47,7 @@ public function isVisible(): ElementInterface
{
try {
return $this->baseElementAssert->isVisible();
} catch (ExpectationFailedException $exception) {
} catch (InvalidArgumentException $exception) {
return $this->startInteractiveSessionOnException($exception, true);
}
}
Expand All @@ -56,7 +56,7 @@ public function hasClass(string $expectedClass): ElementInterface
{
try {
return $this->baseElementAssert->hasClass($expectedClass);
} catch (ExpectationFailedException $exception) {
} catch (InvalidArgumentException $exception) {
return $this->startInteractiveSessionOnException($exception, true);
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/lib/Browser/Assert/ElementAssert.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use Ibexa\Behat\Browser\Element\ElementInterface;
use Ibexa\Behat\Browser\Locator\LocatorInterface;
use PHPUnit\Framework\Assert;
use Webmozart\Assert\Assert;

class ElementAssert implements ElementAssertInterface
{
Expand All @@ -36,9 +36,9 @@ public function textEquals(string $expectedText): ElementInterface
{
$actualText = $this->element->getText();

Assert::assertEquals(
$expectedText,
Assert::eq(
$actualText,
$expectedText,
sprintf(
"Failed asserting that expected string '%s' is equal to actual '%s' for %s locator '%s': '%s'",
$expectedText,
Expand All @@ -56,9 +56,9 @@ public function textContains(string $expectedTextFragment): ElementInterface
{
$actualText = $this->element->getText();

Assert::assertStringContainsString(
$expectedTextFragment,
Assert::contains(
$actualText,
$expectedTextFragment,
sprintf(
"Failed asserting that expected text '%s' is found in actual text '%s' for %s locator '%s': '%s'",
$expectedTextFragment,
Expand All @@ -74,7 +74,7 @@ public function textContains(string $expectedTextFragment): ElementInterface

public function isVisible(): ElementInterface
{
Assert::assertTrue(
Assert::true(
$this->element->isVisible(),
sprintf(
"Failed asserting that %s locator '%s': '%s' is visible",
Expand All @@ -91,7 +91,7 @@ public function hasClass(string $expectedClass): ElementInterface
{
$actualClass = $this->element->getAttribute('class');

Assert::assertTrue(
Assert::true(
$this->element->hasClass($expectedClass),
sprintf(
"Failed asserting that element with %s locator '%s': '%s' has '%s' class, instead class is '%s'",
Expand Down
6 changes: 3 additions & 3 deletions src/lib/Browser/Context/BrowserContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Behat\MinkExtension\Context\RawMinkContext;
use DMore\ChromeDriver\ChromeDriver;
use Ibexa\Behat\Core\Behat\ArgumentParser;
use PHPUnit\Framework\Assert;
use Webmozart\Assert\Assert;

class BrowserContext extends RawMinkContext
{
Expand Down Expand Up @@ -44,7 +44,7 @@ public function responseHeadersContain(TableNode $expectedHeadersData): void
$responseHeaders = $this->getSession()->getDriver()->getResponseHeaders();

foreach ($expectedHeadersData->getHash() as $row) {
Assert::assertEquals($row['Value'], $this->getHeaderValue($responseHeaders, $row['Header']));
Assert::eq($this->getHeaderValue($responseHeaders, $row['Header']), $row['Value']);
}
}

Expand All @@ -58,7 +58,7 @@ public function responseHeadersMatchPattern(TableNode $expectedHeadersData): voi
foreach ($expectedHeadersData->getHash() as $row) {
$expectedValuePattern = $row['Pattern'];
$actualValue = $this->getHeaderValue($responseHeaders, $row['Header']);
Assert::assertEquals(1, preg_match($expectedValuePattern, $actualValue));
Assert::eq(preg_match($expectedValuePattern, $actualValue), 1);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
use Ibexa\Behat\Browser\Element\Mapper\MapperInterface;
use Ibexa\Behat\Browser\Exception\ElementNotFoundException;
use Ibexa\Behat\Core\Debug\InteractiveDebuggerTrait;
use PHPUnit\Framework\ExpectationFailedException;
use Traversable;
use Webmozart\Assert\InvalidArgumentException;

class ElementCollection implements ElementCollectionInterface
{
Expand Down Expand Up @@ -95,7 +95,7 @@ public function single(): ElementInterface
{
try {
return $this->baseElementCollection->single();
} catch (ExpectationFailedException $exception) {
} catch (InvalidArgumentException $exception) {
return $this->startInteractiveSessionOnException($exception, true);
}
}
Expand Down
Loading
Loading