Unverified Commit 0b754b59 authored by Kim Hemsø Rasmussen's avatar Kim Hemsø Rasmussen Committed by Marco Pivetta

Moved testing of 'Doctrine\DBALDBALException::invalidPlatformSpecified' to DBALDBALExceptionTest.

Added upgrade notice about BC break.
Cleanups
parent c9694b73
# Upgrade to 2.6.2
## MINOR BC BREAK:
1 ``Doctrine\DBALDBALException::invalidPlatformSpecified()`` now has one argument which takes the invalid platform option.
Before:
Doctrine\DBALDBALException::invalidPlatformSpecified();
After:
Doctrine\DBALDBALException::invalidPlatformSpecified($invalidPlatform);
# Upgrade to 2.6
## MINOR BC BREAK: `fetch()` and `fetchAll()` method signatures in `Doctrine\DBAL\Driver\ResultStatement`
......
......@@ -37,19 +37,31 @@ class DBALException extends \Exception
}
/**
* @param $invalidPlatform
* Returns a new instance for an invalid platform specified.
*
* @param mixed $invalidPlatform The invalid platform given.
*
* @return DBALException
*/
public static function invalidPlatformSpecified($invalidPlatform): self
{
if (is_object($invalidPlatform)) {
return new self(
sprintf(
"Option 'platform' must be a subtype of '%s', instance of '%s' given",
AbstractPlatform::class,
get_class($invalidPlatform)
)
);
}
return new self(
sprintf(
"Given 'platform' option '%s' must be a subtype of '%s'",
get_class($invalidPlatform),
AbstractPlatform::class
"Option 'platform' must be an object and subtype of '%s'. Got '%s'",
AbstractPlatform::class,
gettype($invalidPlatform)
)
);
}
/**
......
......@@ -804,7 +804,6 @@ class ConnectionTest extends \Doctrine\Tests\DbalTestCase
$connectionParams = $this->params;
// This is our main expectation
$queryCacheProfileMock
->expects($this->once())
->method('generateCacheKeys')
......@@ -824,10 +823,6 @@ class ConnectionTest extends \Doctrine\Tests\DbalTestCase
*/
public function testThrowsExceptionWhenInValidPlatformSpecified(): void
{
self::expectException(DBALException::class);
self::expectExceptionMessage(
"Given 'platform' option 'stdClass' must be a subtype of 'Doctrine\DBAL\Platforms\AbstractPlatform'"
);
$connectionParams = $this->params;
$connectionParams['platform'] = new \stdClass();
......@@ -835,6 +830,8 @@ class ConnectionTest extends \Doctrine\Tests\DbalTestCase
/* @var $driver Driver */
$driver = $this->createMock(Driver::class);
$this->expectException(DBALException::class);
new Connection($connectionParams, $driver);
}
......
......@@ -58,4 +58,30 @@ class DBALExceptionTest extends DbalTestCase
$exception->getMessage()
);
}
/**
* @group DBAL-2821
*/
public function testInvalidPlatformSpecifiedObject(): void
{
$exception = DBALException::invalidPlatformSpecified(new \stdClass());
self::assertSame(
"Option 'platform' must be a subtype of 'Doctrine\DBAL\Platforms\AbstractPlatform', instance of 'stdClass' given",
$exception->getMessage()
);
}
/**
* @group DBAL-2821
*/
public function testInvalidPlatformSpecifiedScalar(): void
{
$exception = DBALException::invalidPlatformSpecified("some string");
self::assertSame(
"Option 'platform' must be an object and subtype of 'Doctrine\DBAL\Platforms\AbstractPlatform'. Got 'string'",
$exception->getMessage()
);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment