Skip to content

Commit

Permalink
Merge 3.6.x into 3.7.x (#6054)
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus authored Jun 5, 2023
2 parents 57e31ad + 4e673be commit 01c4ce1
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
6 changes: 3 additions & 3 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ if (! $diff->isEmpty()) {
}
```

## Deprecated not passing `$fromColumn` to the `TableDiff` constructor.
## Deprecated not passing `$fromTable` to the `TableDiff` constructor.

Not passing `$fromColumn` to the `TableDiff` constructor has been deprecated.
Not passing `$fromTable` to the `TableDiff` constructor has been deprecated.

The `TableDiff::$name` property and the `TableDiff::getName()` method have been deprecated as well. In order to obtain
the name of the table that the diff describes, use `TableDiff::getOldTable()`.
Expand Down Expand Up @@ -1002,7 +1002,7 @@ deprecated in order to provide a more consistent API.

## Deprecated `Comparator::compare($fromSchema, $toSchema)`

The usage of `Comparator::compare($fromSchema, $toSchema)` is deprecated and
The usage of `Comparator::compare($fromSchema, $toSchema)` is deprecated and
replaced by `Comparator::compareSchemas($fromSchema, $toSchema)` in order to
clarify the purpose of the method.

Expand Down
4 changes: 2 additions & 2 deletions src/Schema/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ public function getColumns()
*/
public function getForeignKeyColumns()
{
Deprecation::trigger(
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5731',
'%s is deprecated. Use getForeignKey() and ForeignKeyConstraint::getLocalColumns() instead.',
Expand Down Expand Up @@ -813,7 +813,7 @@ public function getPrimaryKey()
*/
public function getPrimaryKeyColumns()
{
Deprecation::trigger(
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5731',
'%s is deprecated. Use getPrimaryKey() and Index::getColumns() instead.',
Expand Down
4 changes: 2 additions & 2 deletions src/Schema/TableDiff.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,11 @@ public function __construct(
$this->changedForeignKeys = $changedForeignKeys;
$this->removedForeignKeys = $removedForeignKeys;

if ($fromTable !== null) {
if ($fromTable === null) {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5678',
'Not passing the $fromColumn to %s is deprecated.',
'Not passing the $fromTable to %s is deprecated.',
__METHOD__,
);
}
Expand Down
24 changes: 24 additions & 0 deletions tests/Schema/TableDiffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
use Doctrine\DBAL\Schema\Identifier;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

class TableDiffTest extends TestCase
{
use VerifyDeprecations;

/** @var AbstractPlatform&MockObject */
private AbstractPlatform $platform;

Expand Down Expand Up @@ -53,4 +56,25 @@ public function testReturnsNewName(): void

self::assertEquals(new Identifier('bar'), $tableDiff->getNewName());
}

public function testOmittingFromTableInConstructorIsDeprecated(): void
{
$this->expectDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/5678');
$tableDiff = new TableDiff('foo');
}

public function testPassingFromTableToConstructorIsDeprecated(): void
{
$this->expectNoDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/5678');
$tableDiff = new TableDiff(
'foo',
[],
[],
[],
[],
[],
[],
new Table('foo'),
);
}
}

0 comments on commit 01c4ce1

Please sign in to comment.