Remove assertions about createMock() return value

Upstream libs and tools have improvements that make them unnecessary.
parent 5cff2bb7
......@@ -1552,7 +1552,6 @@ abstract class AbstractPlatform
if (($createFlags&self::CREATE_INDEXES) > 0) {
foreach ($table->getIndexes() as $index) {
assert($index instanceof Index);
if ($index->isPrimary()) {
$options['primary'] = $index->getQuotedColumns($this);
$options['primary_index'] = $index;
......
......@@ -19,7 +19,6 @@ use function array_diff;
use function array_merge;
use function array_unique;
use function array_values;
use function assert;
use function count;
use function explode;
use function implode;
......@@ -532,7 +531,6 @@ SQL
}
foreach ($diff->changedColumns as $columnDiff) {
assert($columnDiff instanceof ColumnDiff);
if ($this->onSchemaAlterTableChangeColumn($columnDiff, $diff, $columnSql)) {
continue;
}
......
......@@ -7,7 +7,6 @@ use Doctrine\DBAL\Schema\Visitor\Visitor;
use Doctrine\DBAL\Types\Type;
use function array_filter;
use function array_merge;
use function assert;
use function in_array;
use function preg_match;
use function strlen;
......@@ -242,7 +241,6 @@ class Table extends AbstractAsset
public function columnsAreIndexed(array $columnNames)
{
foreach ($this->getIndexes() as $index) {
assert($index instanceof Index);
if ($index->spansColumns($columnNames)) {
return true;
}
......
......@@ -27,7 +27,6 @@ use Doctrine\Tests\DbalTestCase;
use Exception;
use PHPUnit\Framework\MockObject\MockObject;
use stdClass;
use function assert;
use function call_user_func_array;
/**
......@@ -167,13 +166,11 @@ class ConnectionTest extends DbalTestCase
$eventManager = new EventManager();
$platform = $this->createMock(AbstractPlatform::class);
assert($platform instanceof AbstractPlatform && $platform instanceof MockObject);
$platform->expects($this->once())
->method('setEventManager')
->with($eventManager);
$driver = $this->createMock(Driver::class);
assert($driver instanceof Driver || $driver instanceof MockObject);
$driver->expects($this->any())
->method('getDatabasePlatform')
->willReturn($platform);
......@@ -569,7 +566,6 @@ class ConnectionTest extends DbalTestCase
->onlyMethods(['executeQuery'])
->setConstructorArgs([[], $driverMock])
->getMock();
assert($conn instanceof Connection || $conn instanceof MockObject);
$conn->expects($this->once())
->method('executeQuery')
......@@ -605,7 +601,6 @@ class ConnectionTest extends DbalTestCase
->onlyMethods(['executeQuery'])
->setConstructorArgs([[], $driverMock])
->getMock();
assert($conn instanceof Connection || $conn instanceof MockObject);
$conn->expects($this->once())
->method('executeQuery')
......@@ -642,7 +637,6 @@ class ConnectionTest extends DbalTestCase
->onlyMethods(['executeQuery'])
->setConstructorArgs([[], $driverMock])
->getMock();
assert($conn instanceof Connection || $conn instanceof MockObject);
$conn->expects($this->once())
->method('executeQuery')
......@@ -677,7 +671,6 @@ class ConnectionTest extends DbalTestCase
->onlyMethods(['executeQuery'])
->setConstructorArgs([[], $driverMock])
->getMock();
assert($conn instanceof Connection || $conn instanceof MockObject);
$conn->expects($this->once())
->method('executeQuery')
......@@ -711,8 +704,7 @@ class ConnectionTest extends DbalTestCase
public function testCallingDeleteWithNoDeletionCriteriaResultsInInvalidArgumentException() : void
{
$driver = $this->createMock(Driver::class);
assert($driver instanceof Driver);
$driver = $this->createMock(Driver::class);
$pdoMock = $this->createMock(\Doctrine\DBAL\Driver\Connection::class);
// should never execute queries with invalid arguments
......@@ -771,13 +763,10 @@ class ConnectionTest extends DbalTestCase
public function testPlatformDetectionIsTriggerOnlyOnceOnRetrievingPlatform() : void
{
$driverMock = $this->createMock([Driver::class, VersionAwarePlatformDriver::class]);
assert($driverMock instanceof Driver || $driverMock instanceof VersionAwarePlatformDriver || $driverMock instanceof MockObject);
$driverConnectionMock = $this->createMock(ServerInfoAwareConnection::class);
assert($driverConnectionMock instanceof ServerInfoAwareConnection || $driverConnectionMock instanceof MockObject);
$platformMock = $this->getMockForAbstractClass(AbstractPlatform::class);
assert($platformMock instanceof AbstractPlatform || $platformMock instanceof MockObject);
$connection = new Connection([], $driverMock);
......@@ -816,7 +805,6 @@ class ConnectionTest extends DbalTestCase
$types = [ParameterType::INTEGER];
$queryCacheProfileMock = $this->createMock(QueryCacheProfile::class);
assert($queryCacheProfileMock instanceof QueryCacheProfile || $queryCacheProfileMock instanceof MockObject);
$queryCacheProfileMock
->expects($this->any())
......@@ -831,7 +819,6 @@ class ConnectionTest extends DbalTestCase
->will($this->returnValue(['cacheKey', 'realKey']));
$driver = $this->createMock(Driver::class);
assert($driver instanceof Driver);
self::assertInstanceOf(
ArrayStatement::class,
......@@ -853,7 +840,6 @@ class ConnectionTest extends DbalTestCase
->will($this->returnValue(['realKey' => []]));
$queryCacheProfileMock = $this->createMock(QueryCacheProfile::class);
assert($queryCacheProfileMock instanceof QueryCacheProfile || $queryCacheProfileMock instanceof MockObject);
$queryCacheProfileMock
->expects($this->any())
......@@ -873,7 +859,6 @@ class ConnectionTest extends DbalTestCase
$connectionParams['platform'] = $this->createMock(AbstractPlatform::class);
$driver = $this->createMock(Driver::class);
assert($driver instanceof Driver);
(new Connection($connectionParams, $driver))->executeCacheQuery($query, [], [], $queryCacheProfileMock);
}
......@@ -887,7 +872,6 @@ class ConnectionTest extends DbalTestCase
$connectionParams['platform'] = new stdClass();
$driver = $this->createMock(Driver::class);
assert($driver instanceof Driver);
$this->expectException(DBALException::class);
......@@ -900,7 +884,6 @@ class ConnectionTest extends DbalTestCase
public function testRethrowsOriginalExceptionOnDeterminingPlatformWhenConnectingToNonExistentDatabase() : void
{
$driverMock = $this->createMock([Driver::class, VersionAwarePlatformDriver::class]);
assert($driverMock instanceof Driver || $driverMock instanceof VersionAwarePlatformDriver || $driverMock instanceof MockObject);
$connection = new Connection(['dbname' => 'foo'], $driverMock);
$originalException = new Exception('Original exception');
......@@ -925,16 +908,12 @@ class ConnectionTest extends DbalTestCase
public function testExecuteCacheQueryStripsPlatformFromConnectionParamsBeforeGeneratingCacheKeys() : void
{
$driver = $this->createMock(Driver::class);
assert($driver instanceof Driver || $driver instanceof MockObject);
$platform = $this->createMock(AbstractPlatform::class);
assert($platform instanceof AbstractPlatform || $platform instanceof MockObject);
$queryCacheProfile = $this->createMock(QueryCacheProfile::class);
assert($queryCacheProfile instanceof QueryCacheProfile || $queryCacheProfile instanceof MockObject);
$resultCacheDriver = $this->createMock(Cache::class);
assert($resultCacheDriver instanceof Cache || $resultCacheDriver instanceof MockObject);
$queryCacheProfile
->expects($this->any())
......
......@@ -9,7 +9,6 @@ use Doctrine\DBAL\Exception\DriverException;
use Doctrine\Tests\DbalTestCase;
use Exception;
use stdClass;
use function assert;
use function chr;
use function fopen;
use function sprintf;
......@@ -19,26 +18,22 @@ class DBALExceptionTest extends DbalTestCase
public function testDriverExceptionDuringQueryAcceptsBinaryData() : void
{
$driver = $this->createMock(Driver::class);
assert($driver instanceof Driver);
$e = DBALException::driverExceptionDuringQuery($driver, new Exception(), '', ['ABC', chr(128)]);
$e = DBALException::driverExceptionDuringQuery($driver, new Exception(), '', ['ABC', chr(128)]);
self::assertStringContainsString('with params ["ABC", "\x80"]', $e->getMessage());
}
public function testDriverExceptionDuringQueryAcceptsResource() : void
{
$driver = $this->createMock(Driver::class);
assert($driver instanceof Driver);
$e = DBALException::driverExceptionDuringQuery($driver, new Exception(), 'INSERT INTO file (`content`) VALUES (?)', [1 => fopen(__FILE__, 'r')]);
$e = DBALException::driverExceptionDuringQuery($driver, new Exception(), 'INSERT INTO file (`content`) VALUES (?)', [1 => fopen(__FILE__, 'r')]);
self::assertStringContainsString('Resource', $e->getMessage());
}
public function testAvoidOverWrappingOnDriverException() : void
{
$driver = $this->createMock(Driver::class);
assert($driver instanceof Driver);
$inner = $this->createMock(InnerDriverException::class);
assert($inner instanceof InnerDriverException);
$ex = new DriverException('', $inner);
$e = DBALException::driverExceptionDuringQuery($driver, $ex, '');
......
......@@ -28,10 +28,8 @@ use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\VersionAwarePlatformDriver;
use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject;
use ReflectionProperty;
use function array_merge;
use function assert;
use function get_class;
use function sprintf;
......@@ -83,7 +81,6 @@ abstract class AbstractDriverTest extends DbalTestCase
$driverException = $this->getMockBuilder(DriverExceptionInterface::class)
->setConstructorArgs([$message])
->getMock();
assert($driverException instanceof DriverExceptionInterface || $driverException instanceof MockObject);
$driverException->method('getErrorCode')
->willReturn($errorCode);
$driverException->method('getSQLState')
......
......@@ -11,10 +11,8 @@ use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Driver\StatementIterator;
use Doctrine\DBAL\Portability\Statement as PortabilityStatement;
use Doctrine\Tests\DbalTestCase;
use IteratorAggregate;
use PHPUnit\Framework\MockObject\MockObject;
use Traversable;
use function assert;
use function extension_loaded;
class StatementIteratorTest extends DbalTestCase
......@@ -25,7 +23,6 @@ class StatementIteratorTest extends DbalTestCase
public function testGettingIteratorDoesNotCallFetch(string $class) : void
{
$stmt = $this->createPartialMock($class, ['fetch', 'fetchAll', 'fetchColumn']);
assert($stmt instanceof IteratorAggregate || $stmt instanceof MockObject);
$stmt->expects($this->never())->method('fetch');
$stmt->expects($this->never())->method('fetchAll');
$stmt->expects($this->never())->method('fetchColumn');
......
......@@ -22,7 +22,6 @@ use PDO;
use function array_change_key_case;
use function array_filter;
use function array_keys;
use function assert;
use function count;
use function date;
use function implode;
......@@ -955,7 +954,7 @@ class DataAccessTest extends DbalFunctionalTestCase
}
$connection = $this->connection->getWrappedConnection();
assert($connection instanceof PDOConnection);
self::assertInstanceOf(PDOConnection::class, $connection);
$connection->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
}
}
......
......@@ -9,7 +9,6 @@ use Doctrine\DBAL\Schema\Table;
use Doctrine\Tests\DbalFunctionalTestCase;
use Throwable;
use function array_change_key_case;
use function assert;
use function sprintf;
use function strlen;
use function strtolower;
......@@ -85,7 +84,7 @@ class MasterSlaveConnectionTest extends DbalFunctionalTestCase
}
$conn = DriverManager::getConnection($params);
assert($conn instanceof MasterSlaveConnection);
self::assertInstanceOf(MasterSlaveConnection::class, $conn);
$conn->connect('slave');
self::assertFalse($conn->isConnectedToMaster());
......
......@@ -10,7 +10,6 @@ use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use function assert;
class SchemaDiffTest extends TestCase
{
......@@ -44,7 +43,6 @@ class SchemaDiffTest extends TestCase
private function createPlatform(bool $unsafe)
{
$platform = $this->createMock(AbstractPlatform::class);
assert($platform instanceof AbstractPlatform || $platform instanceof MockObject);
$platform->expects($this->exactly(1))
->method('getCreateSchemaSQL')
->with('foo_ns')
......
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