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
@@ -1,5 +1,6 @@
/.deptrac.cache
/.php-cs-fixer.cache
/.phpunit.cache/
/.phpunit.result.cache
/composer.lock
/node_modules/
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"ibexa/test-core": "~6.0.x-dev",
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpunit/phpunit": "^9.0",
"phpunit/phpunit": "^11.5",
"symfony/phpunit-bridge": "^7.4"
},
"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ parameters:
path: src/contracts/Gateway/DoctrineOneToManyRelationship.php

-
message: '#^PHPDoc tag @var with type Exception is not subtype of native type PHPUnit\\Framework\\MockObject\\MockObject\.$#'
message: '#^PHPDoc tag @var with type Exception is not subtype of native type PHPUnit\\Framework\\MockObject\\Stub\.$#'
identifier: varTag.nativeType
count: 1
path: tests/bundle/Gateway/ExpressionVisitorTest.php
Expand Down
11 changes: 4 additions & 7 deletions phpunit.integration.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd"
bootstrap="tests/integration/bootstrap.php"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnWarning="true"
verbose="true">
cacheDirectory=".phpunit.cache">
<php>
<env name="KERNEL_CLASS" value="Ibexa\Tests\Integration\CorePersistence\Kernel" />
<env name="SEARCH_ENGINE" value="legacy" />
Expand All @@ -17,9 +16,7 @@
</testsuite>
</testsuites>
<extensions>
<extension class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension" />
<bootstrap class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension" />
<bootstrap class="Symfony\Bridge\PhpUnit\SymfonyExtension"/>
</extensions>
<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
</listeners>
</phpunit>
16 changes: 10 additions & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
<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">
<?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="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0&amp;max[direct]=0&amp;max[indirect]=15&amp;verbose=0"/>
</php>
<extensions>
<bootstrap class="Symfony\Bridge\PhpUnit\SymfonyExtension"/>
</extensions>
<testsuites>
<testsuite name="bundle">
<directory>tests/bundle</directory>
Expand Down
2 changes: 1 addition & 1 deletion tests/bundle/Gateway/DoctrineSchemaMetadataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class DoctrineSchemaMetadataTest extends TestCase
protected function setUp(): void
{
$this->metadata = new DoctrineSchemaMetadata(
$this->createMock(Connection::class),
$this->createStub(Connection::class),
'stdClass',
'std_class_table',
[
Expand Down
8 changes: 4 additions & 4 deletions tests/bundle/Gateway/ExpressionVisitorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Ibexa\CorePersistence\Gateway\ExpressionVisitor;
use Ibexa\CorePersistence\Gateway\Parameter;
use Ibexa\CorePersistence\Gateway\RelationshipTypeStrategyRegistry;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Constraint\IsIdentical;
use PHPUnit\Framework\TestCase;

Expand Down Expand Up @@ -155,7 +156,7 @@ public function testFieldNotFound(): void
public function testFieldFromMissingRelationship(): void
{
/** @var \Exception $exception */
$exception = $this->createMock(RuntimeMappingExceptionInterface::class);
$exception = $this->createStub(RuntimeMappingExceptionInterface::class);
$this->schemaMetadata
->expects(self::once())
->method('getRelationshipByForeignProperty')
Expand Down Expand Up @@ -236,10 +237,9 @@ public function testFieldFromSubSelectRelationship(): void
}

/**
* @dataProvider provideForFieldFromInheritedRelationship
*
* @phpstan-param array<\Ibexa\CorePersistence\Gateway\Parameter> $parameters
*/
#[DataProvider('provideForFieldFromInheritedRelationship')]
public function testFieldFromInheritedRelationship(
Comparison $comparison,
string $expectedResult,
Expand Down Expand Up @@ -455,7 +455,7 @@ private function createRelationshipSchemaMetadata(string $tableName = 'relations

/**
* @param \Ibexa\Contracts\CorePersistence\Gateway\DoctrineSchemaMetadataInterface&\PHPUnit\Framework\MockObject\MockObject $metadata
* @param array<string> $fields
* @param list<string> $fields
*/
private function configureFieldInMetadata(DoctrineSchemaMetadataInterface $metadata, array $fields): void
{
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/Gateway/ExpressionVisitorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Ibexa\Contracts\Test\Core\IbexaKernelTestCase;
use Ibexa\CorePersistence\Gateway\ExpressionVisitor;
use Ibexa\CorePersistence\Gateway\RelationshipTypeStrategyRegistry;
use PHPUnit\Framework\Attributes\DataProvider;

final class ExpressionVisitorTest extends IbexaKernelTestCase
{
Expand All @@ -40,7 +41,8 @@ protected function setUp(): void
$registry,
'article',
'article',
new RelationshipTypeStrategyRegistry()
new RelationshipTypeStrategyRegistry(),
$connection
);
}

Expand All @@ -60,9 +62,7 @@ public function testInvalidField(): void
$this->expressionVisitor->dispatch(new Comparison('non_existent_field', '=', 'bar'));
}

/**
* @dataProvider provideForTraversingRelationships
*/
#[DataProvider('provideForTraversingRelationships')]
public function testTraversingRelationships(Comparison $expr, string $expectedResult): void
{
// Note: This assumes relationship tables are joined before being used.
Expand Down
8 changes: 4 additions & 4 deletions tests/lib/Gateway/DoInsertIdentifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Ibexa\Contracts\CorePersistence\Gateway\AbstractDoctrineDatabase;
use Ibexa\Contracts\CorePersistence\Gateway\DoctrineSchemaMetadataRegistryInterface;
use Ibexa\Tests\CorePersistence\Stub\IdentifierProbeGateway;
use LogicException;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

/**
* @covers \Ibexa\Contracts\CorePersistence\Gateway\AbstractDoctrineDatabase
*/
#[CoversClass(AbstractDoctrineDatabase::class)]
final class DoInsertIdentifierTest extends TestCase
{
/** @var \Doctrine\DBAL\Connection&\PHPUnit\Framework\MockObject\MockObject */
Expand Down Expand Up @@ -71,7 +71,7 @@ private function createGateway(array $identifierColumns): IdentifierProbeGateway
{
return new IdentifierProbeGateway(
$this->connection,
$this->createMock(DoctrineSchemaMetadataRegistryInterface::class),
$this->createStub(DoctrineSchemaMetadataRegistryInterface::class),
$identifierColumns,
);
}
Expand Down
5 changes: 2 additions & 3 deletions tests/lib/Gateway/JoinedRelationshipTypeStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
use Doctrine\DBAL\Query\QueryBuilder;
use Ibexa\Contracts\CorePersistence\Gateway\DoctrineRelationship;
use Ibexa\CorePersistence\Gateway\JoinedRelationshipTypeStrategy;
use PHPUnit\Framework\Attributes\CoversClass;

/**
* @covers \Ibexa\CorePersistence\Gateway\JoinedRelationshipTypeStrategy
*/
#[CoversClass(JoinedRelationshipTypeStrategy::class)]
final class JoinedRelationshipTypeStrategyTest extends BaseRelationshipTypeStrategyTestCase
{
private JoinedRelationshipTypeStrategy $strategy;
Expand Down
9 changes: 4 additions & 5 deletions tests/lib/Gateway/RelationshipTypeStrategyRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
use Ibexa\Contracts\CorePersistence\Exception\RuntimeMappingException;
use Ibexa\CorePersistence\Gateway\RelationshipTypeStrategyRegistry;
use Ibexa\Tests\CorePersistence\Stub\InvalidDoctrineRelationship;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

/**
* @covers \Ibexa\CorePersistence\Gateway\RelationshipTypeStrategyRegistry
*/
#[CoversClass(RelationshipTypeStrategyRegistry::class)]
final class RelationshipTypeStrategyRegistryTest extends TestCase
{
private RelationshipTypeStrategyRegistry $registry;
Expand All @@ -33,7 +32,7 @@ public function testHandleRelationshipTypeThrowsRuntimeMappingException(): void
$this->expectExceptionMessage('Unhandled relationship metadata. Expected one of "Ibexa\Contracts\CorePersistence\Gateway\DoctrineRelationship", "Ibexa\Contracts\CorePersistence\Gateway\DoctrineOneToManyRelationship". Received "Ibexa\Tests\CorePersistence\Stub\InvalidDoctrineRelationship"');

$this->registry->handleRelationshipType(
new QueryBuilder($this->createMock(Connection::class)),
new QueryBuilder($this->createStub(Connection::class)),
new InvalidDoctrineRelationship(),
'root_table_alias',
'from_table',
Expand All @@ -48,7 +47,7 @@ public function testHandleRelationshipTypeQueryThrowsRuntimeMappingException():

$this->registry->handleRelationshipTypeQuery(
new InvalidDoctrineRelationship(),
$this->createMock(QueryBuilder::class),
$this->createStub(QueryBuilder::class),
'related_class_id_column',
'related_class_id_column_0'
);
Expand Down
5 changes: 2 additions & 3 deletions tests/lib/Gateway/SubSelectRelationshipTypeStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
use Ibexa\Contracts\CorePersistence\Gateway\DoctrineRelationship;
use Ibexa\CorePersistence\Gateway\SubSelectRelationshipTypeStrategy;
use LogicException;
use PHPUnit\Framework\Attributes\CoversClass;

/**
* @covers \Ibexa\CorePersistence\Gateway\SubSelectRelationshipTypeStrategy
*/
#[CoversClass(SubSelectRelationshipTypeStrategy::class)]
final class SubSelectRelationshipTypeStrategyTest extends BaseRelationshipTypeStrategyTestCase
{
private SubSelectRelationshipTypeStrategy $strategy;
Expand Down