Skip to content

Commit 101b040

Browse files
committed
Fixed testing on Doctrine/ORM ^3.4
1 parent 8d882b5 commit 101b040

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

phpstan.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@ parameters:
3434
path: 'tests/Bundle/DataGridBundle/Fixtures/TestKernel.php'
3535
- message: '#.*Symfony\\Component\\Routing\\RouteCollectionBuilder.*#'
3636
path: 'tests/Bundle/DataSourceBundle/Fixtures/TestKernel.php'
37+
- message: '#Access to an undefined property Doctrine\\ORM\\Mapping\\ClassMetadata<Tests\\FSi\\Bundle\\DataGridBundle\\Fixtures\\EntityCategory>::\$propertyAccessors\.#'
38+
path: 'tests/Bundle/DataGridBundle/DataGrid/ColumnTypExtension/FormExtensionTest.php'
3739
- message: "#Property Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadata<Tests\\\\FSi\\\\Bundle\\\\DataGridBundle\\\\Fixtures\\\\EntityCategory>::\\$fieldMappings \\(array<string, Doctrine\\\\ORM\\\\Mapping\\\\FieldMapping>\\) does not accept array<string, array<string, array\\|string>>\\.#"

tests/Bundle/DataGridBundle/DataGrid/ColumnTypeExtension/FormExtensionTest.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Doctrine\ORM\EntityRepository;
1919
use Doctrine\ORM\Mapping\ClassMetadata;
2020
use Doctrine\ORM\Mapping\FieldMapping;
21+
use Doctrine\ORM\Mapping\PropertyAccessors\PropertyAccessorFactory;
2122
use Doctrine\ORM\Query;
2223
use Doctrine\ORM\Query\Expr;
2324
use Doctrine\ORM\QueryBuilder;
@@ -210,9 +211,16 @@ protected function setUp(): void
210211
'id' => $fieldMapping
211212
];
212213
}
213-
$classMetadata->reflFields = [
214-
'id' => new ReflectionProperty($entityClass, 'id'),
215-
];
214+
if (true === class_exists(PropertyAccessorFactory::class)) {
215+
/* @phpstan-ignore-next-line */
216+
$classMetadata->propertyAccessors = [
217+
'id' => PropertyAccessorFactory::createPropertyAccessor($entityClass, 'id'),
218+
];
219+
} else {
220+
$classMetadata->reflFields = [
221+
'id' => new ReflectionProperty($entityClass, 'id'),
222+
];
223+
}
216224

217225
$repository = $this->getMockBuilder(EntityRepository::class)
218226
->setConstructorArgs([$objectManager, $classMetadata])

tests/Bundle/DataGridBundle/Twig/Extension/DataGridRuntimeTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,8 @@ public function testDataGridColumnActionCellActionRenderBlock(): void
381381
'attr' => [],
382382
'translation_domain' => null,
383383
'field_mapping_values' => [],
384-
'global_var' => 'global_value'
384+
'global_var' => 'global_value',
385+
'vars' => [],
385386
])
386387
->willReturn('template');
387388

0 commit comments

Comments
 (0)