1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
<?php
declare(strict_types=1);
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\DiscriminatorColumn;
use Doctrine\ORM\Mapping\DiscriminatorMap;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\InheritanceType;
use Doctrine\ORM\Mapping\Table;
use Doctrine\Tests\OrmFunctionalTestCase;
use function method_exists;
class GH10462Test extends OrmFunctionalTestCase
{
public function testCharsetAndCollationOptionsOnDiscriminatedColumn(): void
{
if (! $this->_em->getConnection()->getDatabasePlatform() instanceof MySQLPlatform) {
self::markTestSkipped('This test is useful for all databases, but designed only for mysql.');
}
if (method_exists(AbstractPlatform::class, 'getGuidExpression')) {
self::markTestSkipped('Test valid for doctrine/dbal:3.x only.');
}
$this->createSchemaForModels(GH10462Person::class, GH10462Employee::class);
$schemaManager = $this->createSchemaManager();
$personOptions = $schemaManager->introspectTable('gh10462_person')->getColumn('discr')->toArray();
self::assertSame('ascii', $personOptions['charset']);
self::assertSame('ascii_general_ci', $personOptions['collation']);
}
}
#[Entity]
#[Table(name: 'gh10462_person')]
#[InheritanceType(value: 'SINGLE_TABLE')]
#[DiscriminatorColumn(name: 'discr', type: 'string', options: ['charset' => 'ascii', 'collation' => 'ascii_general_ci'])]
#[DiscriminatorMap(['person' => GH10462Person::class, 'employee' => GH10462Employee::class])]
class GH10462Person
{
/** @var int */
#[Id]
#[Column(type: 'integer')]
#[GeneratedValue]
public $id;
}
#[Entity]
class GH10462Employee extends GH10462Person
{
}
|