Skip to content

Commit

Permalink
Merge branch 'bpo/2.10/#3790' into 2.10
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed Jan 13, 2020
2 parents d49d68f + a525610 commit e5d1edc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public function getUnqualifiedForeignTableName()
$position = strrpos($name, '.');

if ($position !== false) {
$name = substr($name, $position);
$name = substr($name, $position + 1);
}

return strtolower($name);
Expand Down
27 changes: 27 additions & 0 deletions tests/Doctrine/Tests/DBAL/Schema/ForeignKeyConstraintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Table;
use PHPUnit\Framework\TestCase;

class ForeignKeyConstraintTest extends TestCase
Expand Down Expand Up @@ -56,4 +57,30 @@ public static function getIntersectsIndexColumnsData() : iterable
[['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'],
];
}
}

0 comments on commit e5d1edc

Please sign in to comment.