Skip to content

Commit

Permalink
Refactor variable name of included/excluded tables
Browse files Browse the repository at this point in the history
  • Loading branch information
guvra committed Jun 11, 2024
1 parent 361ae79 commit bc47a54
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 39 deletions.
4 changes: 2 additions & 2 deletions src/Console/Helper/DumpInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ private function updateProgressBarMessage(array $tableInfo): void
*/
private function getMaxSteps(DumperConfig $config, MetadataInterface $metadata): int
{
$includedTables = $config->getTablesWhitelist() ?: $metadata->getTableNames();
$excludedTables = $config->getTablesBlacklist();
$includedTables = $config->getIncludedTables() ?: $metadata->getTableNames();
$excludedTables = $config->getExcludedTables();

return count(array_diff($includedTables, $excludedTables));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Dumper/Config/ConfigProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function process(ConfigInterface $config): DumperConfig
}

/**
* Remote tables that don't exist and resolve patterns (e.g. "log_*") for the table whitelist/blacklist.
* Remote tables that don't exist and resolve patterns (e.g. "log_*") for included/excluded tables.
*/
private function processTableLists(ConfigInterface $config): void
{
Expand Down
20 changes: 10 additions & 10 deletions src/Dumper/Config/DumperConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ class DumperConfig
/**
* @var string[]
*/
private array $tablesWhitelist = [];
private array $includedTables = [];

/**
* @var string[]
*/
private array $tablesBlacklist = [];
private array $excludedTables = [];

/**
* @var string[]
Expand Down Expand Up @@ -143,23 +143,23 @@ public function getVarQueries(): array
}

/**
* Get the tables to whitelist.
* Get the tables to include.
*
* @return string[]
*/
public function getTablesWhitelist(): array
public function getIncludedTables(): array
{
return $this->tablesWhitelist;
return $this->includedTables;
}

/**
* Get the tables to blacklist.
* Get the tables to exclude.
*
* @return string[]
*/
public function getTablesBlacklist(): array
public function getExcludedTables(): array
{
return $this->tablesBlacklist;
return $this->excludedTables;
}

/**
Expand Down Expand Up @@ -259,8 +259,8 @@ private function prepareFilterPropagationSettings(ConfigInterface $config): void
*/
private function prepareTableSettings(ConfigInterface $config): void
{
$this->tablesWhitelist = $config->get('tables_whitelist', []);
$this->tablesBlacklist = $config->get('tables_blacklist', []);
$this->includedTables = $config->get('tables_whitelist', []);
$this->excludedTables = $config->get('tables_blacklist', []);
$this->tablesConfig = new TableConfigCollection();

foreach ($config->get('tables', []) as $tableName => $tableData) {
Expand Down
6 changes: 3 additions & 3 deletions src/Dumper/MysqlDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ private function getDumpSettings(DumperConfig $config): array
}
}

// Tables to whitelist/blacklist/truncate
$settings['include-tables'] = $config->getTablesWhitelist();
$settings['exclude-tables'] = $config->getTablesBlacklist();
// Tables to include/exclude/truncate
$settings['include-tables'] = $config->getIncludedTables();
$settings['exclude-tables'] = $config->getExcludedTables();
$settings['no-data'] = $config->getTablesToTruncate();

// Set readonly session
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/Config/Validator/JsonSchemaValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function testDumpSettings(): void
}

/**
* Test the tables whitelist.
* Test the "tables_whitelist" parameter.
*/
public function testTablesWhitelist(): void
{
Expand All @@ -118,7 +118,7 @@ public function testTablesWhitelist(): void
}

/**
* Test the tables blacklist.
* Test the "tables_blacklist" parameter.
*/
public function testTablesBlacklist(): void
{
Expand Down
8 changes: 4 additions & 4 deletions tests/functional/Dumper/Config/ConfigProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public function testTableNameResolution(): void
$config = $processor->process(new Config($data));

// Check if the table names were resolved
$this->assertSame(['customers'], $config->getTablesWhitelist());
$this->assertSame(['stores'], $config->getTablesBlacklist());
$this->assertSame(['customers'], $config->getIncludedTables());
$this->assertSame(['stores'], $config->getExcludedTables());

$tablesConfig = $config->getTablesConfig()->all();
$this->assertArrayHasKey('customers', $tablesConfig);
Expand All @@ -48,8 +48,8 @@ public function testWithEmptyConfig(): void

// Process the configuration
$config = $processor->process(new Config([]));
$this->assertEmpty($config->getTablesBlacklist());
$this->assertEmpty($config->getTablesWhitelist());
$this->assertEmpty($config->getExcludedTables());
$this->assertEmpty($config->getIncludedTables());
$this->assertEmpty($config->getTablesConfig()->all());
}

Expand Down
2 changes: 1 addition & 1 deletion tests/functional/Dumper/MysqlDumperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private function assertDumpIsValid(bool $filterPropagationEnabled = true): void
unlink($this->dumpFile);
$this->assertNotEmpty($output);

// Assert that only whitelisted tables are included in the dump
// Assert that the dump only includes allowed tables
$this->assertStringContainsString('CREATE TABLE `customers`', $output);
$this->assertStringContainsString('CREATE TABLE `stores`', $output);
$this->assertStringContainsString('CREATE TABLE `addresses`', $output);
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/Dumper/Config/ConfigProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public function testProcessor(): void
$processor = $this->createConfigProcessor();
$config = $processor->process($config);

$this->assertSame(['table1'], $config->getTablesBlacklist());
$this->assertSame(['table2'], $config->getTablesWhitelist());
$this->assertSame(['table1'], $config->getExcludedTables());
$this->assertSame(['table2'], $config->getIncludedTables());
$this->assertSame(['table3'], array_keys($config->getTablesConfig()->all()));
}

Expand All @@ -46,8 +46,8 @@ public function testProcessorWithWildCard(): void
$processor = $this->createConfigProcessor();
$config = $processor->process($config);

$this->assertSame(['table1', 'table2', 'table3'], $config->getTablesBlacklist());
$this->assertSame(['table1', 'table2', 'table3'], $config->getTablesWhitelist());
$this->assertSame(['table1', 'table2', 'table3'], $config->getExcludedTables());
$this->assertSame(['table1', 'table2', 'table3'], $config->getIncludedTables());
$this->assertSame(['table1', 'table2', 'table3'], array_keys($config->getTablesConfig()->all()));
}

Expand All @@ -60,8 +60,8 @@ public function testProcessorWithEmptyConfig(): void
$processor = $this->createConfigProcessor();
$config = $processor->process($config);

$this->assertSame([], $config->getTablesBlacklist());
$this->assertSame([], $config->getTablesWhitelist());
$this->assertSame([], $config->getExcludedTables());
$this->assertSame([], $config->getIncludedTables());
$this->assertSame([], $config->getTablesConfig()->all());
}

Expand Down
20 changes: 10 additions & 10 deletions tests/unit/Dumper/Config/DumperConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ class DumperConfigTest extends TestCase
/**
* Test the "tables_whitelist" parameter.
*/
public function testTablesWhitelist(): void
public function testIncludedTables(): void
{
$whitelist = ['table1', 'table2'];
$config = $this->createConfig(['tables_whitelist' => $whitelist]);
$this->assertSame($whitelist, $config->getTablesWhitelist());
$includedTables = ['table1', 'table2'];
$config = $this->createConfig(['tables_whitelist' => $includedTables]);
$this->assertSame($includedTables, $config->getIncludedTables());
}

/**
* Test the "tables_blacklist" parameter.
*/
public function testTablesBlacklist(): void
public function testExcludedTables(): void
{
$blacklist = ['table1', 'table2'];
$config = $this->createConfig(['tables_blacklist' => $blacklist]);
$this->assertSame($blacklist, $config->getTablesBlacklist());
$excludedTables = ['table1', 'table2'];
$config = $this->createConfig(['tables_blacklist' => $excludedTables]);
$this->assertSame($excludedTables, $config->getExcludedTables());
}

/**
Expand Down Expand Up @@ -120,8 +120,8 @@ public function testDefaultValues(): void
{
$config = $this->createConfig([]);

$this->assertSame([], $config->getTablesWhitelist());
$this->assertSame([], $config->getTablesBlacklist());
$this->assertSame([], $config->getIncludedTables());
$this->assertSame([], $config->getExcludedTables());
$this->assertSame([], $config->getTablesToSort());
$this->assertSame([], $config->getTablesToFilter());
$this->assertSame([], $config->getTablesToTruncate());
Expand Down

0 comments on commit bc47a54

Please sign in to comment.