Skip to content

Commit

Permalink
Remove deprecated AbstractSchemaManager::getFilterSchemaAssetsExpress…
Browse files Browse the repository at this point in the history
…ion(), Configuration::getFilterSchemaAssetsExpression() and Configuration::getFilterSchemaAssetsExpression()
  • Loading branch information
Majkl578 authored and morozov committed May 23, 2019
1 parent d370eeb commit 1993fc2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 137 deletions.
2 changes: 2 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
* Removed `Table::addUnnamedForeignKeyConstraint()` and `Table::addNamedForeignKeyConstraint()`.
* Removed `Table::renameColumn()`.
* Removed `SQLParserUtils::getPlaceholderPositions()`.
* Removed `AbstractSchemaManager::getFilterSchemaAssetsExpression()`, `Configuration::getFilterSchemaAssetsExpression()`
and `Configuration::getFilterSchemaAssetsExpression()`.
* `SQLParserUtils::*_TOKEN` constants made private.

## BC BREAK `Connection::ping()` returns `void`.
Expand Down
12 changes: 0 additions & 12 deletions lib/Doctrine/DBAL/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,6 @@ public function setFilterSchemaAssetsExpression($filterExpression)
}
}

/**
* Returns filter schema assets expression.
*
* @deprecated Use Configuration::getSchemaAssetsFilter() instead
*
* @return string|null
*/
public function getFilterSchemaAssetsExpression()
{
return $this->_attributes['filterSchemaAssetsExpression'] ?? null;
}

/**
* @param string $filterExpression
*/
Expand Down
10 changes: 0 additions & 10 deletions lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,6 @@ protected function filterAssetNames($assetNames)
return array_values(array_filter($assetNames, $filter));
}

/**
* @deprecated Use Configuration::getSchemaAssetsFilter() instead
*
* @return string|null
*/
protected function getFilterSchemaAssetsExpression()
{
return $this->_conn->getConfiguration()->getFilterSchemaAssetsExpression();
}

/**
* Lists the tables for this connection.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use function array_map;
use function array_pop;
use function count;
use function preg_match;
use function strtolower;

class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
Expand All @@ -30,7 +31,7 @@ protected function tearDown() : void
return;
}

$this->connection->getConfiguration()->setFilterSchemaAssetsExpression(null);
$this->connection->getConfiguration()->setSchemaAssetsFilter(null);
}

/**
Expand Down Expand Up @@ -214,11 +215,15 @@ public function testFilterSchemaExpression()
$column = $testTable->addColumn('id', 'integer');
$this->schemaManager->createTable($testTable);

$this->connection->getConfiguration()->setFilterSchemaAssetsExpression('#^dbal204_#');
$this->connection->getConfiguration()->setSchemaAssetsFilter(static function (string $name) : bool {
return preg_match('#^dbal204_#', $name) === 1;
});
$names = $this->schemaManager->listTableNames();
self::assertCount(2, $names);

$this->connection->getConfiguration()->setFilterSchemaAssetsExpression('#^dbal204_test#');
$this->connection->getConfiguration()->setSchemaAssetsFilter(static function (string $name) : bool {
return preg_match('#^dbal204_test#', $name) === 1;
});
$names = $this->schemaManager->listTableNames();
self::assertCount(1, $names);
}
Expand Down
116 changes: 4 additions & 112 deletions tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use function in_array;
use function preg_match;

/**
* @covers \Doctrine\DBAL\Schema\DB2SchemaManager
Expand Down Expand Up @@ -52,7 +53,9 @@ protected function setUp() : void
*/
public function testListTableNamesFiltersAssetNamesCorrectly()
{
$this->conn->getConfiguration()->setFilterSchemaAssetsExpression('/^(?!T_)/');
$this->conn->getConfiguration()->setSchemaAssetsFilter(static function (string $name) : bool {
return preg_match('/^(?!T_)/', $name) === 1;
});
$this->conn->expects($this->once())->method('fetchAll')->will($this->returnValue([
['name' => 'FOO'],
['name' => 'T_FOO'],
Expand All @@ -69,37 +72,6 @@ public function testListTableNamesFiltersAssetNamesCorrectly()
);
}

/**
* @return void
*
* @group DBAL-2701
*/
public function testAssetFilteringSetsACallable()
{
$filterExpression = '/^(?!T_)/';
$this->conn->getConfiguration()->setFilterSchemaAssetsExpression($filterExpression);
$this->conn->expects($this->once())->method('fetchAll')->will($this->returnValue([
['name' => 'FOO'],
['name' => 'T_FOO'],
['name' => 'BAR'],
['name' => 'T_BAR'],
]));

self::assertSame(
[
'FOO',
'BAR',
],
$this->manager->listTableNames()
);

$callable = $this->conn->getConfiguration()->getSchemaAssetsFilter();
self::assertIsCallable($callable);

// BC check: Test that regexp expression is still preserved & accessible.
$this->assertEquals($filterExpression, $this->conn->getConfiguration()->getFilterSchemaAssetsExpression());
}

/**
* @return void
*/
Expand All @@ -124,85 +96,5 @@ public function testListTableNamesFiltersAssetNamesCorrectlyWithCallable()
],
$this->manager->listTableNames()
);

$this->assertNull($this->conn->getConfiguration()->getFilterSchemaAssetsExpression());
}

/**
* @return void
*/
public function testSettingNullExpressionWillResetCallable()
{
$accepted = ['T_FOO', 'T_BAR'];
$this->conn->getConfiguration()->setSchemaAssetsFilter(static function ($assetName) use ($accepted) {
return in_array($assetName, $accepted);
});

$this->conn->expects($this->atLeastOnce())->method('fetchAll')->will($this->returnValue([
['name' => 'FOO'],
['name' => 'T_FOO'],
['name' => 'BAR'],
['name' => 'T_BAR'],
]));

self::assertSame(
[
'T_FOO',
'T_BAR',
],
$this->manager->listTableNames()
);

$this->conn->getConfiguration()->setFilterSchemaAssetsExpression(null);

self::assertSame(
[
'FOO',
'T_FOO',
'BAR',
'T_BAR',
],
$this->manager->listTableNames()
);

$this->assertNull($this->conn->getConfiguration()->getSchemaAssetsFilter());
}

/**
* @return void
*/
public function testSettingNullAsCallableClearsExpression()
{
$filterExpression = '/^(?!T_)/';
$this->conn->getConfiguration()->setFilterSchemaAssetsExpression($filterExpression);

$this->conn->expects($this->exactly(2))->method('fetchAll')->will($this->returnValue([
['name' => 'FOO'],
['name' => 'T_FOO'],
['name' => 'BAR'],
['name' => 'T_BAR'],
]));

self::assertSame(
[
'FOO',
'BAR',
],
$this->manager->listTableNames()
);

$this->conn->getConfiguration()->setSchemaAssetsFilter(null);

self::assertSame(
[
'FOO',
'T_FOO',
'BAR',
'T_BAR',
],
$this->manager->listTableNames()
);

$this->assertNull($this->conn->getConfiguration()->getFilterSchemaAssetsExpression());
}
}

0 comments on commit 1993fc2

Please sign in to comment.