Skip to content
Snippets Groups Projects
Commit 828a0955 authored by David Prévot's avatar David Prévot
Browse files

New upstream version 3.4.1

parents 2e9e8b09 db06a3f3
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,9 @@ ...@@ -12,7 +12,9 @@
namespace Symfony\Contracts\Service\Test; namespace Symfony\Contracts\Service\Test;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface; use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
use Symfony\Contracts\Service\ServiceLocatorTrait; use Symfony\Contracts\Service\ServiceLocatorTrait;
abstract class ServiceLocatorTestCase extends TestCase abstract class ServiceLocatorTestCase extends TestCase
...@@ -66,27 +68,29 @@ abstract class ServiceLocatorTestCase extends TestCase ...@@ -66,27 +68,29 @@ abstract class ServiceLocatorTestCase extends TestCase
public function testThrowsOnUndefinedInternalService() public function testThrowsOnUndefinedInternalService()
{ {
if (!$this->getExpectedException()) {
$this->expectException(\Psr\Container\NotFoundExceptionInterface::class);
$this->expectExceptionMessage('The service "foo" has a dependency on a non-existent service "bar". This locator only knows about the "foo" service.');
}
$locator = $this->getServiceLocator([ $locator = $this->getServiceLocator([
'foo' => function () use (&$locator) { return $locator->get('bar'); }, 'foo' => function () use (&$locator) { return $locator->get('bar'); },
]); ]);
if (!$this->getExpectedException()) {
$this->expectException(NotFoundExceptionInterface::class);
$this->expectExceptionMessage('The service "foo" has a dependency on a non-existent service "bar". This locator only knows about the "foo" service.');
}
$locator->get('foo'); $locator->get('foo');
} }
public function testThrowsOnCircularReference() public function testThrowsOnCircularReference()
{ {
$this->expectException(\Psr\Container\ContainerExceptionInterface::class);
$this->expectExceptionMessage('Circular reference detected for service "bar", path: "bar -> baz -> bar".');
$locator = $this->getServiceLocator([ $locator = $this->getServiceLocator([
'foo' => function () use (&$locator) { return $locator->get('bar'); }, 'foo' => function () use (&$locator) { return $locator->get('bar'); },
'bar' => function () use (&$locator) { return $locator->get('baz'); }, 'bar' => function () use (&$locator) { return $locator->get('baz'); },
'baz' => function () use (&$locator) { return $locator->get('bar'); }, 'baz' => function () use (&$locator) { return $locator->get('bar'); },
]); ]);
$this->expectException(ContainerExceptionInterface::class);
$this->expectExceptionMessage('Circular reference detected for service "bar", path: "bar -> baz -> bar".');
$locator->get('foo'); $locator->get('foo');
} }
} }
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
], ],
"require": { "require": {
"php": ">=8.1", "php": ">=8.1",
"psr/container": "^2.0" "psr/container": "^1.1|^2.0"
}, },
"conflict": { "conflict": {
"ext-psr": "<1.1|>=2" "ext-psr": "<1.1|>=2"
......
...@@ -183,9 +183,10 @@ class TranslatorTest extends TestCase ...@@ -183,9 +183,10 @@ class TranslatorTest extends TestCase
*/ */
public function testThrowExceptionIfMatchingMessageCannotBeFound($id, $number) public function testThrowExceptionIfMatchingMessageCannotBeFound($id, $number)
{ {
$this->expectException(\InvalidArgumentException::class);
$translator = $this->getTranslator(); $translator = $this->getTranslator();
$this->expectException(\InvalidArgumentException::class);
$translator->trans($id, ['%count%' => $number]); $translator->trans($id, ['%count%' => $number]);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment