/** * Tests whether the selection of white listed tables works correctly. * * @test */ public function testWhiteListFilter() { $config = new SqlDumperConfiguration(); $tableFilter = new TableFilter($config); $table1 = new Table('table1'); $table2 = new Table('table2'); $allTables = array($table1, $table2); $filtered = $tableFilter->filterWhiteListTables($allTables); $this->assertEquals($allTables, $filtered); // Whitelist only one table $config->setTableWhiteList(array('table1')); $filtered = $tableFilter->filterWhiteListTables($allTables); $this->assertEquals(array($table1), $filtered); }
/** * Returns an array with all available tables that should be dumped. Those tables are pre-sorted according to * their dependencies to other tables. Furthermore, the identifiers of the tables are already quoted. * * @param DumperConfigurationInterface $config * * @return \Doctrine\DBAL\Schema\Table[] */ public function findTablesToDump(DumperConfigurationInterface $config) { $schemaManager = $this->connection->getSchemaManager(); $tables = $schemaManager->listTables(); $this->createMissingTableConfigs($config, $tables); $tables = $this->tableDependencyResolver->sortTablesByDependencies($tables); $this->tableDependencyResolver->createDependentFilters($tables, $config); $filter = new TableFilter($config); $tables = $filter->filterWhiteListTables($tables); $tables = $filter->filterIgnoredTables($tables); // Quote all identifiers, as Doctrine DBAL only quotes reserved keywords by default $tables = $this->identifierQuoter->quoteTables($tables); return $tables; }