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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
<?php
declare(strict_types=1);
namespace Doctrine\DBAL\Tests\Schema;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Schema\AbstractAsset;
use Doctrine\DBAL\Schema\Identifier;
use Doctrine\DBAL\Schema\Name\GenericName;
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class AbstractAssetTest extends TestCase
{
use VerifyDeprecations;
#[DataProvider('nameParsingDeprecationProvider')]
public function testNameParsingDeprecation(string $name, AbstractPlatform $platform): void
{
$this->expectDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/6592');
$identifier = new Identifier($name);
$identifier->getQuotedName($platform);
}
/** @return iterable<array{string, AbstractPlatform}> */
public static function nameParsingDeprecationProvider(): iterable
{
return [
// unquoted keywords not in normal case
['select', new OraclePlatform()],
['SELECT', new PostgreSQLPlatform()],
// unquoted name not in normal case qualified by quoted name
['"_".id', new OraclePlatform()],
['"_".ID', new PostgreSQLPlatform()],
// parse error
['table.', new MySQLPlatform()],
['"table', new MySQLPlatform()],
['table"', new MySQLPlatform()],
[' ', new MySQLPlatform()],
// incompatible parser behavior
['"example.com"', new MySQLPlatform()],
];
}
#[DataProvider('noNameParsingDeprecationProvider')]
public function testNoNameParsingDeprecation(string $name, AbstractPlatform $platform): void
{
$identifier = new Identifier($name);
$this->expectNoDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/6592');
$identifier->getQuotedName($platform);
}
/** @return iterable<array{string, AbstractPlatform}> */
public static function noNameParsingDeprecationProvider(): iterable
{
return [
// empty name
['', new MySQLPlatform()],
// name with one qualifier
['schema.table', new MySQLPlatform()],
// quoted keywords
['"select"', new OraclePlatform()],
['"SELECT"', new PostgreSQLPlatform()],
// unquoted keywords in normal case
['SELECT', new OraclePlatform()],
['select', new PostgreSQLPlatform()],
// unquoted keywords in any case on a platform that does not force a case
['SELECT', new MySQLPlatform()],
['select', new MySQLPlatform()],
// non-keywords in any case
['id', new OraclePlatform()],
['ID', new OraclePlatform()],
['id', new PostgreSQLPlatform()],
['ID', new PostgreSQLPlatform()],
];
}
public function testConstructWithoutArguments(): void
{
$this->expectDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/6610');
// @phpstan-ignore expr.resultUnused
new /** @extends AbstractAsset<GenericName> */
class extends AbstractAsset {
};
}
public function testCreateParserNotImplemented(): void
{
$this->expectDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/6592');
// @phpstan-ignore expr.resultUnused
new /** @extends AbstractAsset<GenericName> */
class ('foo') extends AbstractAsset {
};
}
}
|