diff --git a/core-bundle/tests/Contao/DataContainerTest.php b/core-bundle/tests/Contao/DataContainerTest.php index f1ffb0a45bd..262ce84e0fe 100644 --- a/core-bundle/tests/Contao/DataContainerTest.php +++ b/core-bundle/tests/Contao/DataContainerTest.php @@ -23,8 +23,10 @@ class DataContainerTest extends TestCase public function testCombiner(array $source, array $expected): void { $class = new \ReflectionClass(DC_Table::class); + $method = $class->getMethod('combiner'); $method->setAccessible(true); + $names = $method->invoke($class->newInstanceWithoutConstructor(), $source); $this->assertSame($expected, array_values($names)); diff --git a/core-bundle/tests/Contao/DC_TableTest.php b/core-bundle/tests/Contao/DcTableTest.php similarity index 55% rename from core-bundle/tests/Contao/DC_TableTest.php rename to core-bundle/tests/Contao/DcTableTest.php index 9857494cd8d..ad6863dae1a 100644 --- a/core-bundle/tests/Contao/DC_TableTest.php +++ b/core-bundle/tests/Contao/DcTableTest.php @@ -18,7 +18,7 @@ use Contao\Database\Statement; use Contao\DC_Table; -class DC_TableTest extends TestCase +class DcTableTest extends TestCase { /** * @dataProvider getPalette @@ -28,7 +28,6 @@ public function testGetPalette(array $dca, array $row, string $expected): void $result = new Result([$row], ''); $statement = $this->createMock(Statement::class); - $statement ->method('limit') ->willReturn($statement) @@ -46,14 +45,13 @@ public function testGetPalette(array $dca, array $row, string $expected): void ; $reflection = new \ReflectionClass(DC_Table::class); - $dataContainer = $reflection->newInstanceWithoutConstructor(); - $method = $reflection->getMethod('import'); - $method->setAccessible(true); - $method->invoke($dataContainer, $database, 'Database'); + $dataContainer = $reflection->newInstanceWithoutConstructor(); + $dataContainer->Database = $database; - /** @phpstan-ignore-next-line */ - $dataContainer->strTable = 'tl_test'; + $table = $reflection->getProperty('strTable'); + $table->setAccessible(true); + $table->setValue($dataContainer, 'tl_test'); $GLOBALS['TL_DCA']['tl_test'] = $dca; @@ -62,28 +60,26 @@ public function testGetPalette(array $dca, array $row, string $expected): void public function getPalette(): array { - return [ + return [[ [ - [ - 'palettes' => [ - '__selector__' => ['fieldA', 'fieldB', 'fieldC'], - 'default' => 'paletteDefault', - 'valueA' => 'paletteA', - 'valueAvalueC' => 'paletteAC', - ], - 'fields' => [ - 'fieldA' => ['inputType' => 'text'], - 'fieldB' => ['inputType' => 'text'], - 'fieldC' => ['inputType' => 'text'], - ], + 'palettes' => [ + '__selector__' => ['fieldA', 'fieldB', 'fieldC'], + 'default' => 'paletteDefault', + 'valueA' => 'paletteA', + 'valueAvalueC' => 'paletteAC', ], - [ - 'fieldA' => 'valueA', - 'fieldB' => null, - 'fieldC' => 'valueC', + 'fields' => [ + 'fieldA' => ['inputType' => 'text'], + 'fieldB' => ['inputType' => 'text'], + 'fieldC' => ['inputType' => 'text'], ], - 'paletteAC', ], - ]; + [ + 'fieldA' => 'valueA', + 'fieldB' => null, + 'fieldC' => 'valueC', + ], + 'paletteAC', + ]]; } }