Unverified Commit e5d1edc2 authored by Sergei Morozov's avatar Sergei Morozov

Merge branch 'bpo/2.10/#3790' into 2.10

parents d49d68f6 a5256109
......@@ -233,7 +233,7 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
$position = strrpos($name, '.');
if ($position !== false) {
$name = substr($name, $position);
$name = substr($name, $position + 1);
}
return strtolower($name);
......
......@@ -4,6 +4,7 @@ namespace Doctrine\Tests\DBAL\Schema;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Table;
use PHPUnit\Framework\TestCase;
class ForeignKeyConstraintTest extends TestCase
......@@ -56,4 +57,30 @@ class ForeignKeyConstraintTest extends TestCase
[['FOO'], true],
];
}
/**
* @param string|Table $foreignTableName
*
* @group DBAL-1062
* @dataProvider getUnqualifiedForeignTableNameData
*/
public function testGetUnqualifiedForeignTableName($foreignTableName, string $expectedUnqualifiedTableName) : void
{
$foreignKey = new ForeignKeyConstraint(['foo', 'bar'], $foreignTableName, ['fk_foo', 'fk_bar']);
self::assertSame($expectedUnqualifiedTableName, $foreignKey->getUnqualifiedForeignTableName());
}
/**
* @return mixed[][]
*/
public static function getUnqualifiedForeignTableNameData() : iterable
{
return [
['schema.foreign_table', 'foreign_table'],
['foreign_table', 'foreign_table'],
[new Table('schema.foreign_table'), 'foreign_table'],
[new Table('foreign_table'), 'foreign_table'],
];
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment