From e14569c9903bc3b1d5e5ec871e86fb032180b7ba Mon Sep 17 00:00:00 2001 From: Ben Davies Date: Wed, 18 Dec 2019 11:18:56 +0000 Subject: [PATCH] split tests to test well known services one at a time --- .../AbstractDoctrineExtensionTest.php | 46 ++++++++++++------- ...own_schema_filter_default_tables_cache.xml | 21 +++++++++ ...nown_schema_filter_default_tables_lock.xml | 21 +++++++++ ...schema_filter_default_tables_messenger.xml | 21 +++++++++ ..._schema_filter_default_tables_session.xml} | 3 -- ...schema_filter_overridden_tables_cache.xml} | 17 ------- ...n_schema_filter_overridden_tables_lock.xml | 26 +++++++++++ ...ema_filter_overridden_tables_messenger.xml | 25 ++++++++++ ...chema_filter_overridden_tables_session.xml | 26 +++++++++++ ...own_schema_filter_default_tables_cache.yml | 16 +++++++ ...nown_schema_filter_default_tables_lock.yml | 16 +++++++ ...schema_filter_default_tables_messenger.yml | 16 +++++++ ...n_schema_filter_default_tables_session.yml | 16 +++++++ ..._schema_filter_overridden_tables_cache.yml | 21 +++++++++ ...n_schema_filter_overridden_tables_lock.yml | 19 ++++++++ ...ema_filter_overridden_tables_messenger.yml | 18 ++++++++ ...chema_filter_overridden_tables_session.yml | 19 ++++++++ 17 files changed, 310 insertions(+), 37 deletions(-) create mode 100644 Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_default_tables_cache.xml create mode 100644 Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_default_tables_lock.xml create mode 100644 Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_default_tables_messenger.xml rename Tests/DependencyInjection/Fixtures/config/xml/{well_known_schema_filter_default_tables.xml => well_known_schema_filter_default_tables_session.xml} (77%) rename Tests/DependencyInjection/Fixtures/config/xml/{well_known_schema_filter_overridden_tables.xml => well_known_schema_filter_overridden_tables_cache.xml} (57%) create mode 100644 Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_overridden_tables_lock.xml create mode 100644 Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_overridden_tables_messenger.xml create mode 100644 Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_overridden_tables_session.xml create mode 100644 Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_default_tables_cache.yml create mode 100644 Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_default_tables_lock.yml create mode 100644 Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_default_tables_messenger.yml create mode 100644 Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_default_tables_session.yml create mode 100644 Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_overridden_tables_cache.yml create mode 100644 Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_overridden_tables_lock.yml create mode 100644 Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_overridden_tables_messenger.yml create mode 100644 Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_overridden_tables_session.yml diff --git a/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php b/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php index d091bbcf5..266d05fc8 100644 --- a/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php +++ b/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php @@ -843,7 +843,18 @@ public function testDbalSchemaFilterNewConfig() $this->assertNull($connConfig = $getConfiguration('connection3')->getSchemaAssetsFilter()); } - public function testWellKnownSchemaFilterDefaultTables() + public static function dataWellKnownSchemaFilterServices() + { + yield ['cache', 'cache_items']; + yield ['lock', 'lock_keys']; + yield ['messenger', 'messenger_messages']; + yield ['session', 'sessions']; + } + + /** + * @dataProvider dataWellKnownSchemaFilterServices + */ + public function testWellKnownSchemaFilterDefaultTables(string $fileName, string $tableName) { if (! method_exists(Configuration::class, 'setSchemaAssetsFilter')) { $this->markTestSkipped('Test requires doctrine/dbal 2.9 or higher'); @@ -855,13 +866,13 @@ public function testWellKnownSchemaFilterDefaultTables() $container->addCompilerPass(new WellKnownSchemaFilterPass()); $container->addCompilerPass(new DbalSchemaFilterPass()); - $this->loadFromFile($container, 'well_known_schema_filter_default_tables'); + $this->loadFromFile($container, 'well_known_schema_filter_default_tables_' . $fileName); $this->compileContainer($container); $definition = $container->getDefinition('doctrine.dbal.well_known_schema_asset_filter'); - $this->assertSame([['cache_items', 'sessions', 'lock_keys', 'messenger_messages']], $definition->getArguments()); + $this->assertSame([[$tableName]], $definition->getArguments()); $this->assertSame([['connection' => 'connection1'], ['connection' => 'connection2'], ['connection' => 'connection3']], $definition->getTag('doctrine.dbal.schema_filter')); $definition = $container->getDefinition('doctrine.dbal.connection1_schema_asset_filter_manager'); @@ -870,14 +881,22 @@ public function testWellKnownSchemaFilterDefaultTables() $filter = $container->get('well_known_filter'); - $this->assertFalse($filter('sessions')); - $this->assertFalse($filter('cache_items')); - $this->assertFalse($filter('lock_keys')); - $this->assertFalse($filter('messenger_messages')); + $this->assertFalse($filter($tableName)); $this->assertTrue($filter('anything_else')); } - public function testWellKnownSchemaFilterOverriddenTables() + public static function dataWellKnownSchemaOverriddenTablesFilterServices() + { + yield ['cache', 'app_cache']; + yield ['lock', 'app_locks']; + yield ['messenger', 'app_messages']; + yield ['session', 'app_session']; + } + + /** + * @dataProvider dataWellKnownSchemaOverriddenTablesFilterServices + */ + public function testWellKnownSchemaFilterOverriddenTables(string $fileName, string $tableName) { if (! method_exists(Configuration::class, 'setSchemaAssetsFilter')) { $this->markTestSkipped('Test requires doctrine/dbal 2.9 or higher'); @@ -889,20 +908,13 @@ public function testWellKnownSchemaFilterOverriddenTables() $container->addCompilerPass(new WellKnownSchemaFilterPass()); $container->addCompilerPass(new DbalSchemaFilterPass()); - $this->loadFromFile($container, 'well_known_schema_filter_overridden_tables'); + $this->loadFromFile($container, 'well_known_schema_filter_overridden_tables_' . $fileName); $this->compileContainer($container); $filter = $container->get('well_known_filter'); - $this->assertFalse($filter('app_session')); - $this->assertFalse($filter('app_cache')); - $this->assertFalse($filter('app_locks')); - $this->assertFalse($filter('app_messages')); - $this->assertTrue($filter('sessions')); - $this->assertTrue($filter('cache_items')); - $this->assertTrue($filter('lock_keys')); - $this->assertTrue($filter('messenger_messages')); + $this->assertFalse($filter($tableName)); } public function testEntityListenerResolver() diff --git a/Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_default_tables_cache.xml b/Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_default_tables_cache.xml new file mode 100644 index 000000000..15d2ef4d2 --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_default_tables_cache.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + diff --git a/Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_default_tables_lock.xml b/Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_default_tables_lock.xml new file mode 100644 index 000000000..9b2f45b0e --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_default_tables_lock.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + diff --git a/Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_default_tables_messenger.xml b/Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_default_tables_messenger.xml new file mode 100644 index 000000000..a25dadf43 --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_default_tables_messenger.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + diff --git a/Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_default_tables.xml b/Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_default_tables_session.xml similarity index 77% rename from Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_default_tables.xml rename to Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_default_tables_session.xml index a63c484d1..6ab8f22d6 100644 --- a/Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_default_tables.xml +++ b/Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_default_tables_session.xml @@ -16,9 +16,6 @@ - - - diff --git a/Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_overridden_tables.xml b/Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_overridden_tables_cache.xml similarity index 57% rename from Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_overridden_tables.xml rename to Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_overridden_tables_cache.xml index 99b2d51cd..08cee3287 100644 --- a/Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_overridden_tables.xml +++ b/Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_overridden_tables_cache.xml @@ -24,22 +24,5 @@ app_cache - - - - app_session - - - - - - app_locks - - - - - app_messages - - diff --git a/Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_overridden_tables_lock.xml b/Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_overridden_tables_lock.xml new file mode 100644 index 000000000..9d49f149d --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_overridden_tables_lock.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + app_locks + + + + diff --git a/Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_overridden_tables_messenger.xml b/Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_overridden_tables_messenger.xml new file mode 100644 index 000000000..eda437a57 --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_overridden_tables_messenger.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + app_messages + + + + diff --git a/Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_overridden_tables_session.xml b/Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_overridden_tables_session.xml new file mode 100644 index 000000000..1ca50b228 --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/config/xml/well_known_schema_filter_overridden_tables_session.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + app_session + + + + diff --git a/Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_default_tables_cache.yml b/Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_default_tables_cache.yml new file mode 100644 index 000000000..636fed07c --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_default_tables_cache.yml @@ -0,0 +1,16 @@ +doctrine: + dbal: + default_connection: connection1 + connections: + connection1: + schema_filter: ~^(?!t_)~ + connection2: [] + connection3: [] + +services: + well_known_filter: + alias: 'doctrine.dbal.well_known_schema_asset_filter' + public: true + + symfony.cache: + class: 'Symfony\Component\Cache\Adapter\PdoAdapter' diff --git a/Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_default_tables_lock.yml b/Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_default_tables_lock.yml new file mode 100644 index 000000000..e68190cc9 --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_default_tables_lock.yml @@ -0,0 +1,16 @@ +doctrine: + dbal: + default_connection: connection1 + connections: + connection1: + schema_filter: ~^(?!t_)~ + connection2: [] + connection3: [] + +services: + well_known_filter: + alias: 'doctrine.dbal.well_known_schema_asset_filter' + public: true + + symfony.lock: + class: 'Symfony\Component\Lock\Store\PdoStore' diff --git a/Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_default_tables_messenger.yml b/Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_default_tables_messenger.yml new file mode 100644 index 000000000..6cc941e20 --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_default_tables_messenger.yml @@ -0,0 +1,16 @@ +doctrine: + dbal: + default_connection: connection1 + connections: + connection1: + schema_filter: ~^(?!t_)~ + connection2: [] + connection3: [] + +services: + well_known_filter: + alias: 'doctrine.dbal.well_known_schema_asset_filter' + public: true + + symfony.messenger: + class: 'Symfony\Component\Messenger\Transport\Doctrine\Connection' diff --git a/Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_default_tables_session.yml b/Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_default_tables_session.yml new file mode 100644 index 000000000..eae8efc5e --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_default_tables_session.yml @@ -0,0 +1,16 @@ +doctrine: + dbal: + default_connection: connection1 + connections: + connection1: + schema_filter: ~^(?!t_)~ + connection2: [] + connection3: [] + +services: + well_known_filter: + alias: 'doctrine.dbal.well_known_schema_asset_filter' + public: true + + symfony.session: + class: 'Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler' \ No newline at end of file diff --git a/Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_overridden_tables_cache.yml b/Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_overridden_tables_cache.yml new file mode 100644 index 000000000..0b47a5525 --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_overridden_tables_cache.yml @@ -0,0 +1,21 @@ +doctrine: + dbal: + default_connection: connection1 + connections: + connection1: + schema_filter: ~^(?!t_)~ + connection2: [] + connection3: [] + +services: + well_known_filter: + alias: 'doctrine.dbal.well_known_schema_asset_filter' + public: true + + symfony.cache: + class: 'Symfony\Component\Cache\Adapter\PdoAdapter' + arguments: + - ~ + - ~ + - ~ + - db_table: app_cache \ No newline at end of file diff --git a/Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_overridden_tables_lock.yml b/Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_overridden_tables_lock.yml new file mode 100644 index 000000000..85e81d344 --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_overridden_tables_lock.yml @@ -0,0 +1,19 @@ +doctrine: + dbal: + default_connection: connection1 + connections: + connection1: + schema_filter: ~^(?!t_)~ + connection2: [] + connection3: [] + +services: + well_known_filter: + alias: 'doctrine.dbal.well_known_schema_asset_filter' + public: true + + symfony.lock: + class: 'Symfony\Component\Lock\Store\PdoStore' + arguments: + - ~ + - db_table: app_locks \ No newline at end of file diff --git a/Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_overridden_tables_messenger.yml b/Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_overridden_tables_messenger.yml new file mode 100644 index 000000000..fb54b7c4c --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_overridden_tables_messenger.yml @@ -0,0 +1,18 @@ +doctrine: + dbal: + default_connection: connection1 + connections: + connection1: + schema_filter: ~^(?!t_)~ + connection2: [] + connection3: [] + +services: + well_known_filter: + alias: 'doctrine.dbal.well_known_schema_asset_filter' + public: true + + symfony.messenger: + class: 'Symfony\Component\Messenger\Transport\Doctrine\Connection' + arguments: + - table_name: app_messages diff --git a/Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_overridden_tables_session.yml b/Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_overridden_tables_session.yml new file mode 100644 index 000000000..0084db2b1 --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/config/yml/well_known_schema_filter_overridden_tables_session.yml @@ -0,0 +1,19 @@ +doctrine: + dbal: + default_connection: connection1 + connections: + connection1: + schema_filter: ~^(?!t_)~ + connection2: [] + connection3: [] + +services: + well_known_filter: + alias: 'doctrine.dbal.well_known_schema_asset_filter' + public: true + + symfony.session: + class: 'Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler' + arguments: + - ~ + - db_table: app_session