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
@@ -1,3 +1,5 @@
/composer.lock
/.php-cs-fixer.cache
/vendor/
/.phpunit.cache/
/.phpunit.result.cache
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"php": ">=8.3",
"doctrine/dbal": "^4.4",
"ibexa/jms-translation-bundle": "^2.6.1",
"phpunit/phpunit": "^11.5",
"symfony/framework-bundle": "^7.4",
"symfony/mime": "^7.4",
"symfony/options-resolver": "^7.4",
Expand All @@ -17,16 +18,15 @@
"symfony/yaml": "^7.4"
},
"require-dev": {
"phpunit/phpunit": "^9",
"ibexa/code-style": "~2.3.0",
"ibexa/code-style": "^2.0",
"ibexa/core": "~6.0.x-dev",
"ibexa/core-persistence": "~6.0.x-dev",
"ibexa/doctrine-schema": "~6.0.x-dev",
"ibexa/rector": "~6.0.x-dev",
"knplabs/knp-menu": "^3.3",
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"symfony/phpunit-bridge": "^5.4"
"symfony/phpunit-bridge": "^7.4"
},
"conflict": {
"phpstan/phpstan": "2.2.13"
Expand Down
6 changes: 0 additions & 6 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,3 @@ parameters:
identifier: function.alreadyNarrowedType
count: 1
path: src/contracts/IbexaTestCore.php

-
message: '#^Attribute class PHPUnit\\Framework\\Attributes\\DataProvider does not exist\.$#'
identifier: attribute.notFound
count: 1
path: src/contracts/Translation/AbstractTranslationCase.php
50 changes: 23 additions & 27 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
failOnWarning="true"
colors="true">
<php>
<env name="KERNEL_CLASS" value="Ibexa\Tests\Integration\Test\Core\TestKernel" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0"/>
</php>
<testsuites>
<testsuite name="bundle">
<directory>tests/bundle</directory>
</testsuite>
<testsuite name="contracts">
<directory>tests/contracts</directory>
</testsuite>
<testsuite name="integration">
<directory>tests/integration</directory>
</testsuite>
<testsuite name="lib">
<directory>tests/lib</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
</listeners>
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd" bootstrap="vendor/autoload.php" failOnWarning="true" colors="true" cacheDirectory=".phpunit.cache">
<php>
<env name="KERNEL_CLASS" value="Ibexa\Tests\Integration\Test\Core\TestKernel"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0"/>
</php>
<extensions>
<bootstrap class="Symfony\Bridge\PhpUnit\SymfonyExtension"/>
</extensions>
<testsuites>
<testsuite name="bundle">
<directory>tests/bundle</directory>
</testsuite>
<testsuite name="contracts">
<directory>tests/contracts</directory>
</testsuite>
<testsuite name="integration">
<directory>tests/integration</directory>
</testsuite>
<testsuite name="lib">
<directory>tests/lib</directory>
</testsuite>
</testsuites>
</phpunit>
2 changes: 1 addition & 1 deletion src/contracts/Menu/Constraint/ContainsPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct(array $path)
$this->path = $path;
}

protected function matches($other): bool
protected function matches(mixed $other): bool
{
assert($other instanceof ItemInterface);

Expand Down
3 changes: 0 additions & 3 deletions src/contracts/Translation/AbstractTranslationCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ abstract class AbstractTranslationCase extends IbexaKernelTestCase
*/
abstract public static function provideConfigNamesForTranslation(): iterable;

/**
* @dataProvider provideConfigNamesForTranslation
*/
#[DataProvider('provideConfigNamesForTranslation')]
final public function testTranslation(string $configName): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@

use Ibexa\Bundle\Test\Core\DependencyInjection\IbexaTestCoreExtension;
use Ibexa\Test\Core\Bootstrapper\HooksExecutor;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;

/**
* @covers \Ibexa\Bundle\Test\Core\DependencyInjection\IbexaTestCoreExtension
*/
#[CoversClass(IbexaTestCoreExtension::class)]
final class IbexaTestCoreExtensionTest extends TestCase
{
public function testRegistersNoServicesOutsideTheTestEnvironment(): void
Expand Down
11 changes: 5 additions & 6 deletions tests/contracts/Bootstrapper/BootstrapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
use Ibexa\Contracts\Test\Core\Bootstrapper\HooksExecutorInterface;
use Ibexa\Contracts\Test\Core\Bootstrapper\KernelProviderInterface;
use Ibexa\Contracts\Test\Core\IbexaTestKernel;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\TestWith;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
* @covers \Ibexa\Contracts\Test\Core\Bootstrapper\Bootstrapper
*/
#[CoversClass(Bootstrapper::class)]
final class BootstrapperTest extends TestCase
{
/**
Expand Down Expand Up @@ -180,11 +180,10 @@ public function testSkipsKernelShutdownWhenOptedOut(): void
}

/**
* @testWith [{"some.unknown.key": {}}]
* [{"Ibexa\\Contracts\\Test\\Core\\Bootstrapper\\Bootstrapper": {"some_unknown_option": true}}]
*
* @param array<string, mixed> $options
*/
#[TestWith([['some.unknown.key' => []]])]
#[TestWith([['Ibexa\Contracts\Test\Core\Bootstrapper\Bootstrapper' => ['some_unknown_option' => true]]])]
public function testRejectsAnUnrecognizedOptions(array $options): void
{
$this->expectException(UndefinedOptionsException::class);
Expand Down
5 changes: 2 additions & 3 deletions tests/contracts/Bootstrapper/ConsoleCommandRunnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
namespace Ibexa\Tests\Contracts\Test\Core\Bootstrapper;

use Ibexa\Contracts\Test\Core\Bootstrapper\ConsoleCommandRunner;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use RuntimeException;
use Symfony\Bundle\FrameworkBundle\Console\Application;

/**
* @covers \Ibexa\Contracts\Test\Core\Bootstrapper\ConsoleCommandRunner
*/
#[CoversClass(ConsoleCommandRunner::class)]
final class ConsoleCommandRunnerTest extends TestCase
{
public function testDoesNothingOnSuccess(): void
Expand Down
5 changes: 2 additions & 3 deletions tests/contracts/Bootstrapper/DefaultFixtureProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@

use Ibexa\Contracts\Core\Test\Persistence\Fixture\YamlFixture;
use Ibexa\Contracts\Test\Core\Bootstrapper\DefaultFixtureProvider;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

/**
* @covers \Ibexa\Contracts\Test\Core\Bootstrapper\DefaultFixtureProvider
*/
#[CoversClass(DefaultFixtureProvider::class)]
final class DefaultFixtureProviderTest extends TestCase
{
public function testYieldsTheBuiltInBaseFixture(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
namespace Ibexa\Tests\Contracts\Test\Core\Bootstrapper;

use Ibexa\Contracts\Test\Core\Bootstrapper\DefaultSchemaFilesProvider;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpKernel\KernelInterface;

/**
* @covers \Ibexa\Contracts\Test\Core\Bootstrapper\DefaultSchemaFilesProvider
*/
#[CoversClass(DefaultSchemaFilesProvider::class)]
final class DefaultSchemaFilesProviderTest extends TestCase
{
public function testYieldsSchemaFileResolvedThroughTheKernel(): void
Expand Down
9 changes: 4 additions & 5 deletions tests/contracts/Bootstrapper/FixtureHookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
use Ibexa\Contracts\Core\Test\Persistence\Fixture\FixtureImporter;
use Ibexa\Contracts\Test\Core\Bootstrapper\FixtureHook;
use Ibexa\Contracts\Test\Core\Bootstrapper\FixtureProviderInterface;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
* @covers \Ibexa\Contracts\Test\Core\Bootstrapper\FixtureHook
*/
#[CoversClass(FixtureHook::class)]
final class FixtureHookTest extends TestCase
{
public function testLoadFixturesOptionDefaultsToTrue(): void
Expand Down Expand Up @@ -53,7 +52,7 @@ public function testDoesNotAskProviderForFixturesWhenDisabled(): void
$provider = $this->createMock(FixtureProviderInterface::class);
$provider->expects(self::never())->method('getFixtures');

$hook = new FixtureHook($provider, new FixtureImporter($this->createMock(Connection::class)));
$hook = new FixtureHook($provider, new FixtureImporter($this->createStub(Connection::class)));
$hook($this->resolve($hook, [FixtureHook::OPTION_LOAD_FIXTURES => false]));
}

Expand All @@ -80,7 +79,7 @@ private function hookReturningFixtures(array $fixtures): FixtureHook
$provider = $this->createMock(FixtureProviderInterface::class);
$provider->method('getFixtures')->willReturn($fixtures);

$fixtureImporter = new FixtureImporter($this->createMock(Connection::class));
$fixtureImporter = new FixtureImporter($this->createStub(Connection::class));

return new FixtureHook($provider, $fixtureImporter);
}
Expand Down
12 changes: 5 additions & 7 deletions tests/contracts/Bootstrapper/KernelProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
use Ibexa\Contracts\Test\Core\Bootstrapper\KernelProvider;
use Ibexa\Contracts\Test\Core\IbexaTestKernel;
use LogicException;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\TestWith;
use PHPUnit\Framework\TestCase;
use stdClass;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\HttpKernel\Kernel;

/**
* @covers \Ibexa\Contracts\Test\Core\Bootstrapper\KernelProvider
*/
#[CoversClass(KernelProvider::class)]
final class KernelProviderTest extends TestCase
{
/**
Expand Down Expand Up @@ -53,10 +53,8 @@ protected function tearDown(): void
}
}

/**
* @testWith [null, "The kernel class \"null\" must implement \"Symfony\\Component\\HttpKernel\\KernelInterface\". Ensure that the KERNEL_CLASS environment variable is set to a valid test kernel class."]
* ["stdClass", "The kernel class \"stdClass\" must implement \"Symfony\\Component\\HttpKernel\\KernelInterface\". Ensure that the KERNEL_CLASS environment variable is set to a valid test kernel class."]
*/
#[TestWith([null, 'The kernel class "null" must implement "Symfony\Component\HttpKernel\KernelInterface". Ensure that the KERNEL_CLASS environment variable is set to a valid test kernel class.'])]
#[TestWith(['stdClass', 'The kernel class "stdClass" must implement "Symfony\Component\HttpKernel\KernelInterface". Ensure that the KERNEL_CLASS environment variable is set to a valid test kernel class.'])]
public function testThrowsWhenKernelClassIsInvalid(
?string $kernelClass,
string $exceptionMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@

use Ibexa\Contracts\Core\Search\VersatileHandler;
use Ibexa\Contracts\Test\Core\Bootstrapper\PurgeIndexAfterFixturesHook;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
* @covers \Ibexa\Contracts\Test\Core\Bootstrapper\PurgeIndexAfterFixturesHook
*/
#[CoversClass(PurgeIndexAfterFixturesHook::class)]
final class PurgeIndexAfterFixturesHookTest extends TestCase
{
public function testPurgeIndexOptionDefaultsToFalse(): void
Expand Down
5 changes: 2 additions & 3 deletions tests/contracts/Bootstrapper/PurgeSearchIndexHookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@

use Ibexa\Contracts\Core\Search\VersatileHandler;
use Ibexa\Contracts\Test\Core\Bootstrapper\PurgeSearchIndexHook;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
* @covers \Ibexa\Contracts\Test\Core\Bootstrapper\PurgeSearchIndexHook
*/
#[CoversClass(PurgeSearchIndexHook::class)]
final class PurgeSearchIndexHookTest extends TestCase
{
public function testPurgeIndexOptionDefaultsToFalse(): void
Expand Down
9 changes: 4 additions & 5 deletions tests/integration/SampleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
namespace Ibexa\Tests\Integration\Test\Core;

use Ibexa\Contracts\Test\Core\IbexaKernelTestCase;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\Attributes\Group;

/**
* @group integration
*
* @coversNothing
*/
#[Group('integration')]
#[CoversNothing]
final class SampleTest extends IbexaKernelTestCase
{
public function testCompilesSuccessfully(): void
Expand Down
5 changes: 2 additions & 3 deletions tests/lib/Bootstrapper/FixtureProviderChainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
use Ibexa\Contracts\Core\Test\Persistence\Fixture;
use Ibexa\Contracts\Test\Core\Bootstrapper\FixtureProviderInterface;
use Ibexa\Test\Core\Bootstrapper\FixtureProviderChain;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

/**
* @covers \Ibexa\Test\Core\Bootstrapper\FixtureProviderChain
*/
#[CoversClass(FixtureProviderChain::class)]
final class FixtureProviderChainTest extends TestCase
{
public function testSkipsProvidersReturningNull(): void
Expand Down
5 changes: 2 additions & 3 deletions tests/lib/Bootstrapper/HooksExecutorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@

use Ibexa\Contracts\Test\Core\Bootstrapper\HookInterface;
use Ibexa\Test\Core\Bootstrapper\HooksExecutor;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
* @covers \Ibexa\Test\Core\Bootstrapper\HooksExecutor
*/
#[CoversClass(HooksExecutor::class)]
final class HooksExecutorTest extends TestCase
{
public function testConfigureOptionsRejectsUnrecognizedTopLevelKey(): void
Expand Down
5 changes: 2 additions & 3 deletions tests/lib/TestDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@

namespace Ibexa\Tests\Test\Core;

use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\TestCase;
use SimpleXMLElement;
use Symfony\Component\Yaml\Yaml;

/**
* @coversNothing
*/
#[CoversNothing]
final class TestDataTest extends TestCase
{
private const string TEST_DATA_FILE = __DIR__ . '/../../src/contracts/Resources/test_data.yaml';
Expand Down
5 changes: 2 additions & 3 deletions tests/lib/Translation/AbstractTranslationCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use JMS\TranslationBundle\Model\Message;
use JMS\TranslationBundle\Translation\Comparison\ChangeSet;
use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class AbstractTranslationCaseTest extends TestCase
Expand All @@ -23,9 +24,7 @@ public function testEmptyChangeSetPasses(): void
$this->addToAssertionCount(1);
}

/**
* @dataProvider provideChangeSetsWithPendingMessages
*/
#[DataProvider('provideChangeSetsWithPendingMessages')]
public function testChangeSetWithPendingMessagesFails(
ChangeSet $changeSet,
string $expectedMessage
Expand Down