Unverified Commit b578a102 authored by Michael Moravec's avatar Michael Moravec Committed by Sergei Morozov

Remove deprecated AbstractSchemaManager::getFilterSchemaAssetsExpression(),...

Remove deprecated AbstractSchemaManager::getFilterSchemaAssetsExpression(), Configuration::getFilterSchemaAssetsExpression() and Configuration::getFilterSchemaAssetsExpression()
parent d3d8568b
......@@ -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`.
......
......@@ -85,18 +85,6 @@ class Configuration
}
}
/**
* Returns filter schema assets expression.
*
* @deprecated Use Configuration::getSchemaAssetsFilter() instead
*
* @return string|null
*/
public function getFilterSchemaAssetsExpression()
{
return $this->_attributes['filterSchemaAssetsExpression'] ?? null;
}
/**
* @param string $filterExpression
*/
......
......@@ -236,16 +236,6 @@ abstract class AbstractSchemaManager
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.
*
......
......@@ -18,6 +18,7 @@ use Doctrine\DBAL\Types\Types;
use function array_map;
use function array_pop;
use function count;
use function preg_match;
use function strtolower;
class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
......@@ -30,7 +31,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
return;
}
$this->connection->getConfiguration()->setFilterSchemaAssetsExpression(null);
$this->connection->getConfiguration()->setSchemaAssetsFilter(null);
}
/**
......@@ -214,11 +215,15 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$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);
}
......
......@@ -13,6 +13,7 @@ use Doctrine\DBAL\Schema\DB2SchemaManager;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use function in_array;
use function preg_match;
/**
* @covers \Doctrine\DBAL\Schema\DB2SchemaManager
......@@ -50,7 +51,9 @@ final class DB2SchemaManagerTest extends TestCase
*/
public function testListTableNamesFiltersAssetNamesCorrectly() : void
{
$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'],
......@@ -67,35 +70,6 @@ final class DB2SchemaManagerTest extends TestCase
);
}
/**
* @group DBAL-2701
*/
public function testAssetFilteringSetsACallable() : void
{
$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());
}
public function testListTableNamesFiltersAssetNamesCorrectlyWithCallable() : void
{
$accepted = ['T_FOO', 'T_BAR'];
......@@ -117,79 +91,5 @@ final class DB2SchemaManagerTest extends TestCase
],
$this->manager->listTableNames()
);
$this->assertNull($this->conn->getConfiguration()->getFilterSchemaAssetsExpression());
}
public function testSettingNullExpressionWillResetCallable() : void
{
$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());
}
public function testSettingNullAsCallableClearsExpression() : void
{
$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());
}
}
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