Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass;

use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
Expand Down Expand Up @@ -175,8 +174,8 @@ public function process(ContainerBuilder $container)
*
* @return string The name of the chain driver service
*
* @throws ParameterNotFoundException if non of the managerParameters has a
* non-empty value.
* @throws InvalidArgumentException if non of the managerParameters has a
* non-empty value.
*/
protected function getChainDriverServiceName(ContainerBuilder $container)
{
Expand All @@ -203,8 +202,8 @@ protected function getDriver(ContainerBuilder $container)
*
* @return string a service definition name
*
* @throws ParameterNotFoundException if none of the managerParameters has a
* non-empty value.
* @throws InvalidArgumentException if none of the managerParameters has a
* non-empty value.
*/
private function getConfigurationServiceName(ContainerBuilder $container)
{
Expand All @@ -221,7 +220,7 @@ private function getConfigurationServiceName(ContainerBuilder $container)
*
* @return string The name of the active manager.
*
* @throws ParameterNotFoundException If none of the managerParameters is found in the container.
* @throws InvalidArgumentException If none of the managerParameters is found in the container.
*/
private function getManagerName(ContainerBuilder $container)
{
Expand All @@ -234,7 +233,10 @@ private function getManagerName(ContainerBuilder $container)
}
}

throw new ParameterNotFoundException('Could not determine the Doctrine manager. Either Doctrine is not configured or a bundle is misconfigured.');
throw new \InvalidArgumentException(sprintf(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. This is potentially a BC break if anybody was depending on the ParameterNotFoundException for any reason.
  2. Should this be a DependencyInjection\Exception\InvalidArgumentException or similar?

'Could not find the manager name parameter in the container. Tried the following parameter names: "%s"',
implode('", "', $this->managerParameters)
));
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace Symfony\Bridge\Doctrine\Tests\DependencyInjection\CompilerPass;

use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterMappingsPass;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\ContainerBuilder;

class RegisterMappingsPassTest extends \PHPUnit_Framework_TestCase
{
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessageould Could not find the manager name parameter in the container. Tried the following parameter names: "manager.param.one", "manager.param.two"
*/
public function testNoDriverParmeterException()
{
$container = $this->createBuilder([

]);
$this->process($container, [
'manager.param.one',
'manager.param.two',
]);
}

private function process(ContainerBuilder $container, array $managerParamNames)
{
$pass = new ConcreteMappingsPass(
new Definition('\stdClass'),
[],
$managerParamNames,
'some.%s.metadata_driver'
);

$pass->process($container);
}

private function createBuilder()
{
$container = new ContainerBuilder();

return $container;
}
}

class ConcreteMappingsPass extends RegisterMappingsPass
{
}