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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
composer.lock
.php_cs.cache
.php-cs-fixer.cache
.phpunit.cache/
.phpunit.result.cache
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
"ibexa/code-style": "~2.0.0",
"ibexa/doctrine-schema": "~6.0.x-dev",
"ibexa/rector": "~6.0.x-dev",
"matthiasnoback/symfony-dependency-injection-test": "^5.0",
"matthiasnoback/symfony-dependency-injection-test": "^6.0",
"phpspec/phpspec": "^7.1 || ^8.0",
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpstan/phpstan-symfony": "^2.0",
"phpunit/phpunit": "^9.6",
"phpunit/phpunit": "^11.5",
"symfony/phpunit-bridge": "^7.4"
},
"autoload": {
Expand Down
27 changes: 11 additions & 16 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
<phpunit
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="bootstrap.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
colors="true"
>
<?xml version="1.0"?>
<phpunit backupGlobals="false" bootstrap="bootstrap.php" colors="true" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<php>
<ini name="error_reporting" value="-1" />
<ini name="error_reporting" value="-1"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled=1"/>
</php>
<testsuites>
<testsuite name="default"><directory>tests</directory></testsuite>
</testsuites>
<listeners>
<listener class="\Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
</listeners>
<extensions>
<bootstrap class="Symfony\Bridge\PhpUnit\SymfonyExtension"/>
</extensions>
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Ibexa\Tests\Bundle\HttpCache\EventListener;

use Ibexa\HttpCache\EventListener\ConditionallyRemoveVaryHeaderListener;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand All @@ -27,7 +28,7 @@ protected function setUp(): void
/**
* @return iterable<array{varyHeaders: string[], expectedVaryHeaders: string[]}>
*/
public function onKernelResponseProvider(): iterable
public static function onKernelResponseProvider(): iterable
{
return [
[
Expand Down Expand Up @@ -70,19 +71,18 @@ public function onKernelResponseProvider(): iterable
}

/**
* @dataProvider onKernelResponseProvider
*
* @param string[] $varyHeaders
* @param string[] $expectedVaryHeaders
*/
#[DataProvider('onKernelResponseProvider')]
public function testOnKernelResponse(array $varyHeaders, array $expectedVaryHeaders): void
{
$request = new Request();
$request->attributes->set('_route', 'testroute1');

$response = new Response('test content', Response::HTTP_OK, ['vary' => $varyHeaders]);

$kernel = $this->createMock(HttpKernelInterface::class);
$kernel = $this->createStub(HttpKernelInterface::class);
$event = new ResponseEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST, $response);

$this->conditionallyRemoveVaryHeaderListener->onKernelResponse($event);
Expand Down
8 changes: 4 additions & 4 deletions tests/lib/ContextProvider/RoleIdentifyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected function setUp(): void
$this->repositoryMock = $this
->getMockBuilder(Repository::class)
->disableOriginalConstructor()
->setMethods(['getRoleService', 'getPermissionResolver'])
->onlyMethods(['getRoleService', 'getPermissionResolver'])
->getMock();

$this->roleServiceMock = $this->createMock(RoleService::class);
Expand All @@ -49,8 +49,8 @@ protected function setUp(): void

public function testSetIdentity(): void
{
$user = $this->createMock(APIUser::class);
$userReference = $this->createMock(UserReference::class);
$user = $this->createStub(APIUser::class);
$userReference = $this->createStub(UserReference::class);
$userContext = new UserContext();

$permissionResolver = $this->getPermissionResolverMock();
Expand Down Expand Up @@ -175,8 +175,8 @@ protected function getPermissionResolverMock(): PermissionResolver & MockObject
{
return $this
->getMockBuilder(PermissionResolver::class)
->setMethods(['getCurrentUserReference'])
->disableOriginalConstructor()
->onlyMethods(['getCurrentUserReference'])
->getMock();
}

Expand Down
11 changes: 5 additions & 6 deletions tests/lib/PurgeClient/VarnishPurgeClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use FOS\HttpCache\ProxyClient\ProxyClient;
use FOS\HttpCacheBundle\CacheManager;
use Ibexa\HttpCache\PurgeClient\VarnishPurgeClient;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
Expand All @@ -26,8 +27,8 @@ protected function setUp(): void
$this->cacheManager = $this->getMockBuilder(CacheManager::class)
->setConstructorArgs(
[
$this->createMock(ProxyClient::class),
$this->createMock(
$this->createStub(ProxyClient::class),
$this->createStub(
UrlGeneratorInterface::class
),
]
Expand All @@ -48,9 +49,7 @@ public function testPurgeNoLocationIds(): void
$this->purgeClient->purge([]);
}

/**
* @dataProvider purgeTestProvider
*/
#[DataProvider('purgeTestProvider')]
public function testPurge(array $locationIds): void
{
$keys = array_map(
Expand All @@ -68,7 +67,7 @@ static function ($id): string {
$this->purgeClient->purge($keys);
}

public function purgeTestProvider(): array
public static function purgeTestProvider(): array
{
return [
[[123]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public function testToStringWithNoTaggers(): void

public function testToStringListsRegisteredTaggerTypes(): void
{
$fosResponseTagger = $this->createMock(FosResponseTagger::class);
$fosResponseTagger = $this->createStub(FosResponseTagger::class);

$dispatcher = new DispatcherTagger([
new ContentInfoTagger($fosResponseTagger),
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/ResponseTagger/Value/ContentInfoTaggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function testTagsWithLocationIdWhenMainLocationIsSet(): void
->expects($matcher)
->method('addTags')
->willReturnCallback(function (array $tags) use ($matcher): ResponseTagger {
if ($matcher->getInvocationCount() === 1) {
if ($matcher->numberOfInvocations() === 1) {
self::assertSame(
[
ContentTagInterface::CONTENT_PREFIX . '1',
Expand All @@ -71,7 +71,7 @@ public function testTagsWithLocationIdWhenMainLocationIsSet(): void
);
}

if ($matcher->getInvocationCount() === 2) {
if ($matcher->numberOfInvocations() === 2) {
self::assertSame(
[
ContentTagInterface::LOCATION_PREFIX . '456',
Expand Down
14 changes: 7 additions & 7 deletions tests/lib/ResponseTagger/Value/LocationTaggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ public function testTagsWithLocationIdWhenNotMainLocation(): void
->expects($matcher)
->method('addTags')
->willReturnCallback(function (array $tags) use ($matcher): ResponseTagger {
if ($matcher->getInvocationCount() === 1) {
if ($matcher->numberOfInvocations() === 1) {
self::assertSame([ContentTagInterface::LOCATION_PREFIX . '123'], $tags);
}

if ($matcher->getInvocationCount() === 2) {
if ($matcher->numberOfInvocations() === 2) {
self::assertSame([ContentTagInterface::PARENT_LOCATION_PREFIX . '2'], $tags);
}

if ($matcher->getInvocationCount() === 3) {
if ($matcher->numberOfInvocations() === 3) {
self::assertSame([
ContentTagInterface::PATH_PREFIX . '1',
ContentTagInterface::PATH_PREFIX . '2',
Expand Down Expand Up @@ -88,11 +88,11 @@ public function testDoesNotTagLocationIdWhenItIsMainLocation(): void
->expects($matcher)
->method('addTags')
->willReturnCallback(function (array $tags) use ($matcher): ResponseTagger {
if ($matcher->getInvocationCount() === 1) {
if ($matcher->numberOfInvocations() === 1) {
self::assertSame([ContentTagInterface::PARENT_LOCATION_PREFIX . '2'], $tags);
}

if ($matcher->getInvocationCount() === 2) {
if ($matcher->numberOfInvocations() === 2) {
self::assertSame([
ContentTagInterface::PATH_PREFIX . '1',
ContentTagInterface::PATH_PREFIX . '2',
Expand Down Expand Up @@ -121,7 +121,7 @@ public function testTagsWithParentLocationId(): void
->expects($matcher)
->method('addTags')
->willReturnCallback(function (array $tags) use ($matcher): ResponseTagger {
if ($matcher->getInvocationCount() === 0) {
if ($matcher->numberOfInvocations() === 0) {
self::assertSame([ContentTagInterface::PARENT_LOCATION_PREFIX . '123'], $tags);
}

Expand All @@ -145,7 +145,7 @@ public function testTagsWithPathItems(): void
->expects($matcher)
->method('addTags')
->willReturnCallback(function (array $tags) use ($matcher): ResponseTagger {
if ($matcher->getInvocationCount() === 0) {
if ($matcher->numberOfInvocations() === 0) {
self::assertSame([
ContentTagInterface::PATH_PREFIX . '1',
ContentTagInterface::PATH_PREFIX . '2',
Expand Down