Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 359a063

Browse files
committed
bug #22164 [Bridge\Doctrine] Fix change breaking doctrine-bundle test suite (nicolas-grekas)
This PR was merged into the 2.7 branch. Discussion ---------- [Bridge\Doctrine] Fix change breaking doctrine-bundle test suite | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Doctrine Bundle's test suite [is currently broken](https://travis-ci.org/doctrine/DoctrineBundle/jobs/215222182) with `2.8@dev` because the tests expect `addEventListener` to be called with an array as first arg, but #22001 optimized them away as string. Since internally strings are turned back into arrays, let's tweak that change and make Doctrine Bundle green again. Commits ------- 0577c7b [Bridge\Doctrine] Fix change breaking doctrine-bundle test suite
2 parents da0b520 + 0577c7b commit 359a063

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,12 @@ private function addTaggedListeners(ContainerBuilder $container)
109109
throw new RuntimeException(sprintf('The Doctrine connection "%s" referenced in service "%s" does not exist. Available connections names: %s', $con, $id, implode(', ', array_keys($this->connections))));
110110
}
111111

112-
if ($lazy = isset($tag['lazy']) && $tag['lazy']) {
112+
if ($lazy = !empty($tag['lazy'])) {
113113
$taggedListenerDef->setPublic(true);
114114
}
115115

116116
// we add one call per event per service so we have the correct order
117-
$this->getEventManagerDef($container, $con)->addMethodCall('addEventListener', array(
118-
$tag['event'],
119-
$lazy ? $id : new Reference($id),
120-
));
117+
$this->getEventManagerDef($container, $con)->addMethodCall('addEventListener', array(array($tag['event']), $lazy ? $id : new Reference($id)));
121118
}
122119
}
123120
}

src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPassTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ public function testProcessEventListenersWithPriorities()
9090

9191
$this->assertEquals(
9292
array(
93-
array('addEventListener', array('foo_bar', new Reference('c'))),
94-
array('addEventListener', array('foo_bar', new Reference('a'))),
95-
array('addEventListener', array('bar', new Reference('a'))),
96-
array('addEventListener', array('foo', new Reference('b'))),
97-
array('addEventListener', array('foo', new Reference('a'))),
93+
array('addEventListener', array(array('foo_bar'), new Reference('c'))),
94+
array('addEventListener', array(array('foo_bar'), new Reference('a'))),
95+
array('addEventListener', array(array('bar'), new Reference('a'))),
96+
array('addEventListener', array(array('foo'), new Reference('b'))),
97+
array('addEventListener', array(array('foo'), new Reference('a'))),
9898
),
9999
$methodCalls
100100
);
@@ -138,16 +138,16 @@ public function testProcessEventListenersWithMultipleConnections()
138138

139139
$this->assertEquals(
140140
array(
141-
array('addEventListener', array('onFlush', new Reference('a'))),
142-
array('addEventListener', array('onFlush', new Reference('b'))),
141+
array('addEventListener', array(array('onFlush'), new Reference('a'))),
142+
array('addEventListener', array(array('onFlush'), new Reference('b'))),
143143
),
144144
$container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls()
145145
);
146146

147147
$this->assertEquals(
148148
array(
149-
array('addEventListener', array('onFlush', new Reference('a'))),
150-
array('addEventListener', array('onFlush', new Reference('c'))),
149+
array('addEventListener', array(array('onFlush'), new Reference('a'))),
150+
array('addEventListener', array(array('onFlush'), new Reference('c'))),
151151
),
152152
$container->getDefinition('doctrine.dbal.second_connection.event_manager')->getMethodCalls()
153153
);

0 commit comments

Comments
 (0)