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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
/.php_cs.cache
composer.lock
.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 @@ -50,11 +50,11 @@
"ibexa/rector": "~6.0.x-dev",
"ibexa/rest": "~6.0.x-dev",
"ibexa/search": "~6.0.x-dev",
"matthiasnoback/symfony-dependency-injection-test": "^5.0",
"matthiasnoback/symfony-dependency-injection-test": "^6.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"
},
"scripts": {
Expand Down
61 changes: 29 additions & 32 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="tests/bootstrap.php"
colors="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory>src</directory>
</include>
<exclude>
<directory>tests/bundle/</directory>
<directory>tests/lib/</directory>
</exclude>
</coverage>
<testsuites>
<testsuite name="Ibexa\Bundle\User">
<directory>tests/bundle/</directory>
</testsuite>
<testsuite name="Ibexa\User">
<directory>tests/lib/</directory>
</testsuite>
<testsuite name="integration">
<directory>tests/integration</directory>
</testsuite>
</testsuites>
<php>
<env name="KERNEL_CLASS" value="Ibexa\Tests\Integration\User\IbexaTestKernel"/>
<env name="DATABASE_URL" value="sqlite://i@i/test.db"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/>
</php>
<listeners>
<listener class="\Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
</listeners>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/bootstrap.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd" cacheDirectory=".phpunit.cache">
<extensions>
<bootstrap class="Symfony\Bridge\PhpUnit\SymfonyExtension"/>
</extensions>
<testsuites>
<testsuite name="Ibexa\Bundle\User">
<directory>tests/bundle/</directory>
</testsuite>
<testsuite name="Ibexa\User">
<directory>tests/lib/</directory>
</testsuite>
<testsuite name="integration">
<directory>tests/integration</directory>
</testsuite>
</testsuites>
<php>
<env name="KERNEL_CLASS" value="Ibexa\Tests\Integration\User\IbexaTestKernel"/>
<env name="DATABASE_URL" value="sqlite://i@i/test.db"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/>
</php>
<source>
<include>
<directory>src</directory>
</include>
<exclude>
<directory>tests/bundle/</directory>
<directory>tests/lib/</directory>
</exclude>
</source>
</phpunit>
10 changes: 5 additions & 5 deletions tests/integration/SampleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

namespace Ibexa\Tests\Integration\User;

/**
* @group integration
*
* @coversNothing
*/
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\Attributes\Group;

#[Group('integration')]
#[CoversNothing]
final class SampleTest extends IbexaKernelTestCase
{
public function testCompilesSuccessfully(): void
Expand Down
6 changes: 3 additions & 3 deletions tests/lib/EventListener/PerformAccessCheckSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use Ibexa\Tests\User\Stub\RestrictedControllerStub;
use Ibexa\User\EventListener\PerformAccessCheckSubscriber;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\MockObject\Stub;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
Expand All @@ -20,13 +20,13 @@ final class PerformAccessCheckSubscriberTest extends TestCase
{
private PerformAccessCheckSubscriber $subscriber;

private HttpKernelInterface&MockObject $kernel;
private HttpKernelInterface&Stub $kernel;

private Request $request;

protected function setUp(): void
{
$this->kernel = $this->createMock(HttpKernelInterface::class);
$this->kernel = $this->createStub(HttpKernelInterface::class);
$this->request = new Request();
$this->subscriber = new PerformAccessCheckSubscriber([]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
use Ibexa\User\Form\ChoiceList\Loader\AvailableLocaleChoiceLoader;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\MockObject\Stub;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Validator\ConstraintViolationInterface;
use Symfony\Component\Validator\ConstraintViolationList;
Expand All @@ -20,7 +22,7 @@ class AvailableLocaleChoiceLoaderTest extends TestCase
{
private ValidatorInterface&MockObject $validator;

private ConstraintViolationInterface&MockObject $constraintViolation;
private ConstraintViolationInterface&Stub $constraintViolation;

private ConfigResolverInterface&MockObject $configResolver;

Expand All @@ -29,17 +31,16 @@ protected function setUp(): void
parent::setUp();

$this->validator = $this->createMock(ValidatorInterface::class);
$this->constraintViolation = $this->createMock(ConstraintViolationInterface::class);
$this->constraintViolation = $this->createStub(ConstraintViolationInterface::class);
$this->configResolver = $this->createMock(ConfigResolverInterface::class);
}

/**
* @param array<int, string> $availableTranslations
* @param array<int, string> $additionalTranslations
* @param array<string, string> $expectedLocales
*
* @dataProvider providerForGetChoiceList
*/
#[DataProvider('providerForGetChoiceList')]
public function testGetChoiceList(
array $availableTranslations,
array $additionalTranslations,
Expand Down Expand Up @@ -70,7 +71,7 @@ public function testGetChoiceList(
* 2: array<string, string>
* }>
*/
public function providerForGetChoiceList(): array
public static function providerForGetChoiceList(): array
{
return [
'available_translations' => [
Expand Down
19 changes: 9 additions & 10 deletions tests/lib/Invitation/InvitationServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Ibexa\Core\MVC\Symfony\SiteAccess\SiteAccessServiceInterface;
use Ibexa\User\Invitation\InvitationService;
use Ibexa\User\Invitation\Persistence\Handler;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

Expand All @@ -39,20 +40,18 @@ protected function setUp(): void
$this->configResolver = $this->createMock(ConfigResolverInterface::class);

$this->invitationService = new InvitationService(
$this->createMock(PermissionResolver::class),
$this->createMock(Handler::class),
$this->createMock(HashGenerator::class),
$this->createMock(UserService::class),
$this->createStub(PermissionResolver::class),
$this->createStub(Handler::class),
$this->createStub(HashGenerator::class),
$this->createStub(UserService::class),
$this->siteAccessService,
$this->createMock(TransactionHandler::class),
$this->createStub(TransactionHandler::class),
$this->configResolver,
$this->createMock(DomainMapper::class)
$this->createStub(DomainMapper::class)
);
}

/**
* @dataProvider invitationProvider
*/
#[DataProvider('invitationProvider')]
public function testIsValid(
InvitationContract $invitation,
string $usedInSiteAccessName,
Expand Down Expand Up @@ -83,7 +82,7 @@ public function testIsValid(
* 2: bool
* }>
*/
public function invitationProvider(): array
public static function invitationProvider(): array
{
return [
'valid' => [
Expand Down
12 changes: 6 additions & 6 deletions tests/lib/Password/PasswordRequirementsResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Ibexa\Core\Repository\User\PasswordValidatorInterface;
use Ibexa\User\Password\PasswordRequirement;
use Ibexa\User\Password\PasswordRequirementsResolver;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class PasswordRequirementsResolverTest extends TestCase
Expand All @@ -40,12 +41,11 @@ public function testContentTypeWithoutUserFieldDefinition(): void
}

/**
* @dataProvider dataProviderForGetRequirements
*
* @param array<string, mixed> $constraints
* @param array<string, mixed> $fieldSettings
* @param string[] $expectedIdentifiers
*/
#[DataProvider('dataProviderForGetRequirements')]
public function testGetRequirements(
array $constraints,
array $fieldSettings,
Expand All @@ -71,7 +71,7 @@ public function testGetRequirements(
* 2: string[],
* }>
*/
public function dataProviderForGetRequirements(): array
public static function dataProviderForGetRequirements(): array
{
return [
'all rules disabled' => [
Expand Down Expand Up @@ -133,9 +133,9 @@ public function dataProviderForGetRequirements(): array
public function testCoversEveryCoreValidatorSchemaRule(): void
{
$schema = (new UserType(
$this->createMock(UserHandler::class),
$this->createMock(PasswordHashService::class),
$this->createMock(PasswordValidatorInterface::class)
$this->createStub(UserHandler::class),
$this->createStub(PasswordHashService::class),
$this->createStub(PasswordValidatorInterface::class)
))->getValidatorConfigurationSchema()['PasswordValueValidator'];

$allRulesEnabled = array_map(
Expand Down
Loading
Loading