Skip to content

Commit

Permalink
Merge pull request #6051 from greg0ire/clear-up-confusion
Browse files Browse the repository at this point in the history
Reference the right argument
  • Loading branch information
greg0ire committed Jun 1, 2023
2 parents 4d27b98 + b94a87f commit 9a747d2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 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/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 9a747d2

Please sign in to comment.