-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add deprecations for current parser behavior
- Loading branch information
Showing
3 changed files
with
241 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?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\Identifier; | ||
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/XXXX'); | ||
|
||
$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()], | ||
|
||
// name with more than one qualifier | ||
['i.am.overqualified', new MySQLPlatform()], | ||
|
||
// 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/XXXX'); | ||
$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()], | ||
]; | ||
} | ||
} |