From e37041aa942f52386586773d7304b50e069e706d Mon Sep 17 00:00:00 2001 From: SpacePossum Date: Fri, 18 Nov 2016 08:06:11 +0100 Subject: [PATCH] Update message. --- lib/Doctrine/ORM/EntityManager.php | 8 +++++++- tests/Doctrine/Tests/ORM/EntityManagerTest.php | 7 +++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php index 112502b5a..51d6dbf05 100644 --- a/lib/Doctrine/ORM/EntityManager.php +++ b/lib/Doctrine/ORM/EntityManager.php @@ -860,7 +860,13 @@ use Doctrine\Common\Util\ClassUtils; } if ( ! $connection instanceof Connection) { - throw new \InvalidArgumentException(sprintf('Invalid argument for connection "%s".', is_object($connection) ? get_class($connection) : gettype($connection) . '#' . $connection)); + throw new \InvalidArgumentException( + sprintf( + 'Invalid $connection argument of type %s given%s.', + is_object($connection) ? get_class($connection) : gettype($connection), + is_object($connection) ? '' : ': "' . $connection . '"' + ) + ); } if ($eventManager !== null && $connection->getEventManager() !== $eventManager) { diff --git a/tests/Doctrine/Tests/ORM/EntityManagerTest.php b/tests/Doctrine/Tests/ORM/EntityManagerTest.php index 1b08fb79e..ec7f1301f 100644 --- a/tests/Doctrine/Tests/ORM/EntityManagerTest.php +++ b/tests/Doctrine/Tests/ORM/EntityManagerTest.php @@ -208,12 +208,11 @@ class EntityManagerTest extends OrmTestCase return 'callback'; } - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessageRegExp /^Invalid argument for connection \"integer#1\".$/ - */ public function testCreateInvalidConnection() { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessageRegExp('/^Invalid \$connection argument of type integer given: \"1\".$/'); + $config = new Configuration(); $config->setMetadataDriverImpl($this->createMock(MappingDriver::class)); EntityManager::create(1, $config);