Skip to content

Commit

Permalink
split tests to test well known services one at a time
Browse files Browse the repository at this point in the history
  • Loading branch information
bendavies committed Dec 18, 2019
1 parent 0351ce0 commit 4cfbe9b
Show file tree
Hide file tree
Showing 18 changed files with 294 additions and 84 deletions.
46 changes: 29 additions & 17 deletions Tests/DependencyInjection/AbstractDoctrineExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');
Expand All @@ -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');
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" ?>

<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:srv="http://symfony.com/schema/dic/services"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">

<config>
<dbal default-connection="connection1">
<connection name="connection1" schema-filter="~^(?!t_)~" />
<connection name="connection2" />
<connection name="connection3" />
</dbal>
</config>

<srv:services>
<srv:service id="well_known_filter" alias="doctrine.dbal.well_known_schema_asset_filter" public="true" />
<srv:service id="symfony.cache" class="Symfony\Component\Cache\Adapter\PdoAdapter" />
</srv:services>
</srv:container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" ?>

<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:srv="http://symfony.com/schema/dic/services"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">

<config>
<dbal default-connection="connection1">
<connection name="connection1" schema-filter="~^(?!t_)~" />
<connection name="connection2" />
<connection name="connection3" />
</dbal>
</config>

<srv:services>
<srv:service id="well_known_filter" alias="doctrine.dbal.well_known_schema_asset_filter" public="true" />
<srv:service id="symfony.lock" class="Symfony\Component\Lock\Store\PdoStore" />
</srv:services>
</srv:container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" ?>

<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:srv="http://symfony.com/schema/dic/services"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">

<config>
<dbal default-connection="connection1">
<connection name="connection1" schema-filter="~^(?!t_)~" />
<connection name="connection2" />
<connection name="connection3" />
</dbal>
</config>

<srv:services>
<srv:service id="well_known_filter" alias="doctrine.dbal.well_known_schema_asset_filter" public="true" />
<srv:service id="symfony.messenger" class="Symfony\Component\Messenger\Transport\Doctrine\Connection" />
</srv:services>
</srv:container>
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

<srv:services>
<srv:service id="well_known_filter" alias="doctrine.dbal.well_known_schema_asset_filter" public="true" />
<srv:service id="symfony.cache" class="Symfony\Component\Cache\Adapter\PdoAdapter" />
<srv:service id="symfony.session" class="Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler" />
<srv:service id="symfony.lock" class="Symfony\Component\Lock\Store\PdoStore" />
<srv:service id="symfony.messenger" class="Symfony\Component\Messenger\Transport\Doctrine\Connection" />
</srv:services>
</srv:container>
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,5 @@
<srv:argument key="db_table">app_cache</srv:argument>
</srv:argument>
</srv:service>
<srv:service id="symfony.session" class="Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler">
<srv:argument />
<srv:argument type="collection">
<srv:argument key="db_table">app_session</srv:argument>
</srv:argument>
</srv:service>
<srv:service id="symfony.lock" class="Symfony\Component\Lock\Store\PdoStore">
<srv:argument />
<srv:argument type="collection">
<srv:argument key="db_table">app_locks</srv:argument>
</srv:argument>
</srv:service>
<srv:service id="symfony.messenger" class="Symfony\Component\Messenger\Transport\Doctrine\Connection">
<srv:argument type="collection">
<srv:argument key="table_name">app_messages</srv:argument>
</srv:argument>
</srv:service>
</srv:services>
</srv:container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" ?>

<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:srv="http://symfony.com/schema/dic/services"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">

<config>
<dbal default-connection="connection1">
<connection name="connection1" schema-filter="~^(?!t_)~" />
<connection name="connection2" />
<connection name="connection3" />
</dbal>
</config>

<srv:services>
<srv:service id="well_known_filter" alias="doctrine.dbal.well_known_schema_asset_filter" public="true" />
<srv:service id="symfony.lock" class="Symfony\Component\Lock\Store\PdoStore">
<srv:argument />
<srv:argument type="collection">
<srv:argument key="db_table">app_locks</srv:argument>
</srv:argument>
</srv:service>
</srv:services>
</srv:container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" ?>

<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:srv="http://symfony.com/schema/dic/services"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">

<config>
<dbal default-connection="connection1">
<connection name="connection1" schema-filter="~^(?!t_)~" />
<connection name="connection2" />
<connection name="connection3" />
</dbal>
</config>

<srv:services>
<srv:service id="well_known_filter" alias="doctrine.dbal.well_known_schema_asset_filter" public="true" />
<srv:service id="symfony.messenger" class="Symfony\Component\Messenger\Transport\Doctrine\Connection">
<srv:argument type="collection">
<srv:argument key="table_name">app_messages</srv:argument>
</srv:argument>
</srv:service>
</srv:services>
</srv:container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" ?>

<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:srv="http://symfony.com/schema/dic/services"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">

<config>
<dbal default-connection="connection1">
<connection name="connection1" schema-filter="~^(?!t_)~" />
<connection name="connection2" />
<connection name="connection3" />
</dbal>
</config>

<srv:services>
<srv:service id="well_known_filter" alias="doctrine.dbal.well_known_schema_asset_filter" public="true" />
<srv:service id="symfony.session" class="Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler">
<srv:argument />
<srv:argument type="collection">
<srv:argument key="db_table">app_session</srv:argument>
</srv:argument>
</srv:service>
</srv:services>
</srv:container>
Original file line number Diff line number Diff line change
@@ -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'
Original file line number Diff line number Diff line change
@@ -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'
Original file line number Diff line number Diff line change
@@ -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'
Original file line number Diff line number Diff line change
@@ -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'

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit 4cfbe9b

Please sign in to comment.