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 @@ -9,6 +9,7 @@ yarn-error.log
package-lock.json
.DS_Store
.phpunit.result.cache
.phpunit.cache/
composer.lock
/var
tsconfig.json
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,12 @@
"ibexa/test-core": "~6.0.x-dev",
"ibexa/test-rest": "~6.0.x-dev",
"ibexa/translations": "~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.5",
"phpunit/phpunit": "^11.5",
"symfony/phpunit-bridge": "^7.4",
"webmozart/assert": "^2.3"
},
"config": {
Expand Down
37 changes: 16 additions & 21 deletions phpunit.integration.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="tests/integration/bootstrap.php"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnWarning="true"
colors="true">
<testsuites>
<testsuite name="integration">
<directory>tests/integration</directory>
</testsuite>
</testsuites>
<php>
<env name="DATABASE_URL" value="sqlite://i@i/var/test.db" />
<env name="KERNEL_CLASS" value="Ibexa\Tests\Integration\AdminUi\AdminUiIbexaTestKernel" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0&amp;max[direct]=0&amp;verbose=0"/>
</php>
<extensions>
<extension class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension" />
</extensions>
<?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="tests/integration/bootstrap.php" beStrictAboutOutputDuringTests="true" failOnWarning="true" colors="true" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="integration">
<directory>tests/integration</directory>
</testsuite>
</testsuites>
<php>
<env name="DATABASE_URL" value="sqlite://i@i/var/test.db"/>
<env name="KERNEL_CLASS" value="Ibexa\Tests\Integration\AdminUi\AdminUiIbexaTestKernel"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0&amp;max[direct]=0&amp;verbose=0"/>
</php>
<extensions>
<bootstrap class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension"/>
<bootstrap class="Symfony\Bridge\PhpUnit\SymfonyExtension"/>
</extensions>
</phpunit>
36 changes: 18 additions & 18 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="bootstrap.php"
colors="true">
<testsuites>
<testsuite name="Ibexa\Bundle\AdminUi">
<directory>tests/bundle</directory>
</testsuite>
<testsuite name="Ibexa\AdminUi">
<directory>tests/lib</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory>src</directory>
</include>
</coverage>
<?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="bootstrap.php" colors="true" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="Ibexa\Bundle\AdminUi">
<directory>tests/bundle</directory>
</testsuite>
<testsuite name="Ibexa\AdminUi">
<directory>tests/lib</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>src</directory>
</include>
</source>
<extensions>
<bootstrap class="Symfony\Bridge\PhpUnit\SymfonyExtension"/>
</extensions>
</phpunit>
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LogicalAnd;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface;
use Ibexa\Contracts\Rest\Input\Parser\Query\Criterion\CriterionProcessorInterface;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;
Expand All @@ -26,9 +28,8 @@
* @phpstan-type TCriterionProcessor \Ibexa\Contracts\Rest\Input\Parser\Query\Criterion\CriterionProcessorInterface<
* \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion
* >
*
* @covers \Ibexa\Bundle\AdminUi\ValueResolver\ContentTreeChildrenQueryValueResolver
*/
#[CoversClass(ContentTreeChildrenQueryValueResolver::class)]
final class ContentTreeChildrenQueryArgumentResolverTest extends TestCase
{
private ValueResolverInterface $resolver;
Expand All @@ -44,9 +45,7 @@ protected function setUp(): void
);
}

/**
* @dataProvider provideDataForUnsupported
*/
#[DataProvider('provideDataForUnsupported')]
public function testUnsupported(ArgumentMetadata $argumentMetadata): void
{
$actualResult = $this->resolver->resolve(
Expand All @@ -62,35 +61,34 @@ public function testUnsupported(ArgumentMetadata $argumentMetadata): void
* \Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata
* }>
*/
public function provideDataForUnsupported(): iterable
public static function provideDataForUnsupported(): iterable
{
yield 'Not supported' => [
$this->createMock(ArgumentMetadata::class),
self::createStub(ArgumentMetadata::class),
];

yield 'Not supported - invalid argument type' => [
$this->createArgumentMetadata(
self::createArgumentMetadata(
'filter',
'foo',
),
];

yield 'Not supported - invalid argument name' => [
$this->createArgumentMetadata(
self::createArgumentMetadata(
'foo',
Criterion::class,
),
];
}

/**
* @dataProvider provideDataForTestResolve
*
* @param array<string, string|array<mixed>> $criteriaToProcess
* @param Traversable<\Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface> $expectedCriteria
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException
*/
#[DataProvider('provideDataForTestResolve')]
public function testResolve(
CriterionInterface $expected,
Request $request,
Expand Down Expand Up @@ -130,17 +128,17 @@ public function testResolve(
*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidCriterionArgumentException
*/
public function provideDataForTestResolve(): iterable
public static function provideDataForTestResolve(): iterable
{
yield 'Return null - missing filter query param' => [
new LogicalAnd([]),
$this->createRequest(null),
self::createRequest(null),
new ArrayIterator(),
];

yield 'Return null - empty value for filter query param' => [
new LogicalAnd([]),
$this->createRequest([]),
self::createRequest([]),
new ArrayIterator(),
];

Expand All @@ -153,7 +151,7 @@ public function provideDataForTestResolve(): iterable

yield 'Return filter with ContentTypeIdentifier criterion' => [
new LogicalAnd($expectedCriteria),
$this->createRequest($criteriaToProcess),
self::createRequest($criteriaToProcess),
new ArrayIterator($expectedCriteria),
$criteriaToProcess,
];
Expand All @@ -176,7 +174,7 @@ private function mockCriterionProcessorProcessCriteria(
/**
* @param array<mixed>|null $filter
*/
private function createRequest(?array $filter): Request
private static function createRequest(?array $filter): Request
{
$request = Request::create('/');

Expand All @@ -187,7 +185,7 @@ private function createRequest(?array $filter): Request
return $request;
}

private function createArgumentMetadata(
private static function createArgumentMetadata(
string $name,
string $type
): ArgumentMetadata {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use Ibexa\Bundle\AdminUi\DependencyInjection\Compiler\FieldTypeFormMapperDispatcherPass;
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase;
use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
Expand All @@ -28,9 +29,7 @@ protected function registerCompilerPass(ContainerBuilder $container): void
$container->addCompilerPass(new FieldTypeFormMapperDispatcherPass());
}

/**
* @dataProvider tagsProvider
*/
#[DataProvider('tagsProvider')]
public function testRegisterMappers(string $tag): void
{
$fieldTypeIdentifier = 'field_type_identifier';
Expand All @@ -51,7 +50,7 @@ public function testRegisterMappers(string $tag): void
/**
* @return array<array<string>>
*/
public function tagsProvider(): array
public static function tagsProvider(): array
{
return [
[FieldTypeFormMapperDispatcherPass::FIELD_TYPE_FORM_MAPPER_DEFINITION_SERVICE_TAG],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,22 @@ public function testContentEditFormTemplatesAreMapped(): void
'my_template-01.html.twig',
'my_template-02.html.twig',
];
$matcher = self::atLeast(2);

$this->contextualizer
->expects(self::atLeast(2))
->method('setContextualParameter')
->withConsecutive(
[
AdminUiForms::FORM_TEMPLATES_PARAM,
$currentScope,
$expectedTemplatesList,
],
[
AdminUiForms::FIELD_TYPES_PARAM,
$currentScope,
[],
],
);
->expects($matcher)
->method('setContextualParameter')->willReturnCallback(function (...$parameters) use ($matcher, $currentScope, $expectedTemplatesList): void {
if ($matcher->numberOfInvocations() === 1) {
$this->assertSame(AdminUiForms::FORM_TEMPLATES_PARAM, $parameters[0]);
$this->assertSame($currentScope, $parameters[1]);
$this->assertSame($expectedTemplatesList, $parameters[2]);
}
if ($matcher->numberOfInvocations() === 2) {
$this->assertSame(AdminUiForms::FIELD_TYPES_PARAM, $parameters[0]);
$this->assertSame($currentScope, $parameters[1]);
$this->assertSame([], $parameters[2]);
}
});

$this->parser->mapConfig($scopeSettings, $currentScope, $this->contextualizer);
}
Expand All @@ -92,22 +92,22 @@ public function testContentEditFieldTypesAreMapped(): void
'my_fieldtype' => ['meta' => true],
'my_fieldtype_2' => ['meta' => false],
];
$matcher = self::atLeast(2);

$this->contextualizer
->expects(self::atLeast(2))
->method('setContextualParameter')
->withConsecutive(
[
AdminUiForms::FORM_TEMPLATES_PARAM,
$currentScope,
[],
],
[
AdminUiForms::FIELD_TYPES_PARAM,
$currentScope,
$expectedFieldTypeSettings,
],
);
->expects($matcher)
->method('setContextualParameter')->willReturnCallback(function (...$parameters) use ($matcher, $currentScope, $expectedFieldTypeSettings): void {
if ($matcher->numberOfInvocations() === 1) {
$this->assertSame(AdminUiForms::FORM_TEMPLATES_PARAM, $parameters[0]);
$this->assertSame($currentScope, $parameters[1]);
$this->assertSame([], $parameters[2]);
}
if ($matcher->numberOfInvocations() === 2) {
$this->assertSame(AdminUiForms::FIELD_TYPES_PARAM, $parameters[0]);
$this->assertSame($currentScope, $parameters[1]);
$this->assertSame($expectedFieldTypeSettings, $parameters[2]);
}
});

$this->parser->mapConfig($scopeSettings, $currentScope, $this->contextualizer);
}
Expand All @@ -128,27 +128,27 @@ public function testContentEditMetaFieldgroupListIsMapped(): void
],
];
$currentScope = 'admin_group';
$matcher = self::atLeast(2);

$this->contextualizer
->expects(self::atLeast(2))
->method('setContextualParameter')
->withConsecutive(
[
AdminUiForms::FORM_TEMPLATES_PARAM,
$currentScope,
[],
],
[
AdminUiForms::FIELD_TYPES_PARAM,
$currentScope,
[],
],
[
AdminUiForms::META_FIELD_GROUPS_LIST_PARAM,
$currentScope,
['metadata', 'seo'],
],
);
->expects($matcher)
->method('setContextualParameter')->willReturnCallback(function (...$parameters) use ($matcher, $currentScope): void {
if ($matcher->numberOfInvocations() === 1) {
$this->assertSame(AdminUiForms::FORM_TEMPLATES_PARAM, $parameters[0]);
$this->assertSame($currentScope, $parameters[1]);
$this->assertSame([], $parameters[2]);
}
if ($matcher->numberOfInvocations() === 2) {
$this->assertSame(AdminUiForms::FIELD_TYPES_PARAM, $parameters[0]);
$this->assertSame($currentScope, $parameters[1]);
$this->assertSame([], $parameters[2]);
}
if ($matcher->numberOfInvocations() === 3) {
$this->assertSame(AdminUiForms::META_FIELD_GROUPS_LIST_PARAM, $parameters[0]);
$this->assertSame($currentScope, $parameters[1]);
$this->assertSame(['metadata', 'seo'], $parameters[2]);
}
});

$this->parser->mapConfig($scopeSettings, $currentScope, $this->contextualizer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@

use Ibexa\Bundle\AdminUi\DependencyInjection\Configuration\Parser\ContentTypeFieldsByExpression;
use Ibexa\Bundle\Core\DependencyInjection\Configuration\SiteAccessAware\ContextualizerInterface;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

/**
* @covers \Ibexa\Bundle\AdminUi\DependencyInjection\Configuration\Parser\SubtreeOperations
*/
#[CoversClass(ContentTypeFieldsByExpression::class)]
final class ContentTypeFieldsByExpressionTest extends TestCase
{
private ContentTypeFieldsByExpression $parser;
Expand Down
Loading
Loading